Update auto-generated bindings with new upstream.
[ldk-java] / src / main / jni / bindings.c
1 #include "org_ldk_impl_bindings.h"
2 #include <rust_types.h>
3 #include <lightning.h>
4 #include <string.h>
5 #include <stdatomic.h>
6 #include <stdlib.h>
7
8 #define MALLOC(a, _) malloc(a)
9 #define FREE(p) if ((long)(p) > 1024) { free(p); }
10 #define DO_ASSERT(a) (void)(a)
11 #define CHECK(a)
12
13 static jmethodID ordinal_meth = NULL;
14 static jmethodID slicedef_meth = NULL;
15 static jclass slicedef_cls = NULL;
16 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
17         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
18         CHECK(ordinal_meth != NULL);
19         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
20         CHECK(slicedef_meth != NULL);
21         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
22         CHECK(slicedef_cls != NULL);
23 }
24
25 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
26         return *((bool*)ptr);
27 }
28 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
29         return *((long*)ptr);
30 }
31 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
32         FREE((void*)ptr);
33 }
34 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
35         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
36         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
37         return ret_arr;
38 }
39 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
40         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
41         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
42         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
43         return ret_arr;
44 }
45 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
46         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
47         vec->datalen = (*env)->GetArrayLength(env, bytes);
48         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
49         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
50         return (long)vec;
51 }
52 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
53         LDKTransaction *txdata = (LDKTransaction*)ptr;
54         LDKu8slice slice;
55         slice.data = txdata->data;
56         slice.datalen = txdata->datalen;
57         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (long)&slice);
58 }
59 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
60         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
61         txdata->datalen = (*env)->GetArrayLength(env, bytes);
62         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
63         txdata->data_is_owned = false;
64         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
65         return (long)txdata;
66 }
67 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
68         LDKTransaction *tx = (LDKTransaction*)ptr;
69         tx->data_is_owned = true;
70         Transaction_free(*tx);
71         FREE((void*)ptr);
72 }
73 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
74         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
75         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
76         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
77         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
78         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
79         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
80         return (long)vec->datalen;
81 }
82 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
83         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
84         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
85         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
86         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
87         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
88         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
89         vec->data = NULL;
90         vec->datalen = 0;
91         return (long)vec;
92 }
93
94 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
95 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
96 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
97 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
98
99 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
100 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
101 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
102
103 typedef jlongArray int64_tArray;
104 typedef jbyteArray int8_tArray;
105
106 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
107         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
108         char* err_buf = MALLOC(len + 1, "str conv buf");
109         memcpy(err_buf, chars, len);
110         err_buf[len] = 0;
111         jstring err_conv = (*env)->NewStringUTF(env, chars);
112         FREE(err_buf);
113         return err_conv;
114 }
115 static jclass arr_of_J_clz = NULL;
116 static jclass arr_of_B_clz = NULL;
117 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
118         arr_of_J_clz = (*env)->FindClass(env, "[J");
119         CHECK(arr_of_J_clz != NULL);
120         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
121         arr_of_B_clz = (*env)->FindClass(env, "[B");
122         CHECK(arr_of_B_clz != NULL);
123         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
124 }
125 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
126 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
127         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
128                 case 0: return LDKAccessError_UnknownChain;
129                 case 1: return LDKAccessError_UnknownTx;
130         }
131         abort();
132 }
133 static jclass LDKAccessError_class = NULL;
134 static jfieldID LDKAccessError_LDKAccessError_UnknownChain = NULL;
135 static jfieldID LDKAccessError_LDKAccessError_UnknownTx = NULL;
136 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKAccessError_init (JNIEnv *env, jclass clz) {
137         LDKAccessError_class = (*env)->NewGlobalRef(env, clz);
138         CHECK(LDKAccessError_class != NULL);
139         LDKAccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, LDKAccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/LDKAccessError;");
140         CHECK(LDKAccessError_LDKAccessError_UnknownChain != NULL);
141         LDKAccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, LDKAccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/LDKAccessError;");
142         CHECK(LDKAccessError_LDKAccessError_UnknownTx != NULL);
143 }
144 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
145         switch (val) {
146                 case LDKAccessError_UnknownChain:
147                         return (*env)->GetStaticObjectField(env, LDKAccessError_class, LDKAccessError_LDKAccessError_UnknownChain);
148                 case LDKAccessError_UnknownTx:
149                         return (*env)->GetStaticObjectField(env, LDKAccessError_class, LDKAccessError_LDKAccessError_UnknownTx);
150                 default: abort();
151         }
152 }
153
154 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
155         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
156                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
157                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
158         }
159         abort();
160 }
161 static jclass LDKChannelMonitorUpdateErr_class = NULL;
162 static jfieldID LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
163 static jfieldID LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
164 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
165         LDKChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
166         CHECK(LDKChannelMonitorUpdateErr_class != NULL);
167         LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, LDKChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
168         CHECK(LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
169         LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, LDKChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
170         CHECK(LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
171 }
172 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
173         switch (val) {
174                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
175                         return (*env)->GetStaticObjectField(env, LDKChannelMonitorUpdateErr_class, LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
176                 case LDKChannelMonitorUpdateErr_PermanentFailure:
177                         return (*env)->GetStaticObjectField(env, LDKChannelMonitorUpdateErr_class, LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
178                 default: abort();
179         }
180 }
181
182 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
183         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
184                 case 0: return LDKConfirmationTarget_Background;
185                 case 1: return LDKConfirmationTarget_Normal;
186                 case 2: return LDKConfirmationTarget_HighPriority;
187         }
188         abort();
189 }
190 static jclass LDKConfirmationTarget_class = NULL;
191 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_Background = NULL;
192 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
193 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
194 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKConfirmationTarget_init (JNIEnv *env, jclass clz) {
195         LDKConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
196         CHECK(LDKConfirmationTarget_class != NULL);
197         LDKConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/LDKConfirmationTarget;");
198         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_Background != NULL);
199         LDKConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/LDKConfirmationTarget;");
200         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
201         LDKConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/LDKConfirmationTarget;");
202         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
203 }
204 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
205         switch (val) {
206                 case LDKConfirmationTarget_Background:
207                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_Background);
208                 case LDKConfirmationTarget_Normal:
209                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_Normal);
210                 case LDKConfirmationTarget_HighPriority:
211                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_HighPriority);
212                 default: abort();
213         }
214 }
215
216 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
217         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
218                 case 0: return LDKLevel_Off;
219                 case 1: return LDKLevel_Error;
220                 case 2: return LDKLevel_Warn;
221                 case 3: return LDKLevel_Info;
222                 case 4: return LDKLevel_Debug;
223                 case 5: return LDKLevel_Trace;
224         }
225         abort();
226 }
227 static jclass LDKLevel_class = NULL;
228 static jfieldID LDKLevel_LDKLevel_Off = NULL;
229 static jfieldID LDKLevel_LDKLevel_Error = NULL;
230 static jfieldID LDKLevel_LDKLevel_Warn = NULL;
231 static jfieldID LDKLevel_LDKLevel_Info = NULL;
232 static jfieldID LDKLevel_LDKLevel_Debug = NULL;
233 static jfieldID LDKLevel_LDKLevel_Trace = NULL;
234 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKLevel_init (JNIEnv *env, jclass clz) {
235         LDKLevel_class = (*env)->NewGlobalRef(env, clz);
236         CHECK(LDKLevel_class != NULL);
237         LDKLevel_LDKLevel_Off = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Off", "Lorg/ldk/enums/LDKLevel;");
238         CHECK(LDKLevel_LDKLevel_Off != NULL);
239         LDKLevel_LDKLevel_Error = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Error", "Lorg/ldk/enums/LDKLevel;");
240         CHECK(LDKLevel_LDKLevel_Error != NULL);
241         LDKLevel_LDKLevel_Warn = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Warn", "Lorg/ldk/enums/LDKLevel;");
242         CHECK(LDKLevel_LDKLevel_Warn != NULL);
243         LDKLevel_LDKLevel_Info = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Info", "Lorg/ldk/enums/LDKLevel;");
244         CHECK(LDKLevel_LDKLevel_Info != NULL);
245         LDKLevel_LDKLevel_Debug = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Debug", "Lorg/ldk/enums/LDKLevel;");
246         CHECK(LDKLevel_LDKLevel_Debug != NULL);
247         LDKLevel_LDKLevel_Trace = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Trace", "Lorg/ldk/enums/LDKLevel;");
248         CHECK(LDKLevel_LDKLevel_Trace != NULL);
249 }
250 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
251         switch (val) {
252                 case LDKLevel_Off:
253                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Off);
254                 case LDKLevel_Error:
255                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Error);
256                 case LDKLevel_Warn:
257                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Warn);
258                 case LDKLevel_Info:
259                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Info);
260                 case LDKLevel_Debug:
261                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Debug);
262                 case LDKLevel_Trace:
263                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Trace);
264                 default: abort();
265         }
266 }
267
268 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
269         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
270                 case 0: return LDKNetwork_Bitcoin;
271                 case 1: return LDKNetwork_Testnet;
272                 case 2: return LDKNetwork_Regtest;
273         }
274         abort();
275 }
276 static jclass LDKNetwork_class = NULL;
277 static jfieldID LDKNetwork_LDKNetwork_Bitcoin = NULL;
278 static jfieldID LDKNetwork_LDKNetwork_Testnet = NULL;
279 static jfieldID LDKNetwork_LDKNetwork_Regtest = NULL;
280 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKNetwork_init (JNIEnv *env, jclass clz) {
281         LDKNetwork_class = (*env)->NewGlobalRef(env, clz);
282         CHECK(LDKNetwork_class != NULL);
283         LDKNetwork_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/LDKNetwork;");
284         CHECK(LDKNetwork_LDKNetwork_Bitcoin != NULL);
285         LDKNetwork_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/LDKNetwork;");
286         CHECK(LDKNetwork_LDKNetwork_Testnet != NULL);
287         LDKNetwork_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/LDKNetwork;");
288         CHECK(LDKNetwork_LDKNetwork_Regtest != NULL);
289 }
290 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
291         switch (val) {
292                 case LDKNetwork_Bitcoin:
293                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Bitcoin);
294                 case LDKNetwork_Testnet:
295                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Testnet);
296                 case LDKNetwork_Regtest:
297                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Regtest);
298                 default: abort();
299         }
300 }
301
302 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
303         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
304                 case 0: return LDKSecp256k1Error_IncorrectSignature;
305                 case 1: return LDKSecp256k1Error_InvalidMessage;
306                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
307                 case 3: return LDKSecp256k1Error_InvalidSignature;
308                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
309                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
310                 case 6: return LDKSecp256k1Error_InvalidTweak;
311                 case 7: return LDKSecp256k1Error_NotEnoughMemory;
312                 case 8: return LDKSecp256k1Error_CallbackPanicked;
313         }
314         abort();
315 }
316 static jclass LDKSecp256k1Error_class = NULL;
317 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
318 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
319 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
320 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
321 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
322 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
323 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
324 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
325 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked = NULL;
326 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKSecp256k1Error_init (JNIEnv *env, jclass clz) {
327         LDKSecp256k1Error_class = (*env)->NewGlobalRef(env, clz);
328         CHECK(LDKSecp256k1Error_class != NULL);
329         LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
330         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
331         LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/LDKSecp256k1Error;");
332         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
333         LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
334         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
335         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
336         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
337         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
338         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
339         LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/LDKSecp256k1Error;");
340         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
341         LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/LDKSecp256k1Error;");
342         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
343         LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/LDKSecp256k1Error;");
344         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
345         LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_CallbackPanicked", "Lorg/ldk/enums/LDKSecp256k1Error;");
346         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked != NULL);
347 }
348 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
349         switch (val) {
350                 case LDKSecp256k1Error_IncorrectSignature:
351                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature);
352                 case LDKSecp256k1Error_InvalidMessage:
353                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage);
354                 case LDKSecp256k1Error_InvalidPublicKey:
355                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
356                 case LDKSecp256k1Error_InvalidSignature:
357                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature);
358                 case LDKSecp256k1Error_InvalidSecretKey:
359                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
360                 case LDKSecp256k1Error_InvalidRecoveryId:
361                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
362                 case LDKSecp256k1Error_InvalidTweak:
363                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak);
364                 case LDKSecp256k1Error_NotEnoughMemory:
365                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
366                 case LDKSecp256k1Error_CallbackPanicked:
367                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked);
368                 default: abort();
369         }
370 }
371
372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
373         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
374         ret->datalen = (*env)->GetArrayLength(env, elems);
375         if (ret->datalen == 0) {
376                 ret->data = NULL;
377         } else {
378                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
379                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
380                 for (size_t i = 0; i < ret->datalen; i++) {
381                         ret->data[i] = java_elems[i];
382                 }
383                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
384         }
385         return (long)ret;
386 }
387 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
388         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
389         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
390         return ret;
391 }
392 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
393         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
394 }
395 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
396         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
397         CHECK(val->result_ok);
398         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
399         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
400         return res_arr;
401 }
402 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
403         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
404         CHECK(!val->result_ok);
405         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
406         return err_conv;
407 }
408 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
409         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
410 }
411 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
412         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
413         CHECK(val->result_ok);
414         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
415         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
416         return res_arr;
417 }
418 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
419         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
420         CHECK(!val->result_ok);
421         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
422         return err_conv;
423 }
424 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
425         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
426 }
427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
428         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
429         CHECK(val->result_ok);
430         LDKTxCreationKeys res_var = (*val->contents.result);
431         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
432         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
433         long res_ref = (long)res_var.inner & ~1;
434         return res_ref;
435 }
436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
437         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
438         CHECK(!val->result_ok);
439         LDKDecodeError err_var = (*val->contents.err);
440         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
441         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
442         long err_ref = (long)err_var.inner & ~1;
443         return err_ref;
444 }
445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
446         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
447 }
448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
449         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
450         CHECK(val->result_ok);
451         LDKChannelPublicKeys res_var = (*val->contents.result);
452         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
453         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
454         long res_ref = (long)res_var.inner & ~1;
455         return res_ref;
456 }
457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
458         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
459         CHECK(!val->result_ok);
460         LDKDecodeError err_var = (*val->contents.err);
461         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
462         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
463         long err_ref = (long)err_var.inner & ~1;
464         return err_ref;
465 }
466 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
467         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
468 }
469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
470         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
471         CHECK(val->result_ok);
472         LDKTxCreationKeys res_var = (*val->contents.result);
473         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
474         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
475         long res_ref = (long)res_var.inner & ~1;
476         return res_ref;
477 }
478 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
479         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
480         CHECK(!val->result_ok);
481         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
482         return err_conv;
483 }
484 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
485         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
486 }
487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
488         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
489         CHECK(val->result_ok);
490         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
491         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
492         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
493         long res_ref = (long)res_var.inner & ~1;
494         return res_ref;
495 }
496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
497         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
498         CHECK(!val->result_ok);
499         LDKDecodeError err_var = (*val->contents.err);
500         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
501         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
502         long err_ref = (long)err_var.inner & ~1;
503         return err_ref;
504 }
505 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
506         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
507 }
508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
509         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
510         CHECK(val->result_ok);
511         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
512         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
513         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
514         long res_ref = (long)res_var.inner & ~1;
515         return res_ref;
516 }
517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
518         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
519         CHECK(!val->result_ok);
520         LDKDecodeError err_var = (*val->contents.err);
521         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
522         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
523         long err_ref = (long)err_var.inner & ~1;
524         return err_ref;
525 }
526 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
527         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
528 }
529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
530         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
531         CHECK(val->result_ok);
532         LDKChannelTransactionParameters res_var = (*val->contents.result);
533         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
534         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
535         long res_ref = (long)res_var.inner & ~1;
536         return res_ref;
537 }
538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
539         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
540         CHECK(!val->result_ok);
541         LDKDecodeError err_var = (*val->contents.err);
542         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
543         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
544         long err_ref = (long)err_var.inner & ~1;
545         return err_ref;
546 }
547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
548         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
549 }
550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
551         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
552         CHECK(val->result_ok);
553         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
554         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
555         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
556         long res_ref = (long)res_var.inner & ~1;
557         return res_ref;
558 }
559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
560         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
561         CHECK(!val->result_ok);
562         LDKDecodeError err_var = (*val->contents.err);
563         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
564         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
565         long err_ref = (long)err_var.inner & ~1;
566         return err_ref;
567 }
568 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
569         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
570 }
571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
572         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
573         CHECK(val->result_ok);
574         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
575         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
576         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
577         long res_ref = (long)res_var.inner & ~1;
578         return res_ref;
579 }
580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
581         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
582         CHECK(!val->result_ok);
583         LDKDecodeError err_var = (*val->contents.err);
584         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
585         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
586         long err_ref = (long)err_var.inner & ~1;
587         return err_ref;
588 }
589 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
590         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
591 }
592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
593         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
594         CHECK(val->result_ok);
595         LDKCommitmentTransaction res_var = (*val->contents.result);
596         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
597         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
598         long res_ref = (long)res_var.inner & ~1;
599         return res_ref;
600 }
601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
602         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
603         CHECK(!val->result_ok);
604         LDKDecodeError err_var = (*val->contents.err);
605         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
606         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
607         long err_ref = (long)err_var.inner & ~1;
608         return err_ref;
609 }
610 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
611         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
612 }
613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
614         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
615         CHECK(val->result_ok);
616         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
617         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
618         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
619         long res_ref = (long)res_var.inner & ~1;
620         return res_ref;
621 }
622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
623         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
624         CHECK(!val->result_ok);
625         return *val->contents.err;
626 }
627 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
628         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
629 }
630 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
631         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
632         CHECK(val->result_ok);
633         LDKCVec_SignatureZ res_var = (*val->contents.result);
634         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
635         ;
636         for (size_t i = 0; i < res_var.datalen; i++) {
637                 int8_tArray arr_conv_8_arr = (*env)->NewByteArray(env, 64);
638                 (*env)->SetByteArrayRegion(env, arr_conv_8_arr, 0, 64, res_var.data[i].compact_form);
639                 (*env)->SetObjectArrayElement(env, res_arr, i, arr_conv_8_arr);
640         }
641         return res_arr;
642 }
643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
644         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
645         CHECK(!val->result_ok);
646         return *val->contents.err;
647 }
648 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
649         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
650 }
651 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
652         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
653         CHECK(val->result_ok);
654         LDKCVec_u8Z res_var = (*val->contents.result);
655         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
656         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
657         return res_arr;
658 }
659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
660         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
661         CHECK(!val->result_ok);
662         LDKPeerHandleError err_var = (*val->contents.err);
663         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
664         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
665         long err_ref = (long)err_var.inner & ~1;
666         return err_ref;
667 }
668 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
669         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
670 }
671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
672         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
673         CHECK(val->result_ok);
674         return *val->contents.result;
675 }
676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
677         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
678         CHECK(!val->result_ok);
679         LDKPeerHandleError err_var = (*val->contents.err);
680         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
681         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
682         long err_ref = (long)err_var.inner & ~1;
683         return err_ref;
684 }
685 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
686         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
687 }
688 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
689         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
690         CHECK(val->result_ok);
691         return *val->contents.result;
692 }
693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
694         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
695         CHECK(!val->result_ok);
696         LDKPeerHandleError err_var = (*val->contents.err);
697         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
698         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
699         long err_ref = (long)err_var.inner & ~1;
700         return err_ref;
701 }
702 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
703         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
704 }
705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
706         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
707         CHECK(val->result_ok);
708         LDKInitFeatures res_var = (*val->contents.result);
709         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
710         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
711         long res_ref = (long)res_var.inner & ~1;
712         return res_ref;
713 }
714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
715         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
716         CHECK(!val->result_ok);
717         LDKDecodeError err_var = (*val->contents.err);
718         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
719         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
720         long err_ref = (long)err_var.inner & ~1;
721         return err_ref;
722 }
723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
724         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
725 }
726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
727         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
728         CHECK(val->result_ok);
729         LDKNodeFeatures res_var = (*val->contents.result);
730         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
731         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
732         long res_ref = (long)res_var.inner & ~1;
733         return res_ref;
734 }
735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
736         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
737         CHECK(!val->result_ok);
738         LDKDecodeError err_var = (*val->contents.err);
739         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
740         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
741         long err_ref = (long)err_var.inner & ~1;
742         return err_ref;
743 }
744 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
745         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
746 }
747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
748         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
749         CHECK(val->result_ok);
750         LDKChannelFeatures res_var = (*val->contents.result);
751         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
752         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
753         long res_ref = (long)res_var.inner & ~1;
754         return res_ref;
755 }
756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
757         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
758         CHECK(!val->result_ok);
759         LDKDecodeError err_var = (*val->contents.err);
760         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
761         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
762         long err_ref = (long)err_var.inner & ~1;
763         return err_ref;
764 }
765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
766         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
767 }
768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
769         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
770         CHECK(val->result_ok);
771         LDKChannelConfig res_var = (*val->contents.result);
772         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
773         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
774         long res_ref = (long)res_var.inner & ~1;
775         return res_ref;
776 }
777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
778         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
779         CHECK(!val->result_ok);
780         LDKDecodeError err_var = (*val->contents.err);
781         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
782         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
783         long err_ref = (long)err_var.inner & ~1;
784         return err_ref;
785 }
786 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
787         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
788 }
789 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
790         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
791         CHECK(val->result_ok);
792         return *val->contents.result;
793 }
794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
795         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
796         CHECK(!val->result_ok);
797         LDKLightningError err_var = (*val->contents.err);
798         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
799         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
800         long err_ref = (long)err_var.inner & ~1;
801         return err_ref;
802 }
803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b, int64_t c) {
804         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
805         LDKChannelAnnouncement a_conv;
806         a_conv.inner = (void*)(a & (~1));
807         a_conv.is_owned = (a & 1) || (a == 0);
808         a_conv = ChannelAnnouncement_clone(&a_conv);
809         ret->a = a_conv;
810         LDKChannelUpdate b_conv;
811         b_conv.inner = (void*)(b & (~1));
812         b_conv.is_owned = (b & 1) || (b == 0);
813         b_conv = ChannelUpdate_clone(&b_conv);
814         ret->b = b_conv;
815         LDKChannelUpdate c_conv;
816         c_conv.inner = (void*)(c & (~1));
817         c_conv.is_owned = (c & 1) || (c == 0);
818         c_conv = ChannelUpdate_clone(&c_conv);
819         ret->c = c_conv;
820         return (long)ret;
821 }
822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
823         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
824         LDKChannelAnnouncement a_var = tuple->a;
825         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
826         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
827         long a_ref = (long)a_var.inner & ~1;
828         return a_ref;
829 }
830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
831         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
832         LDKChannelUpdate b_var = tuple->b;
833         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
834         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
835         long b_ref = (long)b_var.inner & ~1;
836         return b_ref;
837 }
838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
839         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
840         LDKChannelUpdate c_var = tuple->c;
841         CHECK((((long)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
842         CHECK((((long)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
843         long c_ref = (long)c_var.inner & ~1;
844         return c_ref;
845 }
846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
847         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
848         ret->datalen = (*env)->GetArrayLength(env, elems);
849         if (ret->datalen == 0) {
850                 ret->data = NULL;
851         } else {
852                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
853                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
854                 for (size_t i = 0; i < ret->datalen; i++) {
855                         int64_t arr_elem = java_elems[i];
856                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
857                         FREE((void*)arr_elem);
858                         ret->data[i] = arr_elem_conv;
859                 }
860                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
861         }
862         return (long)ret;
863 }
864 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
865         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
866         for (size_t i = 0; i < ret.datalen; i++) {
867                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
868         }
869         return ret;
870 }
871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
872         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
873         ret->datalen = (*env)->GetArrayLength(env, elems);
874         if (ret->datalen == 0) {
875                 ret->data = NULL;
876         } else {
877                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
878                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
879                 for (size_t i = 0; i < ret->datalen; i++) {
880                         int64_t arr_elem = java_elems[i];
881                         LDKNodeAnnouncement arr_elem_conv;
882                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
883                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
884                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
885                         ret->data[i] = arr_elem_conv;
886                 }
887                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
888         }
889         return (long)ret;
890 }
891 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
892         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
893         for (size_t i = 0; i < ret.datalen; i++) {
894                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
895         }
896         return ret;
897 }
898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
899         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
900 }
901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
902         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
903         CHECK(val->result_ok);
904         return *val->contents.result;
905 }
906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
907         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
908         CHECK(!val->result_ok);
909         LDKLightningError err_var = (*val->contents.err);
910         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
911         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
912         long err_ref = (long)err_var.inner & ~1;
913         return err_ref;
914 }
915 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
916 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
917 static jclass LDKErrorAction_IgnoreError_class = NULL;
918 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
919 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
920 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
922         LDKErrorAction_DisconnectPeer_class =
923                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
924         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
925         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
926         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
927         LDKErrorAction_IgnoreError_class =
928                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
929         CHECK(LDKErrorAction_IgnoreError_class != NULL);
930         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
931         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
932         LDKErrorAction_SendErrorMessage_class =
933                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
934         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
935         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
936         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
937 }
938 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
939         LDKErrorAction *obj = (LDKErrorAction*)ptr;
940         switch(obj->tag) {
941                 case LDKErrorAction_DisconnectPeer: {
942                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
943                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
944                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
945                         long msg_ref = (long)msg_var.inner & ~1;
946                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
947                 }
948                 case LDKErrorAction_IgnoreError: {
949                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
950                 }
951                 case LDKErrorAction_SendErrorMessage: {
952                         LDKErrorMessage msg_var = obj->send_error_message.msg;
953                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
954                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
955                         long msg_ref = (long)msg_var.inner & ~1;
956                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
957                 }
958                 default: abort();
959         }
960 }
961 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
962 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
963 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
964 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
965 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
966 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
968         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
969                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
970         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
971         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
972         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
973         LDKHTLCFailChannelUpdate_ChannelClosed_class =
974                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
975         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
976         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
977         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
978         LDKHTLCFailChannelUpdate_NodeFailure_class =
979                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
980         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
981         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
982         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
983 }
984 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
985         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
986         switch(obj->tag) {
987                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
988                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
989                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
990                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
991                         long msg_ref = (long)msg_var.inner & ~1;
992                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
993                 }
994                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
995                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
996                 }
997                 case LDKHTLCFailChannelUpdate_NodeFailure: {
998                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
999                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1000                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1001                 }
1002                 default: abort();
1003         }
1004 }
1005 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1006 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1007 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1008 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1009 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1010 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1011 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1012 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1013 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1014 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1015 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1016 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1017 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1018 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1019 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1020 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1021 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1022 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1023 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1024 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1025 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1026 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1027 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1028 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1029 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1030 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1031 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1032 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1033 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1034 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1035 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1036 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1037 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1038 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1039 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1040 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1042         LDKMessageSendEvent_SendAcceptChannel_class =
1043                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1044         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1045         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1046         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1047         LDKMessageSendEvent_SendOpenChannel_class =
1048                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1049         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1050         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1051         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1052         LDKMessageSendEvent_SendFundingCreated_class =
1053                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1054         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1055         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1056         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1057         LDKMessageSendEvent_SendFundingSigned_class =
1058                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1059         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1060         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1061         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1062         LDKMessageSendEvent_SendFundingLocked_class =
1063                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1064         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1065         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1066         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1067         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1068                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1069         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1070         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1071         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1072         LDKMessageSendEvent_UpdateHTLCs_class =
1073                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1074         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1075         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1076         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1077         LDKMessageSendEvent_SendRevokeAndACK_class =
1078                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1079         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1080         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1081         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1082         LDKMessageSendEvent_SendClosingSigned_class =
1083                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1084         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1085         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1086         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1087         LDKMessageSendEvent_SendShutdown_class =
1088                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1089         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1090         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1091         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1092         LDKMessageSendEvent_SendChannelReestablish_class =
1093                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1094         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1095         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1096         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1097         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1098                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1099         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1100         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1101         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1102         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1103                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1104         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1105         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1106         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1107         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1108                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1109         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1110         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1111         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1112         LDKMessageSendEvent_HandleError_class =
1113                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1114         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1115         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1116         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1117         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1118                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1119         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1120         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1121         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1122         LDKMessageSendEvent_SendChannelRangeQuery_class =
1123                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1124         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1125         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1126         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1127         LDKMessageSendEvent_SendShortIdsQuery_class =
1128                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1129         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1130         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1131         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
1132 }
1133 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1134         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
1135         switch(obj->tag) {
1136                 case LDKMessageSendEvent_SendAcceptChannel: {
1137                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1138                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1139                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1140                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1141                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1142                         long msg_ref = (long)msg_var.inner & ~1;
1143                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1144                 }
1145                 case LDKMessageSendEvent_SendOpenChannel: {
1146                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1147                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1148                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1149                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1150                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1151                         long msg_ref = (long)msg_var.inner & ~1;
1152                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1153                 }
1154                 case LDKMessageSendEvent_SendFundingCreated: {
1155                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1156                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1157                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1158                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1159                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1160                         long msg_ref = (long)msg_var.inner & ~1;
1161                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1162                 }
1163                 case LDKMessageSendEvent_SendFundingSigned: {
1164                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1165                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1166                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1167                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1168                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1169                         long msg_ref = (long)msg_var.inner & ~1;
1170                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1171                 }
1172                 case LDKMessageSendEvent_SendFundingLocked: {
1173                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1174                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1175                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1176                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1177                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1178                         long msg_ref = (long)msg_var.inner & ~1;
1179                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1180                 }
1181                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1182                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1183                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1184                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1185                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1186                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1187                         long msg_ref = (long)msg_var.inner & ~1;
1188                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1189                 }
1190                 case LDKMessageSendEvent_UpdateHTLCs: {
1191                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1192                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1193                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1194                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1195                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1196                         long updates_ref = (long)updates_var.inner & ~1;
1197                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1198                 }
1199                 case LDKMessageSendEvent_SendRevokeAndACK: {
1200                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1201                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1202                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1203                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1204                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1205                         long msg_ref = (long)msg_var.inner & ~1;
1206                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1207                 }
1208                 case LDKMessageSendEvent_SendClosingSigned: {
1209                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1210                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1211                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1212                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1213                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1214                         long msg_ref = (long)msg_var.inner & ~1;
1215                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1216                 }
1217                 case LDKMessageSendEvent_SendShutdown: {
1218                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1219                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1220                         LDKShutdown msg_var = obj->send_shutdown.msg;
1221                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1222                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1223                         long msg_ref = (long)msg_var.inner & ~1;
1224                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1225                 }
1226                 case LDKMessageSendEvent_SendChannelReestablish: {
1227                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1228                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1229                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1230                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1231                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1232                         long msg_ref = (long)msg_var.inner & ~1;
1233                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1234                 }
1235                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1236                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1237                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1238                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1239                         long msg_ref = (long)msg_var.inner & ~1;
1240                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1241                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1242                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1243                         long update_msg_ref = (long)update_msg_var.inner & ~1;
1244                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1245                 }
1246                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1247                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1248                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1249                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1250                         long msg_ref = (long)msg_var.inner & ~1;
1251                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1252                 }
1253                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1254                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1255                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1256                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1257                         long msg_ref = (long)msg_var.inner & ~1;
1258                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1259                 }
1260                 case LDKMessageSendEvent_HandleError: {
1261                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1262                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1263                         long action_ref = ((long)&obj->handle_error.action) | 1;
1264                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1265                 }
1266                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1267                         long update_ref = ((long)&obj->payment_failure_network_update.update) | 1;
1268                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1269                 }
1270                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1271                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1272                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1273                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1274                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1275                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1276                         long msg_ref = (long)msg_var.inner & ~1;
1277                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1278                 }
1279                 case LDKMessageSendEvent_SendShortIdsQuery: {
1280                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1281                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1282                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1283                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1284                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1285                         long msg_ref = (long)msg_var.inner & ~1;
1286                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1287                 }
1288                 default: abort();
1289         }
1290 }
1291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1292         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1293         ret->datalen = (*env)->GetArrayLength(env, elems);
1294         if (ret->datalen == 0) {
1295                 ret->data = NULL;
1296         } else {
1297                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1298                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1299                 for (size_t i = 0; i < ret->datalen; i++) {
1300                         int64_t arr_elem = java_elems[i];
1301                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1302                         FREE((void*)arr_elem);
1303                         ret->data[i] = arr_elem_conv;
1304                 }
1305                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1306         }
1307         return (long)ret;
1308 }
1309 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1310         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1311         for (size_t i = 0; i < ret.datalen; i++) {
1312                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1313         }
1314         return ret;
1315 }
1316 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1317         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
1318 }
1319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1320         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
1321         CHECK(val->result_ok);
1322         LDKDirectionalChannelInfo res_var = (*val->contents.result);
1323         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1324         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1325         long res_ref = (long)res_var.inner & ~1;
1326         return res_ref;
1327 }
1328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1329         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
1330         CHECK(!val->result_ok);
1331         LDKDecodeError err_var = (*val->contents.err);
1332         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1333         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1334         long err_ref = (long)err_var.inner & ~1;
1335         return err_ref;
1336 }
1337 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1338         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
1339 }
1340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1341         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
1342         CHECK(val->result_ok);
1343         LDKChannelInfo res_var = (*val->contents.result);
1344         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1345         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1346         long res_ref = (long)res_var.inner & ~1;
1347         return res_ref;
1348 }
1349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1350         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
1351         CHECK(!val->result_ok);
1352         LDKDecodeError err_var = (*val->contents.err);
1353         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1354         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1355         long err_ref = (long)err_var.inner & ~1;
1356         return err_ref;
1357 }
1358 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1359         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
1360 }
1361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1362         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
1363         CHECK(val->result_ok);
1364         LDKRoutingFees res_var = (*val->contents.result);
1365         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1366         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1367         long res_ref = (long)res_var.inner & ~1;
1368         return res_ref;
1369 }
1370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1371         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
1372         CHECK(!val->result_ok);
1373         LDKDecodeError err_var = (*val->contents.err);
1374         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1375         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1376         long err_ref = (long)err_var.inner & ~1;
1377         return err_ref;
1378 }
1379 static jclass LDKNetAddress_IPv4_class = NULL;
1380 static jmethodID LDKNetAddress_IPv4_meth = NULL;
1381 static jclass LDKNetAddress_IPv6_class = NULL;
1382 static jmethodID LDKNetAddress_IPv6_meth = NULL;
1383 static jclass LDKNetAddress_OnionV2_class = NULL;
1384 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
1385 static jclass LDKNetAddress_OnionV3_class = NULL;
1386 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
1387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
1388         LDKNetAddress_IPv4_class =
1389                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
1390         CHECK(LDKNetAddress_IPv4_class != NULL);
1391         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
1392         CHECK(LDKNetAddress_IPv4_meth != NULL);
1393         LDKNetAddress_IPv6_class =
1394                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
1395         CHECK(LDKNetAddress_IPv6_class != NULL);
1396         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
1397         CHECK(LDKNetAddress_IPv6_meth != NULL);
1398         LDKNetAddress_OnionV2_class =
1399                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
1400         CHECK(LDKNetAddress_OnionV2_class != NULL);
1401         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
1402         CHECK(LDKNetAddress_OnionV2_meth != NULL);
1403         LDKNetAddress_OnionV3_class =
1404                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
1405         CHECK(LDKNetAddress_OnionV3_class != NULL);
1406         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
1407         CHECK(LDKNetAddress_OnionV3_meth != NULL);
1408 }
1409 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1410         LDKNetAddress *obj = (LDKNetAddress*)ptr;
1411         switch(obj->tag) {
1412                 case LDKNetAddress_IPv4: {
1413                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
1414                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
1415                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
1416                 }
1417                 case LDKNetAddress_IPv6: {
1418                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
1419                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
1420                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
1421                 }
1422                 case LDKNetAddress_OnionV2: {
1423                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
1424                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
1425                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
1426                 }
1427                 case LDKNetAddress_OnionV3: {
1428                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
1429                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
1430                         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);
1431                 }
1432                 default: abort();
1433         }
1434 }
1435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1436         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
1437         ret->datalen = (*env)->GetArrayLength(env, elems);
1438         if (ret->datalen == 0) {
1439                 ret->data = NULL;
1440         } else {
1441                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
1442                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1443                 for (size_t i = 0; i < ret->datalen; i++) {
1444                         int64_t arr_elem = java_elems[i];
1445                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
1446                         FREE((void*)arr_elem);
1447                         ret->data[i] = arr_elem_conv;
1448                 }
1449                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1450         }
1451         return (long)ret;
1452 }
1453 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
1454         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
1455         for (size_t i = 0; i < ret.datalen; i++) {
1456                 ret.data[i] = NetAddress_clone(&orig->data[i]);
1457         }
1458         return ret;
1459 }
1460 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1461         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
1462 }
1463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1464         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
1465         CHECK(val->result_ok);
1466         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
1467         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1468         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1469         long res_ref = (long)res_var.inner & ~1;
1470         return res_ref;
1471 }
1472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1473         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
1474         CHECK(!val->result_ok);
1475         LDKDecodeError err_var = (*val->contents.err);
1476         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1477         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1478         long err_ref = (long)err_var.inner & ~1;
1479         return err_ref;
1480 }
1481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1482         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
1483         ret->datalen = (*env)->GetArrayLength(env, elems);
1484         if (ret->datalen == 0) {
1485                 ret->data = NULL;
1486         } else {
1487                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
1488                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1489                 for (size_t i = 0; i < ret->datalen; i++) {
1490                         ret->data[i] = java_elems[i];
1491                 }
1492                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1493         }
1494         return (long)ret;
1495 }
1496 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1497         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1498         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1499         return ret;
1500 }
1501 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1502         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
1503 }
1504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1505         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
1506         CHECK(val->result_ok);
1507         LDKNodeInfo res_var = (*val->contents.result);
1508         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1509         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1510         long res_ref = (long)res_var.inner & ~1;
1511         return res_ref;
1512 }
1513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1514         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
1515         CHECK(!val->result_ok);
1516         LDKDecodeError err_var = (*val->contents.err);
1517         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1518         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1519         long err_ref = (long)err_var.inner & ~1;
1520         return err_ref;
1521 }
1522 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1523         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
1524 }
1525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1526         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
1527         CHECK(val->result_ok);
1528         LDKNetworkGraph res_var = (*val->contents.result);
1529         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1530         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1531         long res_ref = (long)res_var.inner & ~1;
1532         return res_ref;
1533 }
1534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1535         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
1536         CHECK(!val->result_ok);
1537         LDKDecodeError err_var = (*val->contents.err);
1538         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1539         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1540         long err_ref = (long)err_var.inner & ~1;
1541         return err_ref;
1542 }
1543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1544         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1545         ret->a = a;
1546         LDKTransaction b_ref;
1547         b_ref.datalen = (*env)->GetArrayLength(env, b);
1548         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1549         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1550         b_ref.data_is_owned = false;
1551         ret->b = b_ref;
1552         return (long)ret;
1553 }
1554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1555         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1556         return tuple->a;
1557 }
1558 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1559         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1560         LDKTransaction b_var = tuple->b;
1561         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1562         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1563         return b_arr;
1564 }
1565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1566         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1567         ret->datalen = (*env)->GetArrayLength(env, elems);
1568         if (ret->datalen == 0) {
1569                 ret->data = NULL;
1570         } else {
1571                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1572                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1573                 for (size_t i = 0; i < ret->datalen; i++) {
1574                         int64_t arr_elem = java_elems[i];
1575                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1576                         FREE((void*)arr_elem);
1577                         ret->data[i] = arr_elem_conv;
1578                 }
1579                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1580         }
1581         return (long)ret;
1582 }
1583 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1584         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1585 }
1586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1587         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1588         CHECK(val->result_ok);
1589         return *val->contents.result;
1590 }
1591 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1592         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1593         CHECK(!val->result_ok);
1594         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1595         return err_conv;
1596 }
1597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1598         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1599         ret->datalen = (*env)->GetArrayLength(env, elems);
1600         if (ret->datalen == 0) {
1601                 ret->data = NULL;
1602         } else {
1603                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1604                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1605                 for (size_t i = 0; i < ret->datalen; i++) {
1606                         int64_t arr_elem = java_elems[i];
1607                         LDKMonitorEvent arr_elem_conv;
1608                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1609                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1610                         arr_elem_conv = MonitorEvent_clone(&arr_elem_conv);
1611                         ret->data[i] = arr_elem_conv;
1612                 }
1613                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1614         }
1615         return (long)ret;
1616 }
1617 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1618         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1619         for (size_t i = 0; i < ret.datalen; i++) {
1620                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1621         }
1622         return ret;
1623 }
1624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
1625         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
1626         ret->a = a;
1627         ret->b = b;
1628         return (long)ret;
1629 }
1630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u64u64Z_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1631         LDKC2Tuple_u64u64Z *tuple = (LDKC2Tuple_u64u64Z*)(ptr & ~1);
1632         return tuple->a;
1633 }
1634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u64u64Z_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1635         LDKC2Tuple_u64u64Z *tuple = (LDKC2Tuple_u64u64Z*)(ptr & ~1);
1636         return tuple->b;
1637 }
1638 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1639 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1640 static jclass LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class = NULL;
1641 static jmethodID LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = NULL;
1642 static jclass LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class = NULL;
1643 static jmethodID LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = NULL;
1644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1645         LDKSpendableOutputDescriptor_StaticOutput_class =
1646                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1647         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1648         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1649         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1650         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class =
1651                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DynamicOutputP2WSH;"));
1652         CHECK(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class != NULL);
1653         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class, "<init>", "(J[BSJJ[B)V");
1654         CHECK(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth != NULL);
1655         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class =
1656                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutputCounterpartyPayment;"));
1657         CHECK(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class != NULL);
1658         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, "<init>", "(JJJ)V");
1659         CHECK(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth != NULL);
1660 }
1661 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1662         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
1663         switch(obj->tag) {
1664                 case LDKSpendableOutputDescriptor_StaticOutput: {
1665                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1666                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1667                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1668                         long outpoint_ref = (long)outpoint_var.inner & ~1;
1669                         long output_ref = ((long)&obj->static_output.output) | 1;
1670                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (long)output_ref);
1671                 }
1672                 case LDKSpendableOutputDescriptor_DynamicOutputP2WSH: {
1673                         LDKOutPoint outpoint_var = obj->dynamic_output_p2wsh.outpoint;
1674                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1675                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1676                         long outpoint_ref = (long)outpoint_var.inner & ~1;
1677                         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
1678                         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, obj->dynamic_output_p2wsh.per_commitment_point.compressed_form);
1679                         long output_ref = ((long)&obj->dynamic_output_p2wsh.output) | 1;
1680                         long key_derivation_params_ref = (long)(&obj->dynamic_output_p2wsh.key_derivation_params) | 1;
1681                         int8_tArray revocation_pubkey_arr = (*env)->NewByteArray(env, 33);
1682                         (*env)->SetByteArrayRegion(env, revocation_pubkey_arr, 0, 33, obj->dynamic_output_p2wsh.revocation_pubkey.compressed_form);
1683                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth, outpoint_ref, per_commitment_point_arr, obj->dynamic_output_p2wsh.to_self_delay, (long)output_ref, key_derivation_params_ref, revocation_pubkey_arr);
1684                 }
1685                 case LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment: {
1686                         LDKOutPoint outpoint_var = obj->static_output_counterparty_payment.outpoint;
1687                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1688                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1689                         long outpoint_ref = (long)outpoint_var.inner & ~1;
1690                         long output_ref = ((long)&obj->static_output_counterparty_payment.output) | 1;
1691                         long key_derivation_params_ref = (long)(&obj->static_output_counterparty_payment.key_derivation_params) | 1;
1692                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth, outpoint_ref, (long)output_ref, key_derivation_params_ref);
1693                 }
1694                 default: abort();
1695         }
1696 }
1697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1698         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1699         ret->datalen = (*env)->GetArrayLength(env, elems);
1700         if (ret->datalen == 0) {
1701                 ret->data = NULL;
1702         } else {
1703                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1704                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1705                 for (size_t i = 0; i < ret->datalen; i++) {
1706                         int64_t arr_elem = java_elems[i];
1707                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1708                         FREE((void*)arr_elem);
1709                         ret->data[i] = arr_elem_conv;
1710                 }
1711                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1712         }
1713         return (long)ret;
1714 }
1715 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1716         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1717         for (size_t i = 0; i < ret.datalen; i++) {
1718                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1719         }
1720         return ret;
1721 }
1722 static jclass LDKEvent_FundingGenerationReady_class = NULL;
1723 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
1724 static jclass LDKEvent_FundingBroadcastSafe_class = NULL;
1725 static jmethodID LDKEvent_FundingBroadcastSafe_meth = NULL;
1726 static jclass LDKEvent_PaymentReceived_class = NULL;
1727 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
1728 static jclass LDKEvent_PaymentSent_class = NULL;
1729 static jmethodID LDKEvent_PaymentSent_meth = NULL;
1730 static jclass LDKEvent_PaymentFailed_class = NULL;
1731 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
1732 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
1733 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
1734 static jclass LDKEvent_SpendableOutputs_class = NULL;
1735 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
1736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
1737         LDKEvent_FundingGenerationReady_class =
1738                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
1739         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
1740         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
1741         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
1742         LDKEvent_FundingBroadcastSafe_class =
1743                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingBroadcastSafe;"));
1744         CHECK(LDKEvent_FundingBroadcastSafe_class != NULL);
1745         LDKEvent_FundingBroadcastSafe_meth = (*env)->GetMethodID(env, LDKEvent_FundingBroadcastSafe_class, "<init>", "(JJ)V");
1746         CHECK(LDKEvent_FundingBroadcastSafe_meth != NULL);
1747         LDKEvent_PaymentReceived_class =
1748                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
1749         CHECK(LDKEvent_PaymentReceived_class != NULL);
1750         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[BJ)V");
1751         CHECK(LDKEvent_PaymentReceived_meth != NULL);
1752         LDKEvent_PaymentSent_class =
1753                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
1754         CHECK(LDKEvent_PaymentSent_class != NULL);
1755         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
1756         CHECK(LDKEvent_PaymentSent_meth != NULL);
1757         LDKEvent_PaymentFailed_class =
1758                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
1759         CHECK(LDKEvent_PaymentFailed_class != NULL);
1760         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
1761         CHECK(LDKEvent_PaymentFailed_meth != NULL);
1762         LDKEvent_PendingHTLCsForwardable_class =
1763                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
1764         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
1765         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
1766         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
1767         LDKEvent_SpendableOutputs_class =
1768                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
1769         CHECK(LDKEvent_SpendableOutputs_class != NULL);
1770         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
1771         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
1772 }
1773 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1774         LDKEvent *obj = (LDKEvent*)ptr;
1775         switch(obj->tag) {
1776                 case LDKEvent_FundingGenerationReady: {
1777                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
1778                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
1779                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1780                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
1781                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
1782                         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);
1783                 }
1784                 case LDKEvent_FundingBroadcastSafe: {
1785                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
1786                         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1787                         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1788                         long funding_txo_ref = (long)funding_txo_var.inner & ~1;
1789                         return (*env)->NewObject(env, LDKEvent_FundingBroadcastSafe_class, LDKEvent_FundingBroadcastSafe_meth, funding_txo_ref, obj->funding_broadcast_safe.user_channel_id);
1790                 }
1791                 case LDKEvent_PaymentReceived: {
1792                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1793                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
1794                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1795                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
1796                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_secret_arr, obj->payment_received.amt);
1797                 }
1798                 case LDKEvent_PaymentSent: {
1799                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1800                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
1801                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
1802                 }
1803                 case LDKEvent_PaymentFailed: {
1804                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1805                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
1806                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
1807                 }
1808                 case LDKEvent_PendingHTLCsForwardable: {
1809                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
1810                 }
1811                 case LDKEvent_SpendableOutputs: {
1812                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1813                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
1814                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
1815                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1816                                 long arr_conv_27_ref = ((long)&outputs_var.data[b]) | 1;
1817                                 outputs_arr_ptr[b] = arr_conv_27_ref;
1818                         }
1819                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
1820                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
1821                 }
1822                 default: abort();
1823         }
1824 }
1825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1826         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
1827         ret->datalen = (*env)->GetArrayLength(env, elems);
1828         if (ret->datalen == 0) {
1829                 ret->data = NULL;
1830         } else {
1831                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
1832                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1833                 for (size_t i = 0; i < ret->datalen; i++) {
1834                         int64_t arr_elem = java_elems[i];
1835                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
1836                         FREE((void*)arr_elem);
1837                         ret->data[i] = arr_elem_conv;
1838                 }
1839                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1840         }
1841         return (long)ret;
1842 }
1843 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
1844         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
1845         for (size_t i = 0; i < ret.datalen; i++) {
1846                 ret.data[i] = Event_clone(&orig->data[i]);
1847         }
1848         return ret;
1849 }
1850 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1851         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
1852 }
1853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1854         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
1855         CHECK(val->result_ok);
1856         LDKOutPoint res_var = (*val->contents.result);
1857         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1858         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1859         long res_ref = (long)res_var.inner & ~1;
1860         return res_ref;
1861 }
1862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1863         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
1864         CHECK(!val->result_ok);
1865         LDKDecodeError err_var = (*val->contents.err);
1866         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1867         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1868         long err_ref = (long)err_var.inner & ~1;
1869         return err_ref;
1870 }
1871 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1872         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
1873 }
1874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1875         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
1876         CHECK(val->result_ok);
1877         LDKChannelMonitorUpdate res_var = (*val->contents.result);
1878         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1879         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1880         long res_ref = (long)res_var.inner & ~1;
1881         return res_ref;
1882 }
1883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1884         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
1885         CHECK(!val->result_ok);
1886         LDKDecodeError err_var = (*val->contents.err);
1887         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1888         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1889         long err_ref = (long)err_var.inner & ~1;
1890         return err_ref;
1891 }
1892 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1893         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
1894 }
1895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1896         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
1897         CHECK(val->result_ok);
1898         LDKHTLCUpdate res_var = (*val->contents.result);
1899         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1900         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1901         long res_ref = (long)res_var.inner & ~1;
1902         return res_ref;
1903 }
1904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1905         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
1906         CHECK(!val->result_ok);
1907         LDKDecodeError err_var = (*val->contents.err);
1908         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1909         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1910         long err_ref = (long)err_var.inner & ~1;
1911         return err_ref;
1912 }
1913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1914         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
1915 }
1916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1917         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
1918         CHECK(val->result_ok);
1919         return *val->contents.result;
1920 }
1921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1922         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
1923         CHECK(!val->result_ok);
1924         LDKMonitorUpdateError err_var = (*val->contents.err);
1925         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1926         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1927         long err_ref = (long)err_var.inner & ~1;
1928         return err_ref;
1929 }
1930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1931         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
1932         LDKOutPoint a_conv;
1933         a_conv.inner = (void*)(a & (~1));
1934         a_conv.is_owned = (a & 1) || (a == 0);
1935         a_conv = OutPoint_clone(&a_conv);
1936         ret->a = a_conv;
1937         LDKCVec_u8Z b_ref;
1938         b_ref.datalen = (*env)->GetArrayLength(env, b);
1939         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
1940         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1941         ret->b = b_ref;
1942         return (long)ret;
1943 }
1944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1945         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
1946         LDKOutPoint a_var = tuple->a;
1947         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1948         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1949         long a_ref = (long)a_var.inner & ~1;
1950         return a_ref;
1951 }
1952 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1953         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
1954         LDKCVec_u8Z b_var = tuple->b;
1955         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1956         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1957         return b_arr;
1958 }
1959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
1960         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
1961         ret->a = a;
1962         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
1963         FREE((void*)b);
1964         ret->b = b_conv;
1965         return (long)ret;
1966 }
1967 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1968         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
1969         return tuple->a;
1970 }
1971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1972         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
1973         long b_ref = ((long)&tuple->b) | 1;
1974         return (long)b_ref;
1975 }
1976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1977         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
1978         ret->datalen = (*env)->GetArrayLength(env, elems);
1979         if (ret->datalen == 0) {
1980                 ret->data = NULL;
1981         } else {
1982                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
1983                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1984                 for (size_t i = 0; i < ret->datalen; i++) {
1985                         int64_t arr_elem = java_elems[i];
1986                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
1987                         FREE((void*)arr_elem);
1988                         ret->data[i] = arr_elem_conv;
1989                 }
1990                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1991         }
1992         return (long)ret;
1993 }
1994 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
1995         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
1996         for (size_t i = 0; i < ret.datalen; i++) {
1997                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
1998         }
1999         return ret;
2000 }
2001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
2002         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
2003         LDKThirtyTwoBytes a_ref;
2004         CHECK((*env)->GetArrayLength(env, a) == 32);
2005         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2006         ret->a = a_ref;
2007         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
2008         b_constr.datalen = (*env)->GetArrayLength(env, b);
2009         if (b_constr.datalen > 0)
2010                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
2011         else
2012                 b_constr.data = NULL;
2013         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
2014         for (size_t a = 0; a < b_constr.datalen; a++) {
2015                 int64_t arr_conv_26 = b_vals[a];
2016                 LDKC2Tuple_u32TxOutZ arr_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_conv_26) & ~1);
2017                 FREE((void*)arr_conv_26);
2018                 b_constr.data[a] = arr_conv_26_conv;
2019         }
2020         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
2021         ret->b = b_constr;
2022         return (long)ret;
2023 }
2024 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2025         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
2026         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2027         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2028         return a_arr;
2029 }
2030 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2031         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
2032         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
2033         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
2034         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
2035         for (size_t a = 0; a < b_var.datalen; a++) {
2036                 long arr_conv_26_ref = (long)(&b_var.data[a]) | 1;
2037                 b_arr_ptr[a] = arr_conv_26_ref;
2038         }
2039         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
2040         return b_arr;
2041 }
2042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2043         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
2044         ret->datalen = (*env)->GetArrayLength(env, elems);
2045         if (ret->datalen == 0) {
2046                 ret->data = NULL;
2047         } else {
2048                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
2049                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2050                 for (size_t i = 0; i < ret->datalen; i++) {
2051                         int64_t arr_elem = java_elems[i];
2052                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
2053                         FREE((void*)arr_elem);
2054                         ret->data[i] = arr_elem_conv;
2055                 }
2056                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2057         }
2058         return (long)ret;
2059 }
2060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2061         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2062         LDKSignature a_ref;
2063         CHECK((*env)->GetArrayLength(env, a) == 64);
2064         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2065         ret->a = a_ref;
2066         LDKCVec_SignatureZ b_constr;
2067         b_constr.datalen = (*env)->GetArrayLength(env, b);
2068         if (b_constr.datalen > 0)
2069                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2070         else
2071                 b_constr.data = NULL;
2072         for (size_t i = 0; i < b_constr.datalen; i++) {
2073                 int8_tArray arr_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2074                 LDKSignature arr_conv_8_ref;
2075                 CHECK((*env)->GetArrayLength(env, arr_conv_8) == 64);
2076                 (*env)->GetByteArrayRegion(env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
2077                 b_constr.data[i] = arr_conv_8_ref;
2078         }
2079         ret->b = b_constr;
2080         return (long)ret;
2081 }
2082 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2083         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2084         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
2085         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
2086         return a_arr;
2087 }
2088 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2089         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2090         LDKCVec_SignatureZ b_var = tuple->b;
2091         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
2092         ;
2093         for (size_t i = 0; i < b_var.datalen; i++) {
2094                 int8_tArray arr_conv_8_arr = (*env)->NewByteArray(env, 64);
2095                 (*env)->SetByteArrayRegion(env, arr_conv_8_arr, 0, 64, b_var.data[i].compact_form);
2096                 (*env)->SetObjectArrayElement(env, b_arr, i, arr_conv_8_arr);
2097         }
2098         return b_arr;
2099 }
2100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2101         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2102 }
2103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2104         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2105         CHECK(val->result_ok);
2106         long res_ref = (long)(&(*val->contents.result)) | 1;
2107         return res_ref;
2108 }
2109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2110         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2111         CHECK(!val->result_ok);
2112         return *val->contents.err;
2113 }
2114 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2115         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2116 }
2117 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2118         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2119         CHECK(val->result_ok);
2120         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2121         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2122         return res_arr;
2123 }
2124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2125         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2126         CHECK(!val->result_ok);
2127         return *val->contents.err;
2128 }
2129 typedef struct LDKChannelKeys_JCalls {
2130         atomic_size_t refcnt;
2131         JavaVM *vm;
2132         jweak o;
2133         jmethodID get_per_commitment_point_meth;
2134         jmethodID release_commitment_secret_meth;
2135         jmethodID key_derivation_params_meth;
2136         jmethodID sign_counterparty_commitment_meth;
2137         jmethodID sign_holder_commitment_and_htlcs_meth;
2138         jmethodID sign_justice_transaction_meth;
2139         jmethodID sign_counterparty_htlc_transaction_meth;
2140         jmethodID sign_closing_transaction_meth;
2141         jmethodID sign_channel_announcement_meth;
2142         jmethodID ready_channel_meth;
2143         jmethodID write_meth;
2144 } LDKChannelKeys_JCalls;
2145 static void LDKChannelKeys_JCalls_free(void* this_arg) {
2146         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
2147         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2148                 JNIEnv *env;
2149                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2150                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2151                 FREE(j_calls);
2152         }
2153 }
2154 LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
2155         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
2156         JNIEnv *env;
2157         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2158         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2159         CHECK(obj != NULL);
2160         int8_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2161         LDKPublicKey arg_ref;
2162         CHECK((*env)->GetArrayLength(env, arg) == 33);
2163         (*env)->GetByteArrayRegion(env, arg, 0, 33, arg_ref.compressed_form);
2164         return arg_ref;
2165 }
2166 LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
2167         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
2168         JNIEnv *env;
2169         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2170         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2171         CHECK(obj != NULL);
2172         int8_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2173         LDKThirtyTwoBytes arg_ref;
2174         CHECK((*env)->GetArrayLength(env, arg) == 32);
2175         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.data);
2176         return arg_ref;
2177 }
2178 LDKC2Tuple_u64u64Z key_derivation_params_jcall(const void* this_arg) {
2179         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
2180         JNIEnv *env;
2181         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2182         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2183         CHECK(obj != NULL);
2184         LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)(*env)->CallLongMethod(env, obj, j_calls->key_derivation_params_meth);
2185         LDKC2Tuple_u64u64Z ret_conv = *(LDKC2Tuple_u64u64Z*)(((uint64_t)ret) & ~1);
2186         ret_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)ret);
2187         return ret_conv;
2188 }
2189 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2190         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
2191         JNIEnv *env;
2192         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2193         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2194         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2195         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2196         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2197         long commitment_tx_ref = (long)commitment_tx_var.inner;
2198         if (commitment_tx_var.is_owned) {
2199                 commitment_tx_ref |= 1;
2200         }
2201         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2202         CHECK(obj != NULL);
2203         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2204         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2205         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
2206         return ret_conv;
2207 }
2208 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2209         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
2210         JNIEnv *env;
2211         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2212         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2213         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2214         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2215         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2216         long commitment_tx_ref = (long)commitment_tx_var.inner;
2217         if (commitment_tx_var.is_owned) {
2218                 commitment_tx_ref |= 1;
2219         }
2220         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2221         CHECK(obj != NULL);
2222         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2223         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2224         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
2225         return ret_conv;
2226 }
2227 LDKCResult_SignatureNoneZ sign_justice_transaction_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
2228         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
2229         JNIEnv *env;
2230         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2231         LDKTransaction justice_tx_var = justice_tx;
2232         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2233         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2234         Transaction_free(justice_tx_var);
2235         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2236         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2237         LDKHTLCOutputInCommitment htlc_var = *htlc;
2238         htlc_var = HTLCOutputInCommitment_clone(htlc);
2239         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2240         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2241         long htlc_ref = (long)htlc_var.inner;
2242         if (htlc_var.is_owned) {
2243                 htlc_ref |= 1;
2244         }
2245         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2246         CHECK(obj != NULL);
2247         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_transaction_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
2248         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2249         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
2250         return ret_conv;
2251 }
2252 LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
2253         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
2254         JNIEnv *env;
2255         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2256         LDKTransaction htlc_tx_var = htlc_tx;
2257         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2258         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2259         Transaction_free(htlc_tx_var);
2260         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2261         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2262         LDKHTLCOutputInCommitment htlc_var = *htlc;
2263         htlc_var = HTLCOutputInCommitment_clone(htlc);
2264         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2265         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2266         long htlc_ref = (long)htlc_var.inner;
2267         if (htlc_var.is_owned) {
2268                 htlc_ref |= 1;
2269         }
2270         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2271         CHECK(obj != NULL);
2272         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
2273         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2274         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
2275         return ret_conv;
2276 }
2277 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
2278         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
2279         JNIEnv *env;
2280         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2281         LDKTransaction closing_tx_var = closing_tx;
2282         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
2283         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
2284         Transaction_free(closing_tx_var);
2285         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2286         CHECK(obj != NULL);
2287         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
2288         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2289         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
2290         return ret_conv;
2291 }
2292 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2293         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
2294         JNIEnv *env;
2295         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2296         LDKUnsignedChannelAnnouncement msg_var = *msg;
2297         msg_var = UnsignedChannelAnnouncement_clone(msg);
2298         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2299         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2300         long msg_ref = (long)msg_var.inner;
2301         if (msg_var.is_owned) {
2302                 msg_ref |= 1;
2303         }
2304         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2305         CHECK(obj != NULL);
2306         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2307         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2308         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
2309         return ret_conv;
2310 }
2311 void ready_channel_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2312         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
2313         JNIEnv *env;
2314         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2315         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2316         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2317         CHECK((((long)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2318         CHECK((((long)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2319         long channel_parameters_ref = (long)channel_parameters_var.inner;
2320         if (channel_parameters_var.is_owned) {
2321                 channel_parameters_ref |= 1;
2322         }
2323         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2324         CHECK(obj != NULL);
2325         return (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2326 }
2327 LDKCVec_u8Z write_jcall(const void* this_arg) {
2328         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
2329         JNIEnv *env;
2330         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2331         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2332         CHECK(obj != NULL);
2333         int8_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2334         LDKCVec_u8Z arg_ref;
2335         arg_ref.datalen = (*env)->GetArrayLength(env, arg);
2336         arg_ref.data = MALLOC(arg_ref.datalen, "LDKCVec_u8Z Bytes");
2337         (*env)->GetByteArrayRegion(env, arg, 0, arg_ref.datalen, arg_ref.data);
2338         return arg_ref;
2339 }
2340 static void* LDKChannelKeys_JCalls_clone(const void* this_arg) {
2341         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
2342         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2343         return (void*) this_arg;
2344 }
2345 static inline LDKChannelKeys LDKChannelKeys_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2346         jclass c = (*env)->GetObjectClass(env, o);
2347         CHECK(c != NULL);
2348         LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_JCalls");
2349         atomic_init(&calls->refcnt, 1);
2350         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2351         calls->o = (*env)->NewWeakGlobalRef(env, o);
2352         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2353         CHECK(calls->get_per_commitment_point_meth != NULL);
2354         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2355         CHECK(calls->release_commitment_secret_meth != NULL);
2356         calls->key_derivation_params_meth = (*env)->GetMethodID(env, c, "key_derivation_params", "()J");
2357         CHECK(calls->key_derivation_params_meth != NULL);
2358         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2359         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2360         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2361         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2362         calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "([BJJ[BJ)J");
2363         CHECK(calls->sign_justice_transaction_meth != NULL);
2364         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2365         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2366         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
2367         CHECK(calls->sign_closing_transaction_meth != NULL);
2368         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2369         CHECK(calls->sign_channel_announcement_meth != NULL);
2370         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2371         CHECK(calls->ready_channel_meth != NULL);
2372         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2373         CHECK(calls->write_meth != NULL);
2374
2375         LDKChannelPublicKeys pubkeys_conv;
2376         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2377         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2378         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2379
2380         LDKChannelKeys ret = {
2381                 .this_arg = (void*) calls,
2382                 .get_per_commitment_point = get_per_commitment_point_jcall,
2383                 .release_commitment_secret = release_commitment_secret_jcall,
2384                 .key_derivation_params = key_derivation_params_jcall,
2385                 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
2386                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_jcall,
2387                 .sign_justice_transaction = sign_justice_transaction_jcall,
2388                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
2389                 .sign_closing_transaction = sign_closing_transaction_jcall,
2390                 .sign_channel_announcement = sign_channel_announcement_jcall,
2391                 .ready_channel = ready_channel_jcall,
2392                 .clone = LDKChannelKeys_JCalls_clone,
2393                 .write = write_jcall,
2394                 .free = LDKChannelKeys_JCalls_free,
2395                 .pubkeys = pubkeys_conv,
2396                 .set_pubkeys = NULL,
2397         };
2398         return ret;
2399 }
2400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2401         LDKChannelKeys *res_ptr = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
2402         *res_ptr = LDKChannelKeys_init(env, clz, o, pubkeys);
2403         return (long)res_ptr;
2404 }
2405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2406         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2407         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
2408         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2409         return arg_arr;
2410 }
2411
2412 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2413         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2414         int8_tArray arg_arr = (*env)->NewByteArray(env, 32);
2415         (*env)->SetByteArrayRegion(env, arg_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2416         return arg_arr;
2417 }
2418
2419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1key_1derivation_1params(JNIEnv *env, jclass clz, int64_t this_arg) {
2420         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2421         LDKC2Tuple_u64u64Z* ret_ref = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
2422         *ret_ref = (this_arg_conv->key_derivation_params)(this_arg_conv->this_arg);
2423         return (long)ret_ref;
2424 }
2425
2426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1counterparty_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
2427         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2428         LDKCommitmentTransaction commitment_tx_conv;
2429         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2430         commitment_tx_conv.is_owned = false;
2431         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2432         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2433         return (long)ret_conv;
2434 }
2435
2436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1holder_1commitment_1and_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
2437         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2438         LDKHolderCommitmentTransaction commitment_tx_conv;
2439         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2440         commitment_tx_conv.is_owned = false;
2441         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2442         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2443         return (long)ret_conv;
2444 }
2445
2446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1justice_1transaction(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) {
2447         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2448         LDKTransaction justice_tx_ref;
2449         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2450         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2451         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2452         justice_tx_ref.data_is_owned = true;
2453         unsigned char per_commitment_key_arr[32];
2454         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2455         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2456         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2457         LDKHTLCOutputInCommitment htlc_conv;
2458         htlc_conv.inner = (void*)(htlc & (~1));
2459         htlc_conv.is_owned = false;
2460         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2461         *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
2462         return (long)ret_conv;
2463 }
2464
2465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_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) {
2466         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2467         LDKTransaction htlc_tx_ref;
2468         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2469         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2470         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2471         htlc_tx_ref.data_is_owned = true;
2472         LDKPublicKey per_commitment_point_ref;
2473         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2474         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2475         LDKHTLCOutputInCommitment htlc_conv;
2476         htlc_conv.inner = (void*)(htlc & (~1));
2477         htlc_conv.is_owned = false;
2478         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2479         *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);
2480         return (long)ret_conv;
2481 }
2482
2483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray closing_tx) {
2484         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2485         LDKTransaction closing_tx_ref;
2486         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
2487         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2488         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
2489         closing_tx_ref.data_is_owned = true;
2490         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2491         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2492         return (long)ret_conv;
2493 }
2494
2495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2496         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2497         LDKUnsignedChannelAnnouncement msg_conv;
2498         msg_conv.inner = (void*)(msg & (~1));
2499         msg_conv.is_owned = false;
2500         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2501         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2502         return (long)ret_conv;
2503 }
2504
2505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2506         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2507         LDKChannelTransactionParameters channel_parameters_conv;
2508         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2509         channel_parameters_conv.is_owned = false;
2510         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2511 }
2512
2513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2514         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2515         LDKCVec_u8Z arg_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2516         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
2517         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
2518         CVec_u8Z_free(arg_var);
2519         return arg_arr;
2520 }
2521
2522 LDKChannelPublicKeys LDKChannelKeys_set_get_pubkeys(LDKChannelKeys* this_arg) {
2523         if (this_arg->set_pubkeys != NULL)
2524                 this_arg->set_pubkeys(this_arg);
2525         return this_arg->pubkeys;
2526 }
2527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2528         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2529         LDKChannelPublicKeys ret_var = LDKChannelKeys_set_get_pubkeys(this_arg_conv);
2530         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2531         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2532         long ret_ref = (long)ret_var.inner;
2533         if (ret_var.is_owned) {
2534                 ret_ref |= 1;
2535         }
2536         return ret_ref;
2537 }
2538
2539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
2540         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2541         LDKThirtyTwoBytes a_ref;
2542         CHECK((*env)->GetArrayLength(env, a) == 32);
2543         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2544         ret->a = a_ref;
2545         LDKChannelMonitor b_conv;
2546         b_conv.inner = (void*)(b & (~1));
2547         b_conv.is_owned = (b & 1) || (b == 0);
2548         b_conv = ChannelMonitor_clone(&b_conv);
2549         ret->b = b_conv;
2550         return (long)ret;
2551 }
2552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2553         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2554         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2555         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2556         return a_arr;
2557 }
2558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2559         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2560         LDKChannelMonitor b_var = tuple->b;
2561         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2562         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2563         long b_ref = (long)b_var.inner & ~1;
2564         return b_ref;
2565 }
2566 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2567         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
2568 }
2569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2570         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2571         CHECK(val->result_ok);
2572         long res_ref = (long)(&(*val->contents.result)) | 1;
2573         return res_ref;
2574 }
2575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2576         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2577         CHECK(!val->result_ok);
2578         LDKDecodeError err_var = (*val->contents.err);
2579         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2580         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2581         long err_ref = (long)err_var.inner & ~1;
2582         return err_ref;
2583 }
2584 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2585         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
2586 }
2587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2588         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2589         CHECK(val->result_ok);
2590         long res_ref = ((long)&(*val->contents.result)) | 1;
2591         return (long)res_ref;
2592 }
2593 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2594         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2595         CHECK(!val->result_ok);
2596         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
2597         return err_conv;
2598 }
2599 static jclass LDKAPIError_APIMisuseError_class = NULL;
2600 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
2601 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
2602 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
2603 static jclass LDKAPIError_RouteError_class = NULL;
2604 static jmethodID LDKAPIError_RouteError_meth = NULL;
2605 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
2606 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
2607 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
2608 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
2609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
2610         LDKAPIError_APIMisuseError_class =
2611                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
2612         CHECK(LDKAPIError_APIMisuseError_class != NULL);
2613         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "([B)V");
2614         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
2615         LDKAPIError_FeeRateTooHigh_class =
2616                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
2617         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
2618         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "([BI)V");
2619         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
2620         LDKAPIError_RouteError_class =
2621                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
2622         CHECK(LDKAPIError_RouteError_class != NULL);
2623         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
2624         CHECK(LDKAPIError_RouteError_meth != NULL);
2625         LDKAPIError_ChannelUnavailable_class =
2626                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
2627         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
2628         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "([B)V");
2629         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
2630         LDKAPIError_MonitorUpdateFailed_class =
2631                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
2632         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
2633         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
2634         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
2635 }
2636 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2637         LDKAPIError *obj = (LDKAPIError*)ptr;
2638         switch(obj->tag) {
2639                 case LDKAPIError_APIMisuseError: {
2640                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
2641                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
2642                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
2643                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_arr);
2644                 }
2645                 case LDKAPIError_FeeRateTooHigh: {
2646                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
2647                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
2648                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
2649                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_arr, obj->fee_rate_too_high.feerate);
2650                 }
2651                 case LDKAPIError_RouteError: {
2652                         LDKStr err_str = obj->route_error.err;
2653                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2654                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
2655                 }
2656                 case LDKAPIError_ChannelUnavailable: {
2657                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
2658                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
2659                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
2660                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_arr);
2661                 }
2662                 case LDKAPIError_MonitorUpdateFailed: {
2663                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
2664                 }
2665                 default: abort();
2666         }
2667 }
2668 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2669         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2670 }
2671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2672         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2673         CHECK(val->result_ok);
2674         return *val->contents.result;
2675 }
2676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2677         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2678         CHECK(!val->result_ok);
2679         long err_ref = ((long)&(*val->contents.err)) | 1;
2680         return err_ref;
2681 }
2682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2683         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
2684         ret->datalen = (*env)->GetArrayLength(env, elems);
2685         if (ret->datalen == 0) {
2686                 ret->data = NULL;
2687         } else {
2688                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
2689                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2690                 for (size_t i = 0; i < ret->datalen; i++) {
2691                         int64_t arr_elem = java_elems[i];
2692                         LDKChannelDetails arr_elem_conv;
2693                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2694                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2695                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
2696                         ret->data[i] = arr_elem_conv;
2697                 }
2698                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2699         }
2700         return (long)ret;
2701 }
2702 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2703         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2704         for (size_t i = 0; i < ret.datalen; i++) {
2705                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2706         }
2707         return ret;
2708 }
2709 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2710         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
2711 }
2712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2713         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2714         CHECK(val->result_ok);
2715         return *val->contents.result;
2716 }
2717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2718         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2719         CHECK(!val->result_ok);
2720         LDKPaymentSendFailure err_var = (*val->contents.err);
2721         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2722         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2723         long err_ref = (long)err_var.inner & ~1;
2724         return err_ref;
2725 }
2726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2727         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
2728         ret->datalen = (*env)->GetArrayLength(env, elems);
2729         if (ret->datalen == 0) {
2730                 ret->data = NULL;
2731         } else {
2732                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
2733                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2734                 for (size_t i = 0; i < ret->datalen; i++) {
2735                         int64_t arr_elem = java_elems[i];
2736                         LDKChannelMonitor arr_elem_conv;
2737                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2738                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2739                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
2740                         ret->data[i] = arr_elem_conv;
2741                 }
2742                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2743         }
2744         return (long)ret;
2745 }
2746 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2747         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2748         for (size_t i = 0; i < ret.datalen; i++) {
2749                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2750         }
2751         return ret;
2752 }
2753 typedef struct LDKWatch_JCalls {
2754         atomic_size_t refcnt;
2755         JavaVM *vm;
2756         jweak o;
2757         jmethodID watch_channel_meth;
2758         jmethodID update_channel_meth;
2759         jmethodID release_pending_monitor_events_meth;
2760 } LDKWatch_JCalls;
2761 static void LDKWatch_JCalls_free(void* this_arg) {
2762         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2763         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2764                 JNIEnv *env;
2765                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2766                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2767                 FREE(j_calls);
2768         }
2769 }
2770 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2771         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2772         JNIEnv *env;
2773         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2774         LDKOutPoint funding_txo_var = funding_txo;
2775         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2776         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2777         long funding_txo_ref = (long)funding_txo_var.inner;
2778         if (funding_txo_var.is_owned) {
2779                 funding_txo_ref |= 1;
2780         }
2781         LDKChannelMonitor monitor_var = monitor;
2782         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2783         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2784         long monitor_ref = (long)monitor_var.inner;
2785         if (monitor_var.is_owned) {
2786                 monitor_ref |= 1;
2787         }
2788         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2789         CHECK(obj != NULL);
2790         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2791         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2792         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
2793         return ret_conv;
2794 }
2795 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2796         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2797         JNIEnv *env;
2798         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2799         LDKOutPoint funding_txo_var = funding_txo;
2800         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2801         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2802         long funding_txo_ref = (long)funding_txo_var.inner;
2803         if (funding_txo_var.is_owned) {
2804                 funding_txo_ref |= 1;
2805         }
2806         LDKChannelMonitorUpdate update_var = update;
2807         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2808         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2809         long update_ref = (long)update_var.inner;
2810         if (update_var.is_owned) {
2811                 update_ref |= 1;
2812         }
2813         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2814         CHECK(obj != NULL);
2815         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
2816         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2817         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
2818         return ret_conv;
2819 }
2820 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
2821         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2822         JNIEnv *env;
2823         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2824         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2825         CHECK(obj != NULL);
2826         int64_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
2827         LDKCVec_MonitorEventZ arg_constr;
2828         arg_constr.datalen = (*env)->GetArrayLength(env, arg);
2829         if (arg_constr.datalen > 0)
2830                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2831         else
2832                 arg_constr.data = NULL;
2833         int64_t* arg_vals = (*env)->GetLongArrayElements (env, arg, NULL);
2834         for (size_t o = 0; o < arg_constr.datalen; o++) {
2835                 int64_t arr_conv_14 = arg_vals[o];
2836                 LDKMonitorEvent arr_conv_14_conv;
2837                 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
2838                 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
2839                 arr_conv_14_conv = MonitorEvent_clone(&arr_conv_14_conv);
2840                 arg_constr.data[o] = arr_conv_14_conv;
2841         }
2842         (*env)->ReleaseLongArrayElements(env, arg, arg_vals, 0);
2843         return arg_constr;
2844 }
2845 static void* LDKWatch_JCalls_clone(const void* this_arg) {
2846         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2847         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2848         return (void*) this_arg;
2849 }
2850 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
2851         jclass c = (*env)->GetObjectClass(env, o);
2852         CHECK(c != NULL);
2853         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2854         atomic_init(&calls->refcnt, 1);
2855         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2856         calls->o = (*env)->NewWeakGlobalRef(env, o);
2857         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
2858         CHECK(calls->watch_channel_meth != NULL);
2859         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
2860         CHECK(calls->update_channel_meth != NULL);
2861         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
2862         CHECK(calls->release_pending_monitor_events_meth != NULL);
2863
2864         LDKWatch ret = {
2865                 .this_arg = (void*) calls,
2866                 .watch_channel = watch_channel_jcall,
2867                 .update_channel = update_channel_jcall,
2868                 .release_pending_monitor_events = release_pending_monitor_events_jcall,
2869                 .free = LDKWatch_JCalls_free,
2870         };
2871         return ret;
2872 }
2873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
2874         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2875         *res_ptr = LDKWatch_init(env, clz, o);
2876         return (long)res_ptr;
2877 }
2878 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) {
2879         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
2880         LDKOutPoint funding_txo_conv;
2881         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2882         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2883         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2884         LDKChannelMonitor monitor_conv;
2885         monitor_conv.inner = (void*)(monitor & (~1));
2886         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2887         monitor_conv = ChannelMonitor_clone(&monitor_conv);
2888         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2889         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2890         return (long)ret_conv;
2891 }
2892
2893 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) {
2894         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
2895         LDKOutPoint funding_txo_conv;
2896         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2897         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2898         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2899         LDKChannelMonitorUpdate update_conv;
2900         update_conv.inner = (void*)(update & (~1));
2901         update_conv.is_owned = (update & 1) || (update == 0);
2902         update_conv = ChannelMonitorUpdate_clone(&update_conv);
2903         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2904         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2905         return (long)ret_conv;
2906 }
2907
2908 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
2909         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
2910         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2911         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
2912         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
2913         for (size_t o = 0; o < ret_var.datalen; o++) {
2914                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
2915                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2916                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2917                 long arr_conv_14_ref = (long)arr_conv_14_var.inner;
2918                 if (arr_conv_14_var.is_owned) {
2919                         arr_conv_14_ref |= 1;
2920                 }
2921                 ret_arr_ptr[o] = arr_conv_14_ref;
2922         }
2923         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
2924         FREE(ret_var.data);
2925         return ret_arr;
2926 }
2927
2928 typedef struct LDKBroadcasterInterface_JCalls {
2929         atomic_size_t refcnt;
2930         JavaVM *vm;
2931         jweak o;
2932         jmethodID broadcast_transaction_meth;
2933 } LDKBroadcasterInterface_JCalls;
2934 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2935         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2936         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2937                 JNIEnv *env;
2938                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2939                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2940                 FREE(j_calls);
2941         }
2942 }
2943 void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) {
2944         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2945         JNIEnv *env;
2946         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2947         LDKTransaction tx_var = tx;
2948         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
2949         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
2950         Transaction_free(tx_var);
2951         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2952         CHECK(obj != NULL);
2953         return (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
2954 }
2955 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
2956         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2957         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2958         return (void*) this_arg;
2959 }
2960 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
2961         jclass c = (*env)->GetObjectClass(env, o);
2962         CHECK(c != NULL);
2963         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2964         atomic_init(&calls->refcnt, 1);
2965         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2966         calls->o = (*env)->NewWeakGlobalRef(env, o);
2967         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
2968         CHECK(calls->broadcast_transaction_meth != NULL);
2969
2970         LDKBroadcasterInterface ret = {
2971                 .this_arg = (void*) calls,
2972                 .broadcast_transaction = broadcast_transaction_jcall,
2973                 .free = LDKBroadcasterInterface_JCalls_free,
2974         };
2975         return ret;
2976 }
2977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
2978         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2979         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
2980         return (long)res_ptr;
2981 }
2982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
2983         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg;
2984         LDKTransaction tx_ref;
2985         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
2986         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
2987         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
2988         tx_ref.data_is_owned = true;
2989         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
2990 }
2991
2992 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2993         return ((LDKCResult_ChannelKeysDecodeErrorZ*)arg)->result_ok;
2994 }
2995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2996         LDKCResult_ChannelKeysDecodeErrorZ *val = (LDKCResult_ChannelKeysDecodeErrorZ*)(arg & ~1);
2997         CHECK(val->result_ok);
2998         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
2999         *ret = ChannelKeys_clone(&(*val->contents.result));
3000         return (long)ret;
3001 }
3002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3003         LDKCResult_ChannelKeysDecodeErrorZ *val = (LDKCResult_ChannelKeysDecodeErrorZ*)(arg & ~1);
3004         CHECK(!val->result_ok);
3005         LDKDecodeError err_var = (*val->contents.err);
3006         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3007         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3008         long err_ref = (long)err_var.inner & ~1;
3009         return err_ref;
3010 }
3011 typedef struct LDKKeysInterface_JCalls {
3012         atomic_size_t refcnt;
3013         JavaVM *vm;
3014         jweak o;
3015         jmethodID get_node_secret_meth;
3016         jmethodID get_destination_script_meth;
3017         jmethodID get_shutdown_pubkey_meth;
3018         jmethodID get_channel_keys_meth;
3019         jmethodID get_secure_random_bytes_meth;
3020         jmethodID read_chan_signer_meth;
3021 } LDKKeysInterface_JCalls;
3022 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3023         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3024         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3025                 JNIEnv *env;
3026                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3027                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3028                 FREE(j_calls);
3029         }
3030 }
3031 LDKSecretKey get_node_secret_jcall(const void* this_arg) {
3032         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3033         JNIEnv *env;
3034         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3035         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3036         CHECK(obj != NULL);
3037         int8_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3038         LDKSecretKey arg_ref;
3039         CHECK((*env)->GetArrayLength(env, arg) == 32);
3040         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
3041         return arg_ref;
3042 }
3043 LDKCVec_u8Z get_destination_script_jcall(const void* this_arg) {
3044         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3045         JNIEnv *env;
3046         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3047         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3048         CHECK(obj != NULL);
3049         int8_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
3050         LDKCVec_u8Z arg_ref;
3051         arg_ref.datalen = (*env)->GetArrayLength(env, arg);
3052         arg_ref.data = MALLOC(arg_ref.datalen, "LDKCVec_u8Z Bytes");
3053         (*env)->GetByteArrayRegion(env, arg, 0, arg_ref.datalen, arg_ref.data);
3054         return arg_ref;
3055 }
3056 LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) {
3057         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3058         JNIEnv *env;
3059         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3060         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3061         CHECK(obj != NULL);
3062         int8_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
3063         LDKPublicKey arg_ref;
3064         CHECK((*env)->GetArrayLength(env, arg) == 33);
3065         (*env)->GetByteArrayRegion(env, arg, 0, 33, arg_ref.compressed_form);
3066         return arg_ref;
3067 }
3068 LDKChannelKeys get_channel_keys_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3069         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3070         JNIEnv *env;
3071         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3072         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3073         CHECK(obj != NULL);
3074         LDKChannelKeys* ret = (LDKChannelKeys*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_keys_meth, inbound, channel_value_satoshis);
3075         LDKChannelKeys ret_conv = *(LDKChannelKeys*)(((uint64_t)ret) & ~1);
3076         ret_conv = ChannelKeys_clone(ret);
3077         return ret_conv;
3078 }
3079 LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) {
3080         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3081         JNIEnv *env;
3082         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3083         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3084         CHECK(obj != NULL);
3085         int8_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
3086         LDKThirtyTwoBytes arg_ref;
3087         CHECK((*env)->GetArrayLength(env, arg) == 32);
3088         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.data);
3089         return arg_ref;
3090 }
3091 LDKCResult_ChannelKeysDecodeErrorZ read_chan_signer_jcall(const void* this_arg, LDKu8slice reader) {
3092         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3093         JNIEnv *env;
3094         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3095         LDKu8slice reader_var = reader;
3096         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
3097         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
3098         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3099         CHECK(obj != NULL);
3100         LDKCResult_ChannelKeysDecodeErrorZ* ret = (LDKCResult_ChannelKeysDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
3101         LDKCResult_ChannelKeysDecodeErrorZ ret_conv = *(LDKCResult_ChannelKeysDecodeErrorZ*)(((uint64_t)ret) & ~1);
3102         ret_conv = CResult_ChannelKeysDecodeErrorZ_clone((LDKCResult_ChannelKeysDecodeErrorZ*)ret);
3103         return ret_conv;
3104 }
3105 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
3106         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3107         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3108         return (void*) this_arg;
3109 }
3110 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
3111         jclass c = (*env)->GetObjectClass(env, o);
3112         CHECK(c != NULL);
3113         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3114         atomic_init(&calls->refcnt, 1);
3115         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3116         calls->o = (*env)->NewWeakGlobalRef(env, o);
3117         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
3118         CHECK(calls->get_node_secret_meth != NULL);
3119         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
3120         CHECK(calls->get_destination_script_meth != NULL);
3121         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
3122         CHECK(calls->get_shutdown_pubkey_meth != NULL);
3123         calls->get_channel_keys_meth = (*env)->GetMethodID(env, c, "get_channel_keys", "(ZJ)J");
3124         CHECK(calls->get_channel_keys_meth != NULL);
3125         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
3126         CHECK(calls->get_secure_random_bytes_meth != NULL);
3127         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
3128         CHECK(calls->read_chan_signer_meth != NULL);
3129
3130         LDKKeysInterface ret = {
3131                 .this_arg = (void*) calls,
3132                 .get_node_secret = get_node_secret_jcall,
3133                 .get_destination_script = get_destination_script_jcall,
3134                 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
3135                 .get_channel_keys = get_channel_keys_jcall,
3136                 .get_secure_random_bytes = get_secure_random_bytes_jcall,
3137                 .read_chan_signer = read_chan_signer_jcall,
3138                 .free = LDKKeysInterface_JCalls_free,
3139         };
3140         return ret;
3141 }
3142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3143         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3144         *res_ptr = LDKKeysInterface_init(env, clz, o);
3145         return (long)res_ptr;
3146 }
3147 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
3148         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
3149         int8_tArray arg_arr = (*env)->NewByteArray(env, 32);
3150         (*env)->SetByteArrayRegion(env, arg_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
3151         return arg_arr;
3152 }
3153
3154 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
3155         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
3156         LDKCVec_u8Z arg_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3157         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
3158         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
3159         CVec_u8Z_free(arg_var);
3160         return arg_arr;
3161 }
3162
3163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
3164         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
3165         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
3166         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
3167         return arg_arr;
3168 }
3169
3170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1channel_1keys(JNIEnv *env, jclass clz, int64_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
3171         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
3172         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
3173         *ret = (this_arg_conv->get_channel_keys)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
3174         return (long)ret;
3175 }
3176
3177 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
3178         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
3179         int8_tArray arg_arr = (*env)->NewByteArray(env, 32);
3180         (*env)->SetByteArrayRegion(env, arg_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
3181         return arg_arr;
3182 }
3183
3184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
3185         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
3186         LDKu8slice reader_ref;
3187         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
3188         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
3189         LDKCResult_ChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelKeysDecodeErrorZ), "LDKCResult_ChannelKeysDecodeErrorZ");
3190         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
3191         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
3192         return (long)ret_conv;
3193 }
3194
3195 typedef struct LDKFeeEstimator_JCalls {
3196         atomic_size_t refcnt;
3197         JavaVM *vm;
3198         jweak o;
3199         jmethodID get_est_sat_per_1000_weight_meth;
3200 } LDKFeeEstimator_JCalls;
3201 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3202         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3203         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3204                 JNIEnv *env;
3205                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3206                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3207                 FREE(j_calls);
3208         }
3209 }
3210 uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
3211         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3212         JNIEnv *env;
3213         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3214         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
3215         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3216         CHECK(obj != NULL);
3217         return (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
3218 }
3219 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
3220         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3221         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3222         return (void*) this_arg;
3223 }
3224 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
3225         jclass c = (*env)->GetObjectClass(env, o);
3226         CHECK(c != NULL);
3227         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
3228         atomic_init(&calls->refcnt, 1);
3229         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3230         calls->o = (*env)->NewWeakGlobalRef(env, o);
3231         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I");
3232         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
3233
3234         LDKFeeEstimator ret = {
3235                 .this_arg = (void*) calls,
3236                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
3237                 .free = LDKFeeEstimator_JCalls_free,
3238         };
3239         return ret;
3240 }
3241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
3242         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
3243         *res_ptr = LDKFeeEstimator_init(env, clz, o);
3244         return (long)res_ptr;
3245 }
3246 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) {
3247         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg;
3248         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
3249         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
3250         return ret_val;
3251 }
3252
3253 typedef struct LDKLogger_JCalls {
3254         atomic_size_t refcnt;
3255         JavaVM *vm;
3256         jweak o;
3257         jmethodID log_meth;
3258 } LDKLogger_JCalls;
3259 static void LDKLogger_JCalls_free(void* this_arg) {
3260         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3261         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3262                 JNIEnv *env;
3263                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3264                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3265                 FREE(j_calls);
3266         }
3267 }
3268 void log_jcall(const void* this_arg, const char* record) {
3269         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3270         JNIEnv *env;
3271         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3272         const char* record_str = record;
3273         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
3274         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3275         CHECK(obj != NULL);
3276         return (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
3277 }
3278 static void* LDKLogger_JCalls_clone(const void* this_arg) {
3279         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3280         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3281         return (void*) this_arg;
3282 }
3283 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3284         jclass c = (*env)->GetObjectClass(env, o);
3285         CHECK(c != NULL);
3286         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3287         atomic_init(&calls->refcnt, 1);
3288         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3289         calls->o = (*env)->NewWeakGlobalRef(env, o);
3290         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
3291         CHECK(calls->log_meth != NULL);
3292
3293         LDKLogger ret = {
3294                 .this_arg = (void*) calls,
3295                 .log = log_jcall,
3296                 .free = LDKLogger_JCalls_free,
3297         };
3298         return ret;
3299 }
3300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3301         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3302         *res_ptr = LDKLogger_init(env, clz, o);
3303         return (long)res_ptr;
3304 }
3305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
3306         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
3307         LDKThirtyTwoBytes a_ref;
3308         CHECK((*env)->GetArrayLength(env, a) == 32);
3309         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3310         ret->a = a_ref;
3311         LDKChannelManager b_conv;
3312         b_conv.inner = (void*)(b & (~1));
3313         b_conv.is_owned = (b & 1) || (b == 0);
3314         // Warning: we need a move here but no clone is available for LDKChannelManager
3315         ret->b = b_conv;
3316         return (long)ret;
3317 }
3318 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3319         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
3320         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3321         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3322         return a_arr;
3323 }
3324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3325         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
3326         LDKChannelManager b_var = tuple->b;
3327         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3328         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3329         long b_ref = (long)b_var.inner & ~1;
3330         return b_ref;
3331 }
3332 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3333         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
3334 }
3335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3336         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3337         CHECK(val->result_ok);
3338         long res_ref = (long)(&(*val->contents.result)) | 1;
3339         return res_ref;
3340 }
3341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3342         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3343         CHECK(!val->result_ok);
3344         LDKDecodeError err_var = (*val->contents.err);
3345         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3346         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3347         long err_ref = (long)err_var.inner & ~1;
3348         return err_ref;
3349 }
3350 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3351         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
3352 }
3353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3354         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
3355         CHECK(val->result_ok);
3356         long res_ref = ((long)&(*val->contents.result)) | 1;
3357         return res_ref;
3358 }
3359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3360         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
3361         CHECK(!val->result_ok);
3362         LDKDecodeError err_var = (*val->contents.err);
3363         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3364         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3365         long err_ref = (long)err_var.inner & ~1;
3366         return err_ref;
3367 }
3368 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemoryChannelKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3369         return ((LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg)->result_ok;
3370 }
3371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemoryChannelKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3372         LDKCResult_InMemoryChannelKeysDecodeErrorZ *val = (LDKCResult_InMemoryChannelKeysDecodeErrorZ*)(arg & ~1);
3373         CHECK(val->result_ok);
3374         LDKInMemoryChannelKeys res_var = (*val->contents.result);
3375         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3376         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3377         long res_ref = (long)res_var.inner & ~1;
3378         return res_ref;
3379 }
3380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemoryChannelKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3381         LDKCResult_InMemoryChannelKeysDecodeErrorZ *val = (LDKCResult_InMemoryChannelKeysDecodeErrorZ*)(arg & ~1);
3382         CHECK(!val->result_ok);
3383         LDKDecodeError err_var = (*val->contents.err);
3384         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3385         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3386         long err_ref = (long)err_var.inner & ~1;
3387         return err_ref;
3388 }
3389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3390         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
3391         ret->datalen = (*env)->GetArrayLength(env, elems);
3392         if (ret->datalen == 0) {
3393                 ret->data = NULL;
3394         } else {
3395                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
3396                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3397                 for (size_t i = 0; i < ret->datalen; i++) {
3398                         int64_t arr_elem = java_elems[i];
3399                         LDKRouteHop arr_elem_conv;
3400                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3401                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3402                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
3403                         ret->data[i] = arr_elem_conv;
3404                 }
3405                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3406         }
3407         return (long)ret;
3408 }
3409 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
3410         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
3411         for (size_t i = 0; i < ret.datalen; i++) {
3412                 ret.data[i] = RouteHop_clone(&orig->data[i]);
3413         }
3414         return ret;
3415 }
3416 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
3417         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
3418         for (size_t i = 0; i < ret.datalen; i++) {
3419                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
3420         }
3421         return ret;
3422 }
3423 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3424         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
3425 }
3426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3427         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
3428         CHECK(val->result_ok);
3429         LDKRoute res_var = (*val->contents.result);
3430         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3431         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3432         long res_ref = (long)res_var.inner & ~1;
3433         return res_ref;
3434 }
3435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3436         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
3437         CHECK(!val->result_ok);
3438         LDKDecodeError err_var = (*val->contents.err);
3439         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3440         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3441         long err_ref = (long)err_var.inner & ~1;
3442         return err_ref;
3443 }
3444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3445         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
3446         ret->datalen = (*env)->GetArrayLength(env, elems);
3447         if (ret->datalen == 0) {
3448                 ret->data = NULL;
3449         } else {
3450                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
3451                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3452                 for (size_t i = 0; i < ret->datalen; i++) {
3453                         int64_t arr_elem = java_elems[i];
3454                         LDKRouteHint arr_elem_conv;
3455                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3456                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3457                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
3458                         ret->data[i] = arr_elem_conv;
3459                 }
3460                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3461         }
3462         return (long)ret;
3463 }
3464 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
3465         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
3466         for (size_t i = 0; i < ret.datalen; i++) {
3467                 ret.data[i] = RouteHint_clone(&orig->data[i]);
3468         }
3469         return ret;
3470 }
3471 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3472         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
3473 }
3474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3475         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
3476         CHECK(val->result_ok);
3477         LDKRoute res_var = (*val->contents.result);
3478         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3479         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3480         long res_ref = (long)res_var.inner & ~1;
3481         return res_ref;
3482 }
3483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3484         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
3485         CHECK(!val->result_ok);
3486         LDKLightningError err_var = (*val->contents.err);
3487         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3488         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3489         long err_ref = (long)err_var.inner & ~1;
3490         return err_ref;
3491 }
3492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3493         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
3494 }
3495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3496         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3497         CHECK(val->result_ok);
3498         long res_ref = ((long)&(*val->contents.result)) | 1;
3499         return res_ref;
3500 }
3501 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3502         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3503         CHECK(!val->result_ok);
3504         return *val->contents.err;
3505 }
3506 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3507         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
3508 }
3509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3510         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3511         CHECK(val->result_ok);
3512         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3513         *res_conv = (*val->contents.result);
3514         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
3515         return (long)res_conv;
3516 }
3517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3518         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3519         CHECK(!val->result_ok);
3520         LDKDecodeError err_var = (*val->contents.err);
3521         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3522         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3523         long err_ref = (long)err_var.inner & ~1;
3524         return err_ref;
3525 }
3526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3527         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
3528         ret->datalen = (*env)->GetArrayLength(env, elems);
3529         if (ret->datalen == 0) {
3530                 ret->data = NULL;
3531         } else {
3532                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
3533                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3534                 for (size_t i = 0; i < ret->datalen; i++) {
3535                         int64_t arr_elem = java_elems[i];
3536                         LDKUpdateAddHTLC arr_elem_conv;
3537                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3538                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3539                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3540                         ret->data[i] = arr_elem_conv;
3541                 }
3542                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3543         }
3544         return (long)ret;
3545 }
3546 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
3547         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
3548         for (size_t i = 0; i < ret.datalen; i++) {
3549                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
3550         }
3551         return ret;
3552 }
3553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3554         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
3555         ret->datalen = (*env)->GetArrayLength(env, elems);
3556         if (ret->datalen == 0) {
3557                 ret->data = NULL;
3558         } else {
3559                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
3560                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3561                 for (size_t i = 0; i < ret->datalen; i++) {
3562                         int64_t arr_elem = java_elems[i];
3563                         LDKUpdateFulfillHTLC arr_elem_conv;
3564                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3565                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3566                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3567                         ret->data[i] = arr_elem_conv;
3568                 }
3569                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3570         }
3571         return (long)ret;
3572 }
3573 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
3574         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
3575         for (size_t i = 0; i < ret.datalen; i++) {
3576                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
3577         }
3578         return ret;
3579 }
3580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3581         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
3582         ret->datalen = (*env)->GetArrayLength(env, elems);
3583         if (ret->datalen == 0) {
3584                 ret->data = NULL;
3585         } else {
3586                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
3587                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3588                 for (size_t i = 0; i < ret->datalen; i++) {
3589                         int64_t arr_elem = java_elems[i];
3590                         LDKUpdateFailHTLC arr_elem_conv;
3591                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3592                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3593                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
3594                         ret->data[i] = arr_elem_conv;
3595                 }
3596                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3597         }
3598         return (long)ret;
3599 }
3600 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
3601         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
3602         for (size_t i = 0; i < ret.datalen; i++) {
3603                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
3604         }
3605         return ret;
3606 }
3607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3608         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
3609         ret->datalen = (*env)->GetArrayLength(env, elems);
3610         if (ret->datalen == 0) {
3611                 ret->data = NULL;
3612         } else {
3613                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
3614                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3615                 for (size_t i = 0; i < ret->datalen; i++) {
3616                         int64_t arr_elem = java_elems[i];
3617                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3618                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3619                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3620                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3621                         ret->data[i] = arr_elem_conv;
3622                 }
3623                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3624         }
3625         return (long)ret;
3626 }
3627 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
3628         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
3629         for (size_t i = 0; i < ret.datalen; i++) {
3630                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
3631         }
3632         return ret;
3633 }
3634 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3635         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
3636 }
3637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3638         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3639         CHECK(val->result_ok);
3640         LDKAcceptChannel res_var = (*val->contents.result);
3641         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3642         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3643         long res_ref = (long)res_var.inner & ~1;
3644         return res_ref;
3645 }
3646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3647         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3648         CHECK(!val->result_ok);
3649         LDKDecodeError err_var = (*val->contents.err);
3650         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3651         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3652         long err_ref = (long)err_var.inner & ~1;
3653         return err_ref;
3654 }
3655 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3656         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
3657 }
3658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3659         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3660         CHECK(val->result_ok);
3661         LDKAnnouncementSignatures res_var = (*val->contents.result);
3662         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3663         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3664         long res_ref = (long)res_var.inner & ~1;
3665         return res_ref;
3666 }
3667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3668         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3669         CHECK(!val->result_ok);
3670         LDKDecodeError err_var = (*val->contents.err);
3671         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3672         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3673         long err_ref = (long)err_var.inner & ~1;
3674         return err_ref;
3675 }
3676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3677         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
3678 }
3679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3680         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3681         CHECK(val->result_ok);
3682         LDKChannelReestablish res_var = (*val->contents.result);
3683         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3684         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3685         long res_ref = (long)res_var.inner & ~1;
3686         return res_ref;
3687 }
3688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3689         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3690         CHECK(!val->result_ok);
3691         LDKDecodeError err_var = (*val->contents.err);
3692         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3693         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3694         long err_ref = (long)err_var.inner & ~1;
3695         return err_ref;
3696 }
3697 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3698         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
3699 }
3700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3701         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
3702         CHECK(val->result_ok);
3703         LDKClosingSigned res_var = (*val->contents.result);
3704         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3705         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3706         long res_ref = (long)res_var.inner & ~1;
3707         return res_ref;
3708 }
3709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3710         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
3711         CHECK(!val->result_ok);
3712         LDKDecodeError err_var = (*val->contents.err);
3713         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3714         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3715         long err_ref = (long)err_var.inner & ~1;
3716         return err_ref;
3717 }
3718 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3719         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
3720 }
3721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3722         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
3723         CHECK(val->result_ok);
3724         LDKCommitmentSigned res_var = (*val->contents.result);
3725         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3726         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3727         long res_ref = (long)res_var.inner & ~1;
3728         return res_ref;
3729 }
3730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3731         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
3732         CHECK(!val->result_ok);
3733         LDKDecodeError err_var = (*val->contents.err);
3734         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3735         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3736         long err_ref = (long)err_var.inner & ~1;
3737         return err_ref;
3738 }
3739 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3740         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
3741 }
3742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3743         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
3744         CHECK(val->result_ok);
3745         LDKFundingCreated res_var = (*val->contents.result);
3746         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3747         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3748         long res_ref = (long)res_var.inner & ~1;
3749         return res_ref;
3750 }
3751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3752         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
3753         CHECK(!val->result_ok);
3754         LDKDecodeError err_var = (*val->contents.err);
3755         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3756         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3757         long err_ref = (long)err_var.inner & ~1;
3758         return err_ref;
3759 }
3760 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3761         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
3762 }
3763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3764         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
3765         CHECK(val->result_ok);
3766         LDKFundingSigned res_var = (*val->contents.result);
3767         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3768         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3769         long res_ref = (long)res_var.inner & ~1;
3770         return res_ref;
3771 }
3772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3773         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
3774         CHECK(!val->result_ok);
3775         LDKDecodeError err_var = (*val->contents.err);
3776         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3777         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3778         long err_ref = (long)err_var.inner & ~1;
3779         return err_ref;
3780 }
3781 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3782         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
3783 }
3784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3785         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
3786         CHECK(val->result_ok);
3787         LDKFundingLocked res_var = (*val->contents.result);
3788         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3789         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3790         long res_ref = (long)res_var.inner & ~1;
3791         return res_ref;
3792 }
3793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3794         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
3795         CHECK(!val->result_ok);
3796         LDKDecodeError err_var = (*val->contents.err);
3797         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3798         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3799         long err_ref = (long)err_var.inner & ~1;
3800         return err_ref;
3801 }
3802 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3803         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
3804 }
3805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3806         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
3807         CHECK(val->result_ok);
3808         LDKInit res_var = (*val->contents.result);
3809         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3810         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3811         long res_ref = (long)res_var.inner & ~1;
3812         return res_ref;
3813 }
3814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3815         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
3816         CHECK(!val->result_ok);
3817         LDKDecodeError err_var = (*val->contents.err);
3818         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3819         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3820         long err_ref = (long)err_var.inner & ~1;
3821         return err_ref;
3822 }
3823 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3824         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
3825 }
3826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3827         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
3828         CHECK(val->result_ok);
3829         LDKOpenChannel res_var = (*val->contents.result);
3830         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3831         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3832         long res_ref = (long)res_var.inner & ~1;
3833         return res_ref;
3834 }
3835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3836         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
3837         CHECK(!val->result_ok);
3838         LDKDecodeError err_var = (*val->contents.err);
3839         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3840         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3841         long err_ref = (long)err_var.inner & ~1;
3842         return err_ref;
3843 }
3844 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3845         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
3846 }
3847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3848         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
3849         CHECK(val->result_ok);
3850         LDKRevokeAndACK res_var = (*val->contents.result);
3851         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3852         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3853         long res_ref = (long)res_var.inner & ~1;
3854         return res_ref;
3855 }
3856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3857         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
3858         CHECK(!val->result_ok);
3859         LDKDecodeError err_var = (*val->contents.err);
3860         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3861         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3862         long err_ref = (long)err_var.inner & ~1;
3863         return err_ref;
3864 }
3865 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3866         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
3867 }
3868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3869         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
3870         CHECK(val->result_ok);
3871         LDKShutdown res_var = (*val->contents.result);
3872         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3873         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3874         long res_ref = (long)res_var.inner & ~1;
3875         return res_ref;
3876 }
3877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3878         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
3879         CHECK(!val->result_ok);
3880         LDKDecodeError err_var = (*val->contents.err);
3881         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3882         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3883         long err_ref = (long)err_var.inner & ~1;
3884         return err_ref;
3885 }
3886 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3887         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
3888 }
3889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3890         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
3891         CHECK(val->result_ok);
3892         LDKUpdateFailHTLC res_var = (*val->contents.result);
3893         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3894         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3895         long res_ref = (long)res_var.inner & ~1;
3896         return res_ref;
3897 }
3898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3899         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
3900         CHECK(!val->result_ok);
3901         LDKDecodeError err_var = (*val->contents.err);
3902         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3903         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3904         long err_ref = (long)err_var.inner & ~1;
3905         return err_ref;
3906 }
3907 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3908         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
3909 }
3910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3911         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
3912         CHECK(val->result_ok);
3913         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
3914         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3915         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3916         long res_ref = (long)res_var.inner & ~1;
3917         return res_ref;
3918 }
3919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3920         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
3921         CHECK(!val->result_ok);
3922         LDKDecodeError err_var = (*val->contents.err);
3923         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3924         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3925         long err_ref = (long)err_var.inner & ~1;
3926         return err_ref;
3927 }
3928 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3929         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
3930 }
3931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3932         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
3933         CHECK(val->result_ok);
3934         LDKUpdateFee res_var = (*val->contents.result);
3935         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3936         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3937         long res_ref = (long)res_var.inner & ~1;
3938         return res_ref;
3939 }
3940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3941         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
3942         CHECK(!val->result_ok);
3943         LDKDecodeError err_var = (*val->contents.err);
3944         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3945         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3946         long err_ref = (long)err_var.inner & ~1;
3947         return err_ref;
3948 }
3949 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3950         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
3951 }
3952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3953         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
3954         CHECK(val->result_ok);
3955         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
3956         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3957         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3958         long res_ref = (long)res_var.inner & ~1;
3959         return res_ref;
3960 }
3961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3962         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
3963         CHECK(!val->result_ok);
3964         LDKDecodeError err_var = (*val->contents.err);
3965         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3966         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3967         long err_ref = (long)err_var.inner & ~1;
3968         return err_ref;
3969 }
3970 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3971         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
3972 }
3973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3974         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
3975         CHECK(val->result_ok);
3976         LDKUpdateAddHTLC res_var = (*val->contents.result);
3977         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3978         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3979         long res_ref = (long)res_var.inner & ~1;
3980         return res_ref;
3981 }
3982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3983         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
3984         CHECK(!val->result_ok);
3985         LDKDecodeError err_var = (*val->contents.err);
3986         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3987         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3988         long err_ref = (long)err_var.inner & ~1;
3989         return err_ref;
3990 }
3991 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3992         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
3993 }
3994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3995         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
3996         CHECK(val->result_ok);
3997         LDKPing res_var = (*val->contents.result);
3998         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3999         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4000         long res_ref = (long)res_var.inner & ~1;
4001         return res_ref;
4002 }
4003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4004         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4005         CHECK(!val->result_ok);
4006         LDKDecodeError err_var = (*val->contents.err);
4007         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4008         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4009         long err_ref = (long)err_var.inner & ~1;
4010         return err_ref;
4011 }
4012 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4013         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
4014 }
4015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4016         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4017         CHECK(val->result_ok);
4018         LDKPong res_var = (*val->contents.result);
4019         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4020         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4021         long res_ref = (long)res_var.inner & ~1;
4022         return res_ref;
4023 }
4024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4025         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4026         CHECK(!val->result_ok);
4027         LDKDecodeError err_var = (*val->contents.err);
4028         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4029         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4030         long err_ref = (long)err_var.inner & ~1;
4031         return err_ref;
4032 }
4033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4034         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4035 }
4036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4037         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4038         CHECK(val->result_ok);
4039         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
4040         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4041         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4042         long res_ref = (long)res_var.inner & ~1;
4043         return res_ref;
4044 }
4045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4046         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4047         CHECK(!val->result_ok);
4048         LDKDecodeError err_var = (*val->contents.err);
4049         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4050         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4051         long err_ref = (long)err_var.inner & ~1;
4052         return err_ref;
4053 }
4054 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4055         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4056 }
4057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4058         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4059         CHECK(val->result_ok);
4060         LDKChannelAnnouncement res_var = (*val->contents.result);
4061         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4062         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4063         long res_ref = (long)res_var.inner & ~1;
4064         return res_ref;
4065 }
4066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4067         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4068         CHECK(!val->result_ok);
4069         LDKDecodeError err_var = (*val->contents.err);
4070         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4071         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4072         long err_ref = (long)err_var.inner & ~1;
4073         return err_ref;
4074 }
4075 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4076         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
4077 }
4078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4079         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4080         CHECK(val->result_ok);
4081         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
4082         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4083         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4084         long res_ref = (long)res_var.inner & ~1;
4085         return res_ref;
4086 }
4087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4088         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4089         CHECK(!val->result_ok);
4090         LDKDecodeError err_var = (*val->contents.err);
4091         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4092         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4093         long err_ref = (long)err_var.inner & ~1;
4094         return err_ref;
4095 }
4096 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4097         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
4098 }
4099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4100         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4101         CHECK(val->result_ok);
4102         LDKChannelUpdate res_var = (*val->contents.result);
4103         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4104         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4105         long res_ref = (long)res_var.inner & ~1;
4106         return res_ref;
4107 }
4108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4109         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4110         CHECK(!val->result_ok);
4111         LDKDecodeError err_var = (*val->contents.err);
4112         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4113         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4114         long err_ref = (long)err_var.inner & ~1;
4115         return err_ref;
4116 }
4117 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4118         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
4119 }
4120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4121         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4122         CHECK(val->result_ok);
4123         LDKErrorMessage res_var = (*val->contents.result);
4124         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4125         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4126         long res_ref = (long)res_var.inner & ~1;
4127         return res_ref;
4128 }
4129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4130         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4131         CHECK(!val->result_ok);
4132         LDKDecodeError err_var = (*val->contents.err);
4133         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4134         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4135         long err_ref = (long)err_var.inner & ~1;
4136         return err_ref;
4137 }
4138 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4139         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4140 }
4141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4142         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4143         CHECK(val->result_ok);
4144         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
4145         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4146         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4147         long res_ref = (long)res_var.inner & ~1;
4148         return res_ref;
4149 }
4150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4151         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4152         CHECK(!val->result_ok);
4153         LDKDecodeError err_var = (*val->contents.err);
4154         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4155         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4156         long err_ref = (long)err_var.inner & ~1;
4157         return err_ref;
4158 }
4159 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4160         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4161 }
4162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4163         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4164         CHECK(val->result_ok);
4165         LDKNodeAnnouncement res_var = (*val->contents.result);
4166         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4167         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4168         long res_ref = (long)res_var.inner & ~1;
4169         return res_ref;
4170 }
4171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4172         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4173         CHECK(!val->result_ok);
4174         LDKDecodeError err_var = (*val->contents.err);
4175         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4176         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4177         long err_ref = (long)err_var.inner & ~1;
4178         return err_ref;
4179 }
4180 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4181         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
4182 }
4183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4184         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4185         CHECK(val->result_ok);
4186         LDKQueryShortChannelIds res_var = (*val->contents.result);
4187         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4188         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4189         long res_ref = (long)res_var.inner & ~1;
4190         return res_ref;
4191 }
4192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4193         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4194         CHECK(!val->result_ok);
4195         LDKDecodeError err_var = (*val->contents.err);
4196         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4197         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4198         long err_ref = (long)err_var.inner & ~1;
4199         return err_ref;
4200 }
4201 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4202         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
4203 }
4204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4205         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4206         CHECK(val->result_ok);
4207         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
4208         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4209         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4210         long res_ref = (long)res_var.inner & ~1;
4211         return res_ref;
4212 }
4213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4214         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4215         CHECK(!val->result_ok);
4216         LDKDecodeError err_var = (*val->contents.err);
4217         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4218         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4219         long err_ref = (long)err_var.inner & ~1;
4220         return err_ref;
4221 }
4222 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4223         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
4224 }
4225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4226         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4227         CHECK(val->result_ok);
4228         LDKQueryChannelRange res_var = (*val->contents.result);
4229         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4230         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4231         long res_ref = (long)res_var.inner & ~1;
4232         return res_ref;
4233 }
4234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4235         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4236         CHECK(!val->result_ok);
4237         LDKDecodeError err_var = (*val->contents.err);
4238         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4239         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4240         long err_ref = (long)err_var.inner & ~1;
4241         return err_ref;
4242 }
4243 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4244         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
4245 }
4246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4247         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4248         CHECK(val->result_ok);
4249         LDKReplyChannelRange res_var = (*val->contents.result);
4250         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4251         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4252         long res_ref = (long)res_var.inner & ~1;
4253         return res_ref;
4254 }
4255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4256         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4257         CHECK(!val->result_ok);
4258         LDKDecodeError err_var = (*val->contents.err);
4259         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4260         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4261         long err_ref = (long)err_var.inner & ~1;
4262         return err_ref;
4263 }
4264 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4265         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
4266 }
4267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4268         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4269         CHECK(val->result_ok);
4270         LDKGossipTimestampFilter res_var = (*val->contents.result);
4271         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4272         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4273         long res_ref = (long)res_var.inner & ~1;
4274         return res_ref;
4275 }
4276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4277         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4278         CHECK(!val->result_ok);
4279         LDKDecodeError err_var = (*val->contents.err);
4280         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4281         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4282         long err_ref = (long)err_var.inner & ~1;
4283         return err_ref;
4284 }
4285 typedef struct LDKMessageSendEventsProvider_JCalls {
4286         atomic_size_t refcnt;
4287         JavaVM *vm;
4288         jweak o;
4289         jmethodID get_and_clear_pending_msg_events_meth;
4290 } LDKMessageSendEventsProvider_JCalls;
4291 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
4292         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4293         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4294                 JNIEnv *env;
4295                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4296                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4297                 FREE(j_calls);
4298         }
4299 }
4300 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
4301         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4302         JNIEnv *env;
4303         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4304         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4305         CHECK(obj != NULL);
4306         int64_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
4307         LDKCVec_MessageSendEventZ arg_constr;
4308         arg_constr.datalen = (*env)->GetArrayLength(env, arg);
4309         if (arg_constr.datalen > 0)
4310                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4311         else
4312                 arg_constr.data = NULL;
4313         int64_t* arg_vals = (*env)->GetLongArrayElements (env, arg, NULL);
4314         for (size_t s = 0; s < arg_constr.datalen; s++) {
4315                 int64_t arr_conv_18 = arg_vals[s];
4316                 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_conv_18) & ~1);
4317                 FREE((void*)arr_conv_18);
4318                 arg_constr.data[s] = arr_conv_18_conv;
4319         }
4320         (*env)->ReleaseLongArrayElements(env, arg, arg_vals, 0);
4321         return arg_constr;
4322 }
4323 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
4324         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4325         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4326         return (void*) this_arg;
4327 }
4328 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
4329         jclass c = (*env)->GetObjectClass(env, o);
4330         CHECK(c != NULL);
4331         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
4332         atomic_init(&calls->refcnt, 1);
4333         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4334         calls->o = (*env)->NewWeakGlobalRef(env, o);
4335         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
4336         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
4337
4338         LDKMessageSendEventsProvider ret = {
4339                 .this_arg = (void*) calls,
4340                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
4341                 .free = LDKMessageSendEventsProvider_JCalls_free,
4342         };
4343         return ret;
4344 }
4345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
4346         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
4347         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
4348         return (long)res_ptr;
4349 }
4350 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4351         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg;
4352         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
4353         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4354         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4355         for (size_t s = 0; s < ret_var.datalen; s++) {
4356                 LDKMessageSendEvent *arr_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
4357                 *arr_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
4358                 long arr_conv_18_ref = (long)arr_conv_18_copy;
4359                 ret_arr_ptr[s] = arr_conv_18_ref;
4360         }
4361         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4362         FREE(ret_var.data);
4363         return ret_arr;
4364 }
4365
4366 typedef struct LDKEventsProvider_JCalls {
4367         atomic_size_t refcnt;
4368         JavaVM *vm;
4369         jweak o;
4370         jmethodID get_and_clear_pending_events_meth;
4371 } LDKEventsProvider_JCalls;
4372 static void LDKEventsProvider_JCalls_free(void* this_arg) {
4373         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4374         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4375                 JNIEnv *env;
4376                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4377                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4378                 FREE(j_calls);
4379         }
4380 }
4381 LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
4382         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4383         JNIEnv *env;
4384         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4385         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4386         CHECK(obj != NULL);
4387         int64_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_events_meth);
4388         LDKCVec_EventZ arg_constr;
4389         arg_constr.datalen = (*env)->GetArrayLength(env, arg);
4390         if (arg_constr.datalen > 0)
4391                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
4392         else
4393                 arg_constr.data = NULL;
4394         int64_t* arg_vals = (*env)->GetLongArrayElements (env, arg, NULL);
4395         for (size_t h = 0; h < arg_constr.datalen; h++) {
4396                 int64_t arr_conv_7 = arg_vals[h];
4397                 LDKEvent arr_conv_7_conv = *(LDKEvent*)(((uint64_t)arr_conv_7) & ~1);
4398                 FREE((void*)arr_conv_7);
4399                 arg_constr.data[h] = arr_conv_7_conv;
4400         }
4401         (*env)->ReleaseLongArrayElements(env, arg, arg_vals, 0);
4402         return arg_constr;
4403 }
4404 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
4405         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4406         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4407         return (void*) this_arg;
4408 }
4409 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
4410         jclass c = (*env)->GetObjectClass(env, o);
4411         CHECK(c != NULL);
4412         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
4413         atomic_init(&calls->refcnt, 1);
4414         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4415         calls->o = (*env)->NewWeakGlobalRef(env, o);
4416         calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()[J");
4417         CHECK(calls->get_and_clear_pending_events_meth != NULL);
4418
4419         LDKEventsProvider ret = {
4420                 .this_arg = (void*) calls,
4421                 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
4422                 .free = LDKEventsProvider_JCalls_free,
4423         };
4424         return ret;
4425 }
4426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
4427         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
4428         *res_ptr = LDKEventsProvider_init(env, clz, o);
4429         return (long)res_ptr;
4430 }
4431 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_EventsProvider_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4432         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg;
4433         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
4434         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4435         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4436         for (size_t h = 0; h < ret_var.datalen; h++) {
4437                 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
4438                 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
4439                 long arr_conv_7_ref = (long)arr_conv_7_copy;
4440                 ret_arr_ptr[h] = arr_conv_7_ref;
4441         }
4442         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4443         FREE(ret_var.data);
4444         return ret_arr;
4445 }
4446
4447 typedef struct LDKAccess_JCalls {
4448         atomic_size_t refcnt;
4449         JavaVM *vm;
4450         jweak o;
4451         jmethodID get_utxo_meth;
4452 } LDKAccess_JCalls;
4453 static void LDKAccess_JCalls_free(void* this_arg) {
4454         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4455         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4456                 JNIEnv *env;
4457                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4458                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4459                 FREE(j_calls);
4460         }
4461 }
4462 LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4463         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4464         JNIEnv *env;
4465         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4466         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
4467         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
4468         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4469         CHECK(obj != NULL);
4470         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4471         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
4472         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)ret);
4473         return ret_conv;
4474 }
4475 static void* LDKAccess_JCalls_clone(const void* this_arg) {
4476         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4477         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4478         return (void*) this_arg;
4479 }
4480 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
4481         jclass c = (*env)->GetObjectClass(env, o);
4482         CHECK(c != NULL);
4483         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4484         atomic_init(&calls->refcnt, 1);
4485         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4486         calls->o = (*env)->NewWeakGlobalRef(env, o);
4487         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
4488         CHECK(calls->get_utxo_meth != NULL);
4489
4490         LDKAccess ret = {
4491                 .this_arg = (void*) calls,
4492                 .get_utxo = get_utxo_jcall,
4493                 .free = LDKAccess_JCalls_free,
4494         };
4495         return ret;
4496 }
4497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
4498         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4499         *res_ptr = LDKAccess_init(env, clz, o);
4500         return (long)res_ptr;
4501 }
4502 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) {
4503         LDKAccess* this_arg_conv = (LDKAccess*)this_arg;
4504         unsigned char genesis_hash_arr[32];
4505         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
4506         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
4507         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4508         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4509         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4510         return (long)ret_conv;
4511 }
4512
4513 typedef struct LDKFilter_JCalls {
4514         atomic_size_t refcnt;
4515         JavaVM *vm;
4516         jweak o;
4517         jmethodID register_tx_meth;
4518         jmethodID register_output_meth;
4519 } LDKFilter_JCalls;
4520 static void LDKFilter_JCalls_free(void* this_arg) {
4521         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4522         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4523                 JNIEnv *env;
4524                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4525                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4526                 FREE(j_calls);
4527         }
4528 }
4529 void register_tx_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
4530         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4531         JNIEnv *env;
4532         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4533         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
4534         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
4535         LDKu8slice script_pubkey_var = script_pubkey;
4536         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
4537         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
4538         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4539         CHECK(obj != NULL);
4540         return (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
4541 }
4542 void register_output_jcall(const void* this_arg, const LDKOutPoint * outpoint, LDKu8slice script_pubkey) {
4543         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4544         JNIEnv *env;
4545         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4546         LDKOutPoint outpoint_var = *outpoint;
4547         outpoint_var = OutPoint_clone(outpoint);
4548         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4549         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4550         long outpoint_ref = (long)outpoint_var.inner;
4551         if (outpoint_var.is_owned) {
4552                 outpoint_ref |= 1;
4553         }
4554         LDKu8slice script_pubkey_var = script_pubkey;
4555         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
4556         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
4557         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4558         CHECK(obj != NULL);
4559         return (*env)->CallVoidMethod(env, obj, j_calls->register_output_meth, outpoint_ref, script_pubkey_arr);
4560 }
4561 static void* LDKFilter_JCalls_clone(const void* this_arg) {
4562         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4563         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4564         return (void*) this_arg;
4565 }
4566 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
4567         jclass c = (*env)->GetObjectClass(env, o);
4568         CHECK(c != NULL);
4569         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
4570         atomic_init(&calls->refcnt, 1);
4571         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4572         calls->o = (*env)->NewWeakGlobalRef(env, o);
4573         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
4574         CHECK(calls->register_tx_meth != NULL);
4575         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J[B)V");
4576         CHECK(calls->register_output_meth != NULL);
4577
4578         LDKFilter ret = {
4579                 .this_arg = (void*) calls,
4580                 .register_tx = register_tx_jcall,
4581                 .register_output = register_output_jcall,
4582                 .free = LDKFilter_JCalls_free,
4583         };
4584         return ret;
4585 }
4586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
4587         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
4588         *res_ptr = LDKFilter_init(env, clz, o);
4589         return (long)res_ptr;
4590 }
4591 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) {
4592         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
4593         unsigned char txid_arr[32];
4594         CHECK((*env)->GetArrayLength(env, txid) == 32);
4595         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
4596         unsigned char (*txid_ref)[32] = &txid_arr;
4597         LDKu8slice script_pubkey_ref;
4598         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
4599         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
4600         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
4601         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
4602 }
4603
4604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t outpoint, int8_tArray script_pubkey) {
4605         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
4606         LDKOutPoint outpoint_conv;
4607         outpoint_conv.inner = (void*)(outpoint & (~1));
4608         outpoint_conv.is_owned = false;
4609         LDKu8slice script_pubkey_ref;
4610         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
4611         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
4612         (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_ref);
4613         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
4614 }
4615
4616 typedef struct LDKPersist_JCalls {
4617         atomic_size_t refcnt;
4618         JavaVM *vm;
4619         jweak o;
4620         jmethodID persist_new_channel_meth;
4621         jmethodID update_persisted_channel_meth;
4622 } LDKPersist_JCalls;
4623 static void LDKPersist_JCalls_free(void* this_arg) {
4624         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4625         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4626                 JNIEnv *env;
4627                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4628                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4629                 FREE(j_calls);
4630         }
4631 }
4632 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
4633         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4634         JNIEnv *env;
4635         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4636         LDKOutPoint id_var = id;
4637         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4638         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4639         long id_ref = (long)id_var.inner;
4640         if (id_var.is_owned) {
4641                 id_ref |= 1;
4642         }
4643         LDKChannelMonitor data_var = *data;
4644         data_var = ChannelMonitor_clone(data);
4645         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4646         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4647         long data_ref = (long)data_var.inner;
4648         if (data_var.is_owned) {
4649                 data_ref |= 1;
4650         }
4651         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4652         CHECK(obj != NULL);
4653         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
4654         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
4655         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
4656         return ret_conv;
4657 }
4658 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
4659         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4660         JNIEnv *env;
4661         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4662         LDKOutPoint id_var = id;
4663         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4664         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4665         long id_ref = (long)id_var.inner;
4666         if (id_var.is_owned) {
4667                 id_ref |= 1;
4668         }
4669         LDKChannelMonitorUpdate update_var = *update;
4670         update_var = ChannelMonitorUpdate_clone(update);
4671         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4672         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4673         long update_ref = (long)update_var.inner;
4674         if (update_var.is_owned) {
4675                 update_ref |= 1;
4676         }
4677         LDKChannelMonitor data_var = *data;
4678         data_var = ChannelMonitor_clone(data);
4679         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4680         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4681         long data_ref = (long)data_var.inner;
4682         if (data_var.is_owned) {
4683                 data_ref |= 1;
4684         }
4685         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4686         CHECK(obj != NULL);
4687         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
4688         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
4689         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
4690         return ret_conv;
4691 }
4692 static void* LDKPersist_JCalls_clone(const void* this_arg) {
4693         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4694         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4695         return (void*) this_arg;
4696 }
4697 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
4698         jclass c = (*env)->GetObjectClass(env, o);
4699         CHECK(c != NULL);
4700         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
4701         atomic_init(&calls->refcnt, 1);
4702         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4703         calls->o = (*env)->NewWeakGlobalRef(env, o);
4704         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
4705         CHECK(calls->persist_new_channel_meth != NULL);
4706         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
4707         CHECK(calls->update_persisted_channel_meth != NULL);
4708
4709         LDKPersist ret = {
4710                 .this_arg = (void*) calls,
4711                 .persist_new_channel = persist_new_channel_jcall,
4712                 .update_persisted_channel = update_persisted_channel_jcall,
4713                 .free = LDKPersist_JCalls_free,
4714         };
4715         return ret;
4716 }
4717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
4718         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
4719         *res_ptr = LDKPersist_init(env, clz, o);
4720         return (long)res_ptr;
4721 }
4722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1persist_1new_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t data) {
4723         LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
4724         LDKOutPoint id_conv;
4725         id_conv.inner = (void*)(id & (~1));
4726         id_conv.is_owned = (id & 1) || (id == 0);
4727         id_conv = OutPoint_clone(&id_conv);
4728         LDKChannelMonitor data_conv;
4729         data_conv.inner = (void*)(data & (~1));
4730         data_conv.is_owned = false;
4731         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4732         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
4733         return (long)ret_conv;
4734 }
4735
4736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1update_1persisted_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t update, int64_t data) {
4737         LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
4738         LDKOutPoint id_conv;
4739         id_conv.inner = (void*)(id & (~1));
4740         id_conv.is_owned = (id & 1) || (id == 0);
4741         id_conv = OutPoint_clone(&id_conv);
4742         LDKChannelMonitorUpdate update_conv;
4743         update_conv.inner = (void*)(update & (~1));
4744         update_conv.is_owned = false;
4745         LDKChannelMonitor data_conv;
4746         data_conv.inner = (void*)(data & (~1));
4747         data_conv.is_owned = false;
4748         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4749         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
4750         return (long)ret_conv;
4751 }
4752
4753 typedef struct LDKChannelMessageHandler_JCalls {
4754         atomic_size_t refcnt;
4755         JavaVM *vm;
4756         jweak o;
4757         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
4758         jmethodID handle_open_channel_meth;
4759         jmethodID handle_accept_channel_meth;
4760         jmethodID handle_funding_created_meth;
4761         jmethodID handle_funding_signed_meth;
4762         jmethodID handle_funding_locked_meth;
4763         jmethodID handle_shutdown_meth;
4764         jmethodID handle_closing_signed_meth;
4765         jmethodID handle_update_add_htlc_meth;
4766         jmethodID handle_update_fulfill_htlc_meth;
4767         jmethodID handle_update_fail_htlc_meth;
4768         jmethodID handle_update_fail_malformed_htlc_meth;
4769         jmethodID handle_commitment_signed_meth;
4770         jmethodID handle_revoke_and_ack_meth;
4771         jmethodID handle_update_fee_meth;
4772         jmethodID handle_announcement_signatures_meth;
4773         jmethodID peer_disconnected_meth;
4774         jmethodID peer_connected_meth;
4775         jmethodID handle_channel_reestablish_meth;
4776         jmethodID handle_error_meth;
4777 } LDKChannelMessageHandler_JCalls;
4778 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
4779         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4780         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4781                 JNIEnv *env;
4782                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4783                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4784                 FREE(j_calls);
4785         }
4786 }
4787 void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
4788         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4789         JNIEnv *env;
4790         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4791         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
4792         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
4793         LDKInitFeatures their_features_var = their_features;
4794         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4795         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4796         long their_features_ref = (long)their_features_var.inner;
4797         if (their_features_var.is_owned) {
4798                 their_features_ref |= 1;
4799         }
4800         LDKOpenChannel msg_var = *msg;
4801         msg_var = OpenChannel_clone(msg);
4802         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4803         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4804         long msg_ref = (long)msg_var.inner;
4805         if (msg_var.is_owned) {
4806                 msg_ref |= 1;
4807         }
4808         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4809         CHECK(obj != NULL);
4810         return (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
4811 }
4812 void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
4813         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4814         JNIEnv *env;
4815         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4816         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
4817         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
4818         LDKInitFeatures their_features_var = their_features;
4819         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4820         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4821         long their_features_ref = (long)their_features_var.inner;
4822         if (their_features_var.is_owned) {
4823                 their_features_ref |= 1;
4824         }
4825         LDKAcceptChannel msg_var = *msg;
4826         msg_var = AcceptChannel_clone(msg);
4827         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4828         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4829         long msg_ref = (long)msg_var.inner;
4830         if (msg_var.is_owned) {
4831                 msg_ref |= 1;
4832         }
4833         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4834         CHECK(obj != NULL);
4835         return (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
4836 }
4837 void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
4838         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4839         JNIEnv *env;
4840         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4841         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
4842         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
4843         LDKFundingCreated msg_var = *msg;
4844         msg_var = FundingCreated_clone(msg);
4845         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4846         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4847         long msg_ref = (long)msg_var.inner;
4848         if (msg_var.is_owned) {
4849                 msg_ref |= 1;
4850         }
4851         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4852         CHECK(obj != NULL);
4853         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
4854 }
4855 void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
4856         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4857         JNIEnv *env;
4858         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4859         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
4860         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
4861         LDKFundingSigned msg_var = *msg;
4862         msg_var = FundingSigned_clone(msg);
4863         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4864         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4865         long msg_ref = (long)msg_var.inner;
4866         if (msg_var.is_owned) {
4867                 msg_ref |= 1;
4868         }
4869         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4870         CHECK(obj != NULL);
4871         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
4872 }
4873 void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
4874         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4875         JNIEnv *env;
4876         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4877         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
4878         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
4879         LDKFundingLocked msg_var = *msg;
4880         msg_var = FundingLocked_clone(msg);
4881         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4882         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4883         long msg_ref = (long)msg_var.inner;
4884         if (msg_var.is_owned) {
4885                 msg_ref |= 1;
4886         }
4887         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4888         CHECK(obj != NULL);
4889         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
4890 }
4891 void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown * msg) {
4892         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4893         JNIEnv *env;
4894         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4895         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
4896         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
4897         LDKShutdown msg_var = *msg;
4898         msg_var = Shutdown_clone(msg);
4899         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4900         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4901         long msg_ref = (long)msg_var.inner;
4902         if (msg_var.is_owned) {
4903                 msg_ref |= 1;
4904         }
4905         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4906         CHECK(obj != NULL);
4907         return (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, msg_ref);
4908 }
4909 void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
4910         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4911         JNIEnv *env;
4912         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4913         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
4914         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
4915         LDKClosingSigned msg_var = *msg;
4916         msg_var = ClosingSigned_clone(msg);
4917         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4918         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4919         long msg_ref = (long)msg_var.inner;
4920         if (msg_var.is_owned) {
4921                 msg_ref |= 1;
4922         }
4923         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4924         CHECK(obj != NULL);
4925         return (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
4926 }
4927 void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
4928         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4929         JNIEnv *env;
4930         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4931         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
4932         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
4933         LDKUpdateAddHTLC msg_var = *msg;
4934         msg_var = UpdateAddHTLC_clone(msg);
4935         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4936         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4937         long msg_ref = (long)msg_var.inner;
4938         if (msg_var.is_owned) {
4939                 msg_ref |= 1;
4940         }
4941         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4942         CHECK(obj != NULL);
4943         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
4944 }
4945 void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
4946         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4947         JNIEnv *env;
4948         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4949         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
4950         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
4951         LDKUpdateFulfillHTLC msg_var = *msg;
4952         msg_var = UpdateFulfillHTLC_clone(msg);
4953         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4954         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4955         long msg_ref = (long)msg_var.inner;
4956         if (msg_var.is_owned) {
4957                 msg_ref |= 1;
4958         }
4959         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4960         CHECK(obj != NULL);
4961         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
4962 }
4963 void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
4964         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4965         JNIEnv *env;
4966         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4967         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
4968         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
4969         LDKUpdateFailHTLC msg_var = *msg;
4970         msg_var = UpdateFailHTLC_clone(msg);
4971         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4972         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4973         long msg_ref = (long)msg_var.inner;
4974         if (msg_var.is_owned) {
4975                 msg_ref |= 1;
4976         }
4977         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4978         CHECK(obj != NULL);
4979         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
4980 }
4981 void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
4982         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4983         JNIEnv *env;
4984         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4985         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
4986         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
4987         LDKUpdateFailMalformedHTLC msg_var = *msg;
4988         msg_var = UpdateFailMalformedHTLC_clone(msg);
4989         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4990         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4991         long msg_ref = (long)msg_var.inner;
4992         if (msg_var.is_owned) {
4993                 msg_ref |= 1;
4994         }
4995         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4996         CHECK(obj != NULL);
4997         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
4998 }
4999 void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
5000         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5001         JNIEnv *env;
5002         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5003         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5004         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5005         LDKCommitmentSigned msg_var = *msg;
5006         msg_var = CommitmentSigned_clone(msg);
5007         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5008         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5009         long msg_ref = (long)msg_var.inner;
5010         if (msg_var.is_owned) {
5011                 msg_ref |= 1;
5012         }
5013         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5014         CHECK(obj != NULL);
5015         return (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
5016 }
5017 void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
5018         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5019         JNIEnv *env;
5020         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5021         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5022         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5023         LDKRevokeAndACK msg_var = *msg;
5024         msg_var = RevokeAndACK_clone(msg);
5025         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5026         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5027         long msg_ref = (long)msg_var.inner;
5028         if (msg_var.is_owned) {
5029                 msg_ref |= 1;
5030         }
5031         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5032         CHECK(obj != NULL);
5033         return (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
5034 }
5035 void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
5036         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5037         JNIEnv *env;
5038         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5039         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5040         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5041         LDKUpdateFee msg_var = *msg;
5042         msg_var = UpdateFee_clone(msg);
5043         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5044         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5045         long msg_ref = (long)msg_var.inner;
5046         if (msg_var.is_owned) {
5047                 msg_ref |= 1;
5048         }
5049         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5050         CHECK(obj != NULL);
5051         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
5052 }
5053 void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
5054         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5055         JNIEnv *env;
5056         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5057         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5058         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5059         LDKAnnouncementSignatures msg_var = *msg;
5060         msg_var = AnnouncementSignatures_clone(msg);
5061         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5062         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5063         long msg_ref = (long)msg_var.inner;
5064         if (msg_var.is_owned) {
5065                 msg_ref |= 1;
5066         }
5067         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5068         CHECK(obj != NULL);
5069         return (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
5070 }
5071 void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
5072         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5073         JNIEnv *env;
5074         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5075         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5076         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5077         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5078         CHECK(obj != NULL);
5079         return (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
5080 }
5081 void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
5082         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5083         JNIEnv *env;
5084         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5085         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5086         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5087         LDKInit msg_var = *msg;
5088         msg_var = Init_clone(msg);
5089         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5090         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5091         long msg_ref = (long)msg_var.inner;
5092         if (msg_var.is_owned) {
5093                 msg_ref |= 1;
5094         }
5095         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5096         CHECK(obj != NULL);
5097         return (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
5098 }
5099 void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
5100         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5101         JNIEnv *env;
5102         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5103         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5104         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5105         LDKChannelReestablish msg_var = *msg;
5106         msg_var = ChannelReestablish_clone(msg);
5107         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5108         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5109         long msg_ref = (long)msg_var.inner;
5110         if (msg_var.is_owned) {
5111                 msg_ref |= 1;
5112         }
5113         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5114         CHECK(obj != NULL);
5115         return (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
5116 }
5117 void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
5118         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5119         JNIEnv *env;
5120         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5121         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5122         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5123         LDKErrorMessage msg_var = *msg;
5124         msg_var = ErrorMessage_clone(msg);
5125         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5126         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5127         long msg_ref = (long)msg_var.inner;
5128         if (msg_var.is_owned) {
5129                 msg_ref |= 1;
5130         }
5131         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5132         CHECK(obj != NULL);
5133         return (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
5134 }
5135 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
5136         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5137         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5138         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5139         return (void*) this_arg;
5140 }
5141 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
5142         jclass c = (*env)->GetObjectClass(env, o);
5143         CHECK(c != NULL);
5144         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
5145         atomic_init(&calls->refcnt, 1);
5146         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5147         calls->o = (*env)->NewWeakGlobalRef(env, o);
5148         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
5149         CHECK(calls->handle_open_channel_meth != NULL);
5150         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
5151         CHECK(calls->handle_accept_channel_meth != NULL);
5152         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
5153         CHECK(calls->handle_funding_created_meth != NULL);
5154         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
5155         CHECK(calls->handle_funding_signed_meth != NULL);
5156         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
5157         CHECK(calls->handle_funding_locked_meth != NULL);
5158         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJ)V");
5159         CHECK(calls->handle_shutdown_meth != NULL);
5160         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
5161         CHECK(calls->handle_closing_signed_meth != NULL);
5162         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
5163         CHECK(calls->handle_update_add_htlc_meth != NULL);
5164         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
5165         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
5166         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
5167         CHECK(calls->handle_update_fail_htlc_meth != NULL);
5168         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
5169         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
5170         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
5171         CHECK(calls->handle_commitment_signed_meth != NULL);
5172         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
5173         CHECK(calls->handle_revoke_and_ack_meth != NULL);
5174         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
5175         CHECK(calls->handle_update_fee_meth != NULL);
5176         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
5177         CHECK(calls->handle_announcement_signatures_meth != NULL);
5178         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
5179         CHECK(calls->peer_disconnected_meth != NULL);
5180         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
5181         CHECK(calls->peer_connected_meth != NULL);
5182         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
5183         CHECK(calls->handle_channel_reestablish_meth != NULL);
5184         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
5185         CHECK(calls->handle_error_meth != NULL);
5186
5187         LDKChannelMessageHandler ret = {
5188                 .this_arg = (void*) calls,
5189                 .handle_open_channel = handle_open_channel_jcall,
5190                 .handle_accept_channel = handle_accept_channel_jcall,
5191                 .handle_funding_created = handle_funding_created_jcall,
5192                 .handle_funding_signed = handle_funding_signed_jcall,
5193                 .handle_funding_locked = handle_funding_locked_jcall,
5194                 .handle_shutdown = handle_shutdown_jcall,
5195                 .handle_closing_signed = handle_closing_signed_jcall,
5196                 .handle_update_add_htlc = handle_update_add_htlc_jcall,
5197                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
5198                 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
5199                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
5200                 .handle_commitment_signed = handle_commitment_signed_jcall,
5201                 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
5202                 .handle_update_fee = handle_update_fee_jcall,
5203                 .handle_announcement_signatures = handle_announcement_signatures_jcall,
5204                 .peer_disconnected = peer_disconnected_jcall,
5205                 .peer_connected = peer_connected_jcall,
5206                 .handle_channel_reestablish = handle_channel_reestablish_jcall,
5207                 .handle_error = handle_error_jcall,
5208                 .free = LDKChannelMessageHandler_JCalls_free,
5209                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
5210         };
5211         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5212         return ret;
5213 }
5214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
5215         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
5216         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
5217         return (long)res_ptr;
5218 }
5219 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) {
5220         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5221         LDKPublicKey their_node_id_ref;
5222         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5223         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5224         LDKInitFeatures their_features_conv;
5225         their_features_conv.inner = (void*)(their_features & (~1));
5226         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5227         their_features_conv = InitFeatures_clone(&their_features_conv);
5228         LDKOpenChannel msg_conv;
5229         msg_conv.inner = (void*)(msg & (~1));
5230         msg_conv.is_owned = false;
5231         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5232 }
5233
5234 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) {
5235         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5236         LDKPublicKey their_node_id_ref;
5237         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5238         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5239         LDKInitFeatures their_features_conv;
5240         their_features_conv.inner = (void*)(their_features & (~1));
5241         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5242         their_features_conv = InitFeatures_clone(&their_features_conv);
5243         LDKAcceptChannel msg_conv;
5244         msg_conv.inner = (void*)(msg & (~1));
5245         msg_conv.is_owned = false;
5246         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5247 }
5248
5249 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) {
5250         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5251         LDKPublicKey their_node_id_ref;
5252         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5253         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5254         LDKFundingCreated msg_conv;
5255         msg_conv.inner = (void*)(msg & (~1));
5256         msg_conv.is_owned = false;
5257         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5258 }
5259
5260 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) {
5261         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5262         LDKPublicKey their_node_id_ref;
5263         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5264         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5265         LDKFundingSigned msg_conv;
5266         msg_conv.inner = (void*)(msg & (~1));
5267         msg_conv.is_owned = false;
5268         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5269 }
5270
5271 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) {
5272         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5273         LDKPublicKey their_node_id_ref;
5274         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5275         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5276         LDKFundingLocked msg_conv;
5277         msg_conv.inner = (void*)(msg & (~1));
5278         msg_conv.is_owned = false;
5279         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5280 }
5281
5282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1shutdown(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
5283         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5284         LDKPublicKey their_node_id_ref;
5285         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5286         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5287         LDKShutdown msg_conv;
5288         msg_conv.inner = (void*)(msg & (~1));
5289         msg_conv.is_owned = false;
5290         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5291 }
5292
5293 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) {
5294         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5295         LDKPublicKey their_node_id_ref;
5296         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5297         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5298         LDKClosingSigned msg_conv;
5299         msg_conv.inner = (void*)(msg & (~1));
5300         msg_conv.is_owned = false;
5301         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5302 }
5303
5304 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) {
5305         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5306         LDKPublicKey their_node_id_ref;
5307         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5308         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5309         LDKUpdateAddHTLC msg_conv;
5310         msg_conv.inner = (void*)(msg & (~1));
5311         msg_conv.is_owned = false;
5312         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5313 }
5314
5315 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) {
5316         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5317         LDKPublicKey their_node_id_ref;
5318         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5319         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5320         LDKUpdateFulfillHTLC msg_conv;
5321         msg_conv.inner = (void*)(msg & (~1));
5322         msg_conv.is_owned = false;
5323         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5324 }
5325
5326 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) {
5327         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5328         LDKPublicKey their_node_id_ref;
5329         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5330         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5331         LDKUpdateFailHTLC msg_conv;
5332         msg_conv.inner = (void*)(msg & (~1));
5333         msg_conv.is_owned = false;
5334         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5335 }
5336
5337 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) {
5338         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5339         LDKPublicKey their_node_id_ref;
5340         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5341         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5342         LDKUpdateFailMalformedHTLC msg_conv;
5343         msg_conv.inner = (void*)(msg & (~1));
5344         msg_conv.is_owned = false;
5345         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5346 }
5347
5348 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) {
5349         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5350         LDKPublicKey their_node_id_ref;
5351         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5352         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5353         LDKCommitmentSigned msg_conv;
5354         msg_conv.inner = (void*)(msg & (~1));
5355         msg_conv.is_owned = false;
5356         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5357 }
5358
5359 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) {
5360         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5361         LDKPublicKey their_node_id_ref;
5362         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5363         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5364         LDKRevokeAndACK msg_conv;
5365         msg_conv.inner = (void*)(msg & (~1));
5366         msg_conv.is_owned = false;
5367         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5368 }
5369
5370 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) {
5371         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5372         LDKPublicKey their_node_id_ref;
5373         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5374         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5375         LDKUpdateFee msg_conv;
5376         msg_conv.inner = (void*)(msg & (~1));
5377         msg_conv.is_owned = false;
5378         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5379 }
5380
5381 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) {
5382         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5383         LDKPublicKey their_node_id_ref;
5384         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5385         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5386         LDKAnnouncementSignatures msg_conv;
5387         msg_conv.inner = (void*)(msg & (~1));
5388         msg_conv.is_owned = false;
5389         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5390 }
5391
5392 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) {
5393         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5394         LDKPublicKey their_node_id_ref;
5395         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5396         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5397         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
5398 }
5399
5400 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) {
5401         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5402         LDKPublicKey their_node_id_ref;
5403         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5404         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5405         LDKInit msg_conv;
5406         msg_conv.inner = (void*)(msg & (~1));
5407         msg_conv.is_owned = false;
5408         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5409 }
5410
5411 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) {
5412         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5413         LDKPublicKey their_node_id_ref;
5414         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5415         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5416         LDKChannelReestablish msg_conv;
5417         msg_conv.inner = (void*)(msg & (~1));
5418         msg_conv.is_owned = false;
5419         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5420 }
5421
5422 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) {
5423         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5424         LDKPublicKey their_node_id_ref;
5425         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5426         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5427         LDKErrorMessage msg_conv;
5428         msg_conv.inner = (void*)(msg & (~1));
5429         msg_conv.is_owned = false;
5430         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5431 }
5432
5433 typedef struct LDKRoutingMessageHandler_JCalls {
5434         atomic_size_t refcnt;
5435         JavaVM *vm;
5436         jweak o;
5437         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5438         jmethodID handle_node_announcement_meth;
5439         jmethodID handle_channel_announcement_meth;
5440         jmethodID handle_channel_update_meth;
5441         jmethodID handle_htlc_fail_channel_update_meth;
5442         jmethodID get_next_channel_announcements_meth;
5443         jmethodID get_next_node_announcements_meth;
5444         jmethodID sync_routing_table_meth;
5445         jmethodID handle_reply_channel_range_meth;
5446         jmethodID handle_reply_short_channel_ids_end_meth;
5447         jmethodID handle_query_channel_range_meth;
5448         jmethodID handle_query_short_channel_ids_meth;
5449 } LDKRoutingMessageHandler_JCalls;
5450 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
5451         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5452         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5453                 JNIEnv *env;
5454                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5455                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5456                 FREE(j_calls);
5457         }
5458 }
5459 LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
5460         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5461         JNIEnv *env;
5462         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5463         LDKNodeAnnouncement msg_var = *msg;
5464         msg_var = NodeAnnouncement_clone(msg);
5465         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5466         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5467         long msg_ref = (long)msg_var.inner;
5468         if (msg_var.is_owned) {
5469                 msg_ref |= 1;
5470         }
5471         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5472         CHECK(obj != NULL);
5473         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
5474         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5475         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
5476         return ret_conv;
5477 }
5478 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
5479         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5480         JNIEnv *env;
5481         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5482         LDKChannelAnnouncement msg_var = *msg;
5483         msg_var = ChannelAnnouncement_clone(msg);
5484         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5485         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5486         long msg_ref = (long)msg_var.inner;
5487         if (msg_var.is_owned) {
5488                 msg_ref |= 1;
5489         }
5490         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5491         CHECK(obj != NULL);
5492         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
5493         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5494         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
5495         return ret_conv;
5496 }
5497 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
5498         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5499         JNIEnv *env;
5500         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5501         LDKChannelUpdate msg_var = *msg;
5502         msg_var = ChannelUpdate_clone(msg);
5503         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5504         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5505         long msg_ref = (long)msg_var.inner;
5506         if (msg_var.is_owned) {
5507                 msg_ref |= 1;
5508         }
5509         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5510         CHECK(obj != NULL);
5511         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
5512         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5513         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
5514         return ret_conv;
5515 }
5516 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
5517         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5518         JNIEnv *env;
5519         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5520         long ret_update = (long)update;
5521         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5522         CHECK(obj != NULL);
5523         return (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
5524 }
5525 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
5526         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5527         JNIEnv *env;
5528         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5529         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5530         CHECK(obj != NULL);
5531         int64_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
5532         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ arg_constr;
5533         arg_constr.datalen = (*env)->GetArrayLength(env, arg);
5534         if (arg_constr.datalen > 0)
5535                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
5536         else
5537                 arg_constr.data = NULL;
5538         int64_t* arg_vals = (*env)->GetLongArrayElements (env, arg, NULL);
5539         for (size_t l = 0; l < arg_constr.datalen; l++) {
5540                 int64_t arr_conv_63 = arg_vals[l];
5541                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_conv_63) & ~1);
5542                 FREE((void*)arr_conv_63);
5543                 arg_constr.data[l] = arr_conv_63_conv;
5544         }
5545         (*env)->ReleaseLongArrayElements(env, arg, arg_vals, 0);
5546         return arg_constr;
5547 }
5548 LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
5549         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5550         JNIEnv *env;
5551         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5552         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
5553         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
5554         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5555         CHECK(obj != NULL);
5556         int64_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
5557         LDKCVec_NodeAnnouncementZ arg_constr;
5558         arg_constr.datalen = (*env)->GetArrayLength(env, arg);
5559         if (arg_constr.datalen > 0)
5560                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
5561         else
5562                 arg_constr.data = NULL;
5563         int64_t* arg_vals = (*env)->GetLongArrayElements (env, arg, NULL);
5564         for (size_t s = 0; s < arg_constr.datalen; s++) {
5565                 int64_t arr_conv_18 = arg_vals[s];
5566                 LDKNodeAnnouncement arr_conv_18_conv;
5567                 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
5568                 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
5569                 arr_conv_18_conv = NodeAnnouncement_clone(&arr_conv_18_conv);
5570                 arg_constr.data[s] = arr_conv_18_conv;
5571         }
5572         (*env)->ReleaseLongArrayElements(env, arg, arg_vals, 0);
5573         return arg_constr;
5574 }
5575 void sync_routing_table_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
5576         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5577         JNIEnv *env;
5578         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5579         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5580         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5581         LDKInit init_var = *init;
5582         init_var = Init_clone(init);
5583         CHECK((((long)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5584         CHECK((((long)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5585         long init_ref = (long)init_var.inner;
5586         if (init_var.is_owned) {
5587                 init_ref |= 1;
5588         }
5589         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5590         CHECK(obj != NULL);
5591         return (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
5592 }
5593 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
5594         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5595         JNIEnv *env;
5596         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5597         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5598         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5599         LDKReplyChannelRange msg_var = msg;
5600         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5601         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5602         long msg_ref = (long)msg_var.inner;
5603         if (msg_var.is_owned) {
5604                 msg_ref |= 1;
5605         }
5606         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5607         CHECK(obj != NULL);
5608         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
5609         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5610         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
5611         return ret_conv;
5612 }
5613 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
5614         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5615         JNIEnv *env;
5616         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5617         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5618         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5619         LDKReplyShortChannelIdsEnd msg_var = msg;
5620         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5621         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5622         long msg_ref = (long)msg_var.inner;
5623         if (msg_var.is_owned) {
5624                 msg_ref |= 1;
5625         }
5626         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5627         CHECK(obj != NULL);
5628         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
5629         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5630         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
5631         return ret_conv;
5632 }
5633 LDKCResult_NoneLightningErrorZ handle_query_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
5634         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5635         JNIEnv *env;
5636         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5637         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5638         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5639         LDKQueryChannelRange msg_var = msg;
5640         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5641         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5642         long msg_ref = (long)msg_var.inner;
5643         if (msg_var.is_owned) {
5644                 msg_ref |= 1;
5645         }
5646         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5647         CHECK(obj != NULL);
5648         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
5649         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5650         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
5651         return ret_conv;
5652 }
5653 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
5654         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5655         JNIEnv *env;
5656         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5657         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5658         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5659         LDKQueryShortChannelIds msg_var = msg;
5660         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5661         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5662         long msg_ref = (long)msg_var.inner;
5663         if (msg_var.is_owned) {
5664                 msg_ref |= 1;
5665         }
5666         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5667         CHECK(obj != NULL);
5668         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
5669         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5670         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
5671         return ret_conv;
5672 }
5673 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
5674         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5675         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5676         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5677         return (void*) this_arg;
5678 }
5679 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
5680         jclass c = (*env)->GetObjectClass(env, o);
5681         CHECK(c != NULL);
5682         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
5683         atomic_init(&calls->refcnt, 1);
5684         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5685         calls->o = (*env)->NewWeakGlobalRef(env, o);
5686         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
5687         CHECK(calls->handle_node_announcement_meth != NULL);
5688         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
5689         CHECK(calls->handle_channel_announcement_meth != NULL);
5690         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
5691         CHECK(calls->handle_channel_update_meth != NULL);
5692         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
5693         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
5694         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
5695         CHECK(calls->get_next_channel_announcements_meth != NULL);
5696         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
5697         CHECK(calls->get_next_node_announcements_meth != NULL);
5698         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
5699         CHECK(calls->sync_routing_table_meth != NULL);
5700         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
5701         CHECK(calls->handle_reply_channel_range_meth != NULL);
5702         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
5703         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
5704         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
5705         CHECK(calls->handle_query_channel_range_meth != NULL);
5706         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
5707         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
5708
5709         LDKRoutingMessageHandler ret = {
5710                 .this_arg = (void*) calls,
5711                 .handle_node_announcement = handle_node_announcement_jcall,
5712                 .handle_channel_announcement = handle_channel_announcement_jcall,
5713                 .handle_channel_update = handle_channel_update_jcall,
5714                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
5715                 .get_next_channel_announcements = get_next_channel_announcements_jcall,
5716                 .get_next_node_announcements = get_next_node_announcements_jcall,
5717                 .sync_routing_table = sync_routing_table_jcall,
5718                 .handle_reply_channel_range = handle_reply_channel_range_jcall,
5719                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_jcall,
5720                 .handle_query_channel_range = handle_query_channel_range_jcall,
5721                 .handle_query_short_channel_ids = handle_query_short_channel_ids_jcall,
5722                 .free = LDKRoutingMessageHandler_JCalls_free,
5723                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
5724         };
5725         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5726         return ret;
5727 }
5728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
5729         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
5730         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
5731         return (long)res_ptr;
5732 }
5733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
5734         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
5735         LDKNodeAnnouncement msg_conv;
5736         msg_conv.inner = (void*)(msg & (~1));
5737         msg_conv.is_owned = false;
5738         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5739         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
5740         return (long)ret_conv;
5741 }
5742
5743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
5744         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
5745         LDKChannelAnnouncement msg_conv;
5746         msg_conv.inner = (void*)(msg & (~1));
5747         msg_conv.is_owned = false;
5748         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5749         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
5750         return (long)ret_conv;
5751 }
5752
5753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
5754         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
5755         LDKChannelUpdate msg_conv;
5756         msg_conv.inner = (void*)(msg & (~1));
5757         msg_conv.is_owned = false;
5758         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5759         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
5760         return (long)ret_conv;
5761 }
5762
5763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1htlc_1fail_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t update) {
5764         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
5765         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
5766         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
5767 }
5768
5769 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) {
5770         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
5771         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
5772         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5773         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5774         for (size_t l = 0; l < ret_var.datalen; l++) {
5775                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arr_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5776                 *arr_conv_63_ref = ret_var.data[l];
5777                 ret_arr_ptr[l] = (long)arr_conv_63_ref;
5778         }
5779         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5780         FREE(ret_var.data);
5781         return ret_arr;
5782 }
5783
5784 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) {
5785         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
5786         LDKPublicKey starting_point_ref;
5787         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
5788         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
5789         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
5790         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5791         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5792         for (size_t s = 0; s < ret_var.datalen; s++) {
5793                 LDKNodeAnnouncement arr_conv_18_var = ret_var.data[s];
5794                 CHECK((((long)arr_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5795                 CHECK((((long)&arr_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5796                 long arr_conv_18_ref = (long)arr_conv_18_var.inner;
5797                 if (arr_conv_18_var.is_owned) {
5798                         arr_conv_18_ref |= 1;
5799                 }
5800                 ret_arr_ptr[s] = arr_conv_18_ref;
5801         }
5802         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5803         FREE(ret_var.data);
5804         return ret_arr;
5805 }
5806
5807 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) {
5808         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
5809         LDKPublicKey their_node_id_ref;
5810         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5811         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5812         LDKInit init_conv;
5813         init_conv.inner = (void*)(init & (~1));
5814         init_conv.is_owned = false;
5815         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
5816 }
5817
5818 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) {
5819         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
5820         LDKPublicKey their_node_id_ref;
5821         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5822         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5823         LDKReplyChannelRange msg_conv;
5824         msg_conv.inner = (void*)(msg & (~1));
5825         msg_conv.is_owned = (msg & 1) || (msg == 0);
5826         msg_conv = ReplyChannelRange_clone(&msg_conv);
5827         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5828         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5829         return (long)ret_conv;
5830 }
5831
5832 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) {
5833         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
5834         LDKPublicKey their_node_id_ref;
5835         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5836         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5837         LDKReplyShortChannelIdsEnd msg_conv;
5838         msg_conv.inner = (void*)(msg & (~1));
5839         msg_conv.is_owned = (msg & 1) || (msg == 0);
5840         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
5841         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5842         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5843         return (long)ret_conv;
5844 }
5845
5846 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) {
5847         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
5848         LDKPublicKey their_node_id_ref;
5849         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5850         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5851         LDKQueryChannelRange msg_conv;
5852         msg_conv.inner = (void*)(msg & (~1));
5853         msg_conv.is_owned = (msg & 1) || (msg == 0);
5854         msg_conv = QueryChannelRange_clone(&msg_conv);
5855         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5856         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5857         return (long)ret_conv;
5858 }
5859
5860 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) {
5861         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
5862         LDKPublicKey their_node_id_ref;
5863         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5864         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5865         LDKQueryShortChannelIds msg_conv;
5866         msg_conv.inner = (void*)(msg & (~1));
5867         msg_conv.is_owned = (msg & 1) || (msg == 0);
5868         msg_conv = QueryShortChannelIds_clone(&msg_conv);
5869         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5870         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5871         return (long)ret_conv;
5872 }
5873
5874 typedef struct LDKSocketDescriptor_JCalls {
5875         atomic_size_t refcnt;
5876         JavaVM *vm;
5877         jweak o;
5878         jmethodID send_data_meth;
5879         jmethodID disconnect_socket_meth;
5880         jmethodID eq_meth;
5881         jmethodID hash_meth;
5882 } LDKSocketDescriptor_JCalls;
5883 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
5884         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5885         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5886                 JNIEnv *env;
5887                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5888                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5889                 FREE(j_calls);
5890         }
5891 }
5892 uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
5893         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5894         JNIEnv *env;
5895         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5896         LDKu8slice data_var = data;
5897         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
5898         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
5899         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5900         CHECK(obj != NULL);
5901         return (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
5902 }
5903 void disconnect_socket_jcall(void* this_arg) {
5904         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5905         JNIEnv *env;
5906         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5907         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5908         CHECK(obj != NULL);
5909         return (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
5910 }
5911 bool eq_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
5912         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5913         JNIEnv *env;
5914         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5915         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
5916         *other_arg_clone = SocketDescriptor_clone(other_arg);
5917         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5918         CHECK(obj != NULL);
5919         return (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (long)other_arg_clone);
5920 }
5921 uint64_t hash_jcall(const void* this_arg) {
5922         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5923         JNIEnv *env;
5924         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5925         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5926         CHECK(obj != NULL);
5927         return (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
5928 }
5929 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
5930         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5931         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5932         return (void*) this_arg;
5933 }
5934 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
5935         jclass c = (*env)->GetObjectClass(env, o);
5936         CHECK(c != NULL);
5937         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
5938         atomic_init(&calls->refcnt, 1);
5939         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5940         calls->o = (*env)->NewWeakGlobalRef(env, o);
5941         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
5942         CHECK(calls->send_data_meth != NULL);
5943         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
5944         CHECK(calls->disconnect_socket_meth != NULL);
5945         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
5946         CHECK(calls->eq_meth != NULL);
5947         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
5948         CHECK(calls->hash_meth != NULL);
5949
5950         LDKSocketDescriptor ret = {
5951                 .this_arg = (void*) calls,
5952                 .send_data = send_data_jcall,
5953                 .disconnect_socket = disconnect_socket_jcall,
5954                 .eq = eq_jcall,
5955                 .hash = hash_jcall,
5956                 .clone = LDKSocketDescriptor_JCalls_clone,
5957                 .free = LDKSocketDescriptor_JCalls_free,
5958         };
5959         return ret;
5960 }
5961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
5962         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
5963         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
5964         return (long)res_ptr;
5965 }
5966 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) {
5967         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
5968         LDKu8slice data_ref;
5969         data_ref.datalen = (*env)->GetArrayLength(env, data);
5970         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
5971         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
5972         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
5973         return ret_val;
5974 }
5975
5976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
5977         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
5978         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
5979 }
5980
5981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
5982         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
5983         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
5984         return ret_val;
5985 }
5986
5987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
5988         LDKTransaction _res_ref;
5989         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
5990         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
5991         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
5992         _res_ref.data_is_owned = true;
5993         Transaction_free(_res_ref);
5994 }
5995
5996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
5997         if ((_res & 1) != 0) return;
5998         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
5999         FREE((void*)_res);
6000         TxOut_free(_res_conv);
6001 }
6002
6003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6004         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
6005         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6006         *ret_ref = TxOut_clone(orig_conv);
6007         return (long)ret_ref;
6008 }
6009
6010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
6011         LDKSecretKey o_ref;
6012         CHECK((*env)->GetArrayLength(env, o) == 32);
6013         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
6014         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6015         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
6016         return (long)ret_conv;
6017 }
6018
6019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6020         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6021         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6022         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
6023         return (long)ret_conv;
6024 }
6025
6026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6027         if ((_res & 1) != 0) return;
6028         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
6029         FREE((void*)_res);
6030         CResult_SecretKeyErrorZ_free(_res_conv);
6031 }
6032
6033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
6034         LDKPublicKey o_ref;
6035         CHECK((*env)->GetArrayLength(env, o) == 33);
6036         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
6037         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6038         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
6039         return (long)ret_conv;
6040 }
6041
6042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6043         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6044         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6045         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
6046         return (long)ret_conv;
6047 }
6048
6049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6050         if ((_res & 1) != 0) return;
6051         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
6052         FREE((void*)_res);
6053         CResult_PublicKeyErrorZ_free(_res_conv);
6054 }
6055
6056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6057         LDKTxCreationKeys o_conv;
6058         o_conv.inner = (void*)(o & (~1));
6059         o_conv.is_owned = (o & 1) || (o == 0);
6060         o_conv = TxCreationKeys_clone(&o_conv);
6061         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6062         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
6063         return (long)ret_conv;
6064 }
6065
6066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6067         LDKDecodeError e_conv;
6068         e_conv.inner = (void*)(e & (~1));
6069         e_conv.is_owned = (e & 1) || (e == 0);
6070         e_conv = DecodeError_clone(&e_conv);
6071         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6072         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
6073         return (long)ret_conv;
6074 }
6075
6076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6077         if ((_res & 1) != 0) return;
6078         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6079         FREE((void*)_res);
6080         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
6081 }
6082
6083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6084         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
6085         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6086         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
6087         return (long)ret_conv;
6088 }
6089
6090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6091         LDKChannelPublicKeys o_conv;
6092         o_conv.inner = (void*)(o & (~1));
6093         o_conv.is_owned = (o & 1) || (o == 0);
6094         o_conv = ChannelPublicKeys_clone(&o_conv);
6095         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6096         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
6097         return (long)ret_conv;
6098 }
6099
6100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6101         LDKDecodeError e_conv;
6102         e_conv.inner = (void*)(e & (~1));
6103         e_conv.is_owned = (e & 1) || (e == 0);
6104         e_conv = DecodeError_clone(&e_conv);
6105         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6106         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
6107         return (long)ret_conv;
6108 }
6109
6110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6111         if ((_res & 1) != 0) return;
6112         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6113         FREE((void*)_res);
6114         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
6115 }
6116
6117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6118         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
6119         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6120         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
6121         return (long)ret_conv;
6122 }
6123
6124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6125         LDKTxCreationKeys o_conv;
6126         o_conv.inner = (void*)(o & (~1));
6127         o_conv.is_owned = (o & 1) || (o == 0);
6128         o_conv = TxCreationKeys_clone(&o_conv);
6129         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6130         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
6131         return (long)ret_conv;
6132 }
6133
6134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6135         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6136         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6137         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
6138         return (long)ret_conv;
6139 }
6140
6141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6142         if ((_res & 1) != 0) return;
6143         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
6144         FREE((void*)_res);
6145         CResult_TxCreationKeysErrorZ_free(_res_conv);
6146 }
6147
6148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6149         LDKHTLCOutputInCommitment o_conv;
6150         o_conv.inner = (void*)(o & (~1));
6151         o_conv.is_owned = (o & 1) || (o == 0);
6152         o_conv = HTLCOutputInCommitment_clone(&o_conv);
6153         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6154         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
6155         return (long)ret_conv;
6156 }
6157
6158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6159         LDKDecodeError e_conv;
6160         e_conv.inner = (void*)(e & (~1));
6161         e_conv.is_owned = (e & 1) || (e == 0);
6162         e_conv = DecodeError_clone(&e_conv);
6163         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6164         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
6165         return (long)ret_conv;
6166 }
6167
6168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6169         if ((_res & 1) != 0) return;
6170         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
6171         FREE((void*)_res);
6172         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
6173 }
6174
6175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6176         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
6177         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6178         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
6179         return (long)ret_conv;
6180 }
6181
6182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6183         LDKCounterpartyChannelTransactionParameters o_conv;
6184         o_conv.inner = (void*)(o & (~1));
6185         o_conv.is_owned = (o & 1) || (o == 0);
6186         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
6187         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6188         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6189         return (long)ret_conv;
6190 }
6191
6192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6193         LDKDecodeError e_conv;
6194         e_conv.inner = (void*)(e & (~1));
6195         e_conv.is_owned = (e & 1) || (e == 0);
6196         e_conv = DecodeError_clone(&e_conv);
6197         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6198         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
6199         return (long)ret_conv;
6200 }
6201
6202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6203         if ((_res & 1) != 0) return;
6204         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6205         FREE((void*)_res);
6206         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6207 }
6208
6209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6210         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6211         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6212         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6213         return (long)ret_conv;
6214 }
6215
6216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6217         LDKChannelTransactionParameters o_conv;
6218         o_conv.inner = (void*)(o & (~1));
6219         o_conv.is_owned = (o & 1) || (o == 0);
6220         o_conv = ChannelTransactionParameters_clone(&o_conv);
6221         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6222         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6223         return (long)ret_conv;
6224 }
6225
6226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6227         LDKDecodeError e_conv;
6228         e_conv.inner = (void*)(e & (~1));
6229         e_conv.is_owned = (e & 1) || (e == 0);
6230         e_conv = DecodeError_clone(&e_conv);
6231         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6232         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
6233         return (long)ret_conv;
6234 }
6235
6236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6237         if ((_res & 1) != 0) return;
6238         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6239         FREE((void*)_res);
6240         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6241 }
6242
6243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6244         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6245         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6246         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6247         return (long)ret_conv;
6248 }
6249
6250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
6251         LDKCVec_SignatureZ _res_constr;
6252         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
6253         if (_res_constr.datalen > 0)
6254                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6255         else
6256                 _res_constr.data = NULL;
6257         for (size_t i = 0; i < _res_constr.datalen; i++) {
6258                 int8_tArray arr_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
6259                 LDKSignature arr_conv_8_ref;
6260                 CHECK((*env)->GetArrayLength(env, arr_conv_8) == 64);
6261                 (*env)->GetByteArrayRegion(env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
6262                 _res_constr.data[i] = arr_conv_8_ref;
6263         }
6264         CVec_SignatureZ_free(_res_constr);
6265 }
6266
6267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6268         LDKHolderCommitmentTransaction o_conv;
6269         o_conv.inner = (void*)(o & (~1));
6270         o_conv.is_owned = (o & 1) || (o == 0);
6271         o_conv = HolderCommitmentTransaction_clone(&o_conv);
6272         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6273         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
6274         return (long)ret_conv;
6275 }
6276
6277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6278         LDKDecodeError e_conv;
6279         e_conv.inner = (void*)(e & (~1));
6280         e_conv.is_owned = (e & 1) || (e == 0);
6281         e_conv = DecodeError_clone(&e_conv);
6282         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6283         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
6284         return (long)ret_conv;
6285 }
6286
6287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6288         if ((_res & 1) != 0) return;
6289         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6290         FREE((void*)_res);
6291         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
6292 }
6293
6294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6295         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6296         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6297         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6298         return (long)ret_conv;
6299 }
6300
6301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6302         LDKBuiltCommitmentTransaction o_conv;
6303         o_conv.inner = (void*)(o & (~1));
6304         o_conv.is_owned = (o & 1) || (o == 0);
6305         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
6306         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6307         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
6308         return (long)ret_conv;
6309 }
6310
6311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6312         LDKDecodeError e_conv;
6313         e_conv.inner = (void*)(e & (~1));
6314         e_conv.is_owned = (e & 1) || (e == 0);
6315         e_conv = DecodeError_clone(&e_conv);
6316         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6317         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
6318         return (long)ret_conv;
6319 }
6320
6321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6322         if ((_res & 1) != 0) return;
6323         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6324         FREE((void*)_res);
6325         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
6326 }
6327
6328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6329         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6330         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6331         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6332         return (long)ret_conv;
6333 }
6334
6335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6336         LDKCommitmentTransaction o_conv;
6337         o_conv.inner = (void*)(o & (~1));
6338         o_conv.is_owned = (o & 1) || (o == 0);
6339         o_conv = CommitmentTransaction_clone(&o_conv);
6340         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6341         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
6342         return (long)ret_conv;
6343 }
6344
6345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6346         LDKDecodeError e_conv;
6347         e_conv.inner = (void*)(e & (~1));
6348         e_conv.is_owned = (e & 1) || (e == 0);
6349         e_conv = DecodeError_clone(&e_conv);
6350         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6351         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
6352         return (long)ret_conv;
6353 }
6354
6355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6356         if ((_res & 1) != 0) return;
6357         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6358         FREE((void*)_res);
6359         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
6360 }
6361
6362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6363         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
6364         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6365         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
6366         return (long)ret_conv;
6367 }
6368
6369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6370         LDKTrustedCommitmentTransaction o_conv;
6371         o_conv.inner = (void*)(o & (~1));
6372         o_conv.is_owned = (o & 1) || (o == 0);
6373         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
6374         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6375         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
6376         return (long)ret_conv;
6377 }
6378
6379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
6380         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6381         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
6382         return (long)ret_conv;
6383 }
6384
6385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6386         if ((_res & 1) != 0) return;
6387         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
6388         FREE((void*)_res);
6389         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
6390 }
6391
6392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
6393         LDKCVec_SignatureZ o_constr;
6394         o_constr.datalen = (*env)->GetArrayLength(env, o);
6395         if (o_constr.datalen > 0)
6396                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6397         else
6398                 o_constr.data = NULL;
6399         for (size_t i = 0; i < o_constr.datalen; i++) {
6400                 int8_tArray arr_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
6401                 LDKSignature arr_conv_8_ref;
6402                 CHECK((*env)->GetArrayLength(env, arr_conv_8) == 64);
6403                 (*env)->GetByteArrayRegion(env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
6404                 o_constr.data[i] = arr_conv_8_ref;
6405         }
6406         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6407         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
6408         return (long)ret_conv;
6409 }
6410
6411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
6412         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6413         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
6414         return (long)ret_conv;
6415 }
6416
6417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6418         if ((_res & 1) != 0) return;
6419         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
6420         FREE((void*)_res);
6421         CResult_CVec_SignatureZNoneZ_free(_res_conv);
6422 }
6423
6424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6425         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
6426         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6427         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
6428         return (long)ret_conv;
6429 }
6430
6431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
6432         LDKCVec_PublicKeyZ _res_constr;
6433         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
6434         if (_res_constr.datalen > 0)
6435                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
6436         else
6437                 _res_constr.data = NULL;
6438         for (size_t i = 0; i < _res_constr.datalen; i++) {
6439                 int8_tArray arr_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
6440                 LDKPublicKey arr_conv_8_ref;
6441                 CHECK((*env)->GetArrayLength(env, arr_conv_8) == 33);
6442                 (*env)->GetByteArrayRegion(env, arr_conv_8, 0, 33, arr_conv_8_ref.compressed_form);
6443                 _res_constr.data[i] = arr_conv_8_ref;
6444         }
6445         CVec_PublicKeyZ_free(_res_constr);
6446 }
6447
6448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
6449         LDKCVec_u8Z _res_ref;
6450         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
6451         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
6452         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
6453         CVec_u8Z_free(_res_ref);
6454 }
6455
6456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
6457         LDKCVec_u8Z o_ref;
6458         o_ref.datalen = (*env)->GetArrayLength(env, o);
6459         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
6460         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
6461         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
6462         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
6463         return (long)ret_conv;
6464 }
6465
6466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6467         LDKPeerHandleError e_conv;
6468         e_conv.inner = (void*)(e & (~1));
6469         e_conv.is_owned = (e & 1) || (e == 0);
6470         e_conv = PeerHandleError_clone(&e_conv);
6471         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
6472         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
6473         return (long)ret_conv;
6474 }
6475
6476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6477         if ((_res & 1) != 0) return;
6478         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
6479         FREE((void*)_res);
6480         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
6481 }
6482
6483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6484         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
6485         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
6486         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
6487         return (long)ret_conv;
6488 }
6489
6490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
6491         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
6492         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
6493         return (long)ret_conv;
6494 }
6495
6496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6497         LDKPeerHandleError e_conv;
6498         e_conv.inner = (void*)(e & (~1));
6499         e_conv.is_owned = (e & 1) || (e == 0);
6500         e_conv = PeerHandleError_clone(&e_conv);
6501         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
6502         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
6503         return (long)ret_conv;
6504 }
6505
6506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6507         if ((_res & 1) != 0) return;
6508         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
6509         FREE((void*)_res);
6510         CResult_NonePeerHandleErrorZ_free(_res_conv);
6511 }
6512
6513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6514         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
6515         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
6516         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
6517         return (long)ret_conv;
6518 }
6519
6520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
6521         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
6522         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
6523         return (long)ret_conv;
6524 }
6525
6526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6527         LDKPeerHandleError e_conv;
6528         e_conv.inner = (void*)(e & (~1));
6529         e_conv.is_owned = (e & 1) || (e == 0);
6530         e_conv = PeerHandleError_clone(&e_conv);
6531         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
6532         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
6533         return (long)ret_conv;
6534 }
6535
6536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6537         if ((_res & 1) != 0) return;
6538         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
6539         FREE((void*)_res);
6540         CResult_boolPeerHandleErrorZ_free(_res_conv);
6541 }
6542
6543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6544         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
6545         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
6546         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
6547         return (long)ret_conv;
6548 }
6549
6550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6551         LDKInitFeatures o_conv;
6552         o_conv.inner = (void*)(o & (~1));
6553         o_conv.is_owned = (o & 1) || (o == 0);
6554         o_conv = InitFeatures_clone(&o_conv);
6555         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
6556         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
6557         return (long)ret_conv;
6558 }
6559
6560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6561         LDKDecodeError e_conv;
6562         e_conv.inner = (void*)(e & (~1));
6563         e_conv.is_owned = (e & 1) || (e == 0);
6564         e_conv = DecodeError_clone(&e_conv);
6565         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
6566         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
6567         return (long)ret_conv;
6568 }
6569
6570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6571         if ((_res & 1) != 0) return;
6572         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6573         FREE((void*)_res);
6574         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
6575 }
6576
6577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6578         LDKNodeFeatures o_conv;
6579         o_conv.inner = (void*)(o & (~1));
6580         o_conv.is_owned = (o & 1) || (o == 0);
6581         o_conv = NodeFeatures_clone(&o_conv);
6582         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
6583         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
6584         return (long)ret_conv;
6585 }
6586
6587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6588         LDKDecodeError e_conv;
6589         e_conv.inner = (void*)(e & (~1));
6590         e_conv.is_owned = (e & 1) || (e == 0);
6591         e_conv = DecodeError_clone(&e_conv);
6592         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
6593         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
6594         return (long)ret_conv;
6595 }
6596
6597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6598         if ((_res & 1) != 0) return;
6599         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6600         FREE((void*)_res);
6601         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
6602 }
6603
6604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6605         LDKChannelFeatures o_conv;
6606         o_conv.inner = (void*)(o & (~1));
6607         o_conv.is_owned = (o & 1) || (o == 0);
6608         o_conv = ChannelFeatures_clone(&o_conv);
6609         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
6610         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
6611         return (long)ret_conv;
6612 }
6613
6614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6615         LDKDecodeError e_conv;
6616         e_conv.inner = (void*)(e & (~1));
6617         e_conv.is_owned = (e & 1) || (e == 0);
6618         e_conv = DecodeError_clone(&e_conv);
6619         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
6620         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
6621         return (long)ret_conv;
6622 }
6623
6624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6625         if ((_res & 1) != 0) return;
6626         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6627         FREE((void*)_res);
6628         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
6629 }
6630
6631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6632         LDKChannelConfig o_conv;
6633         o_conv.inner = (void*)(o & (~1));
6634         o_conv.is_owned = (o & 1) || (o == 0);
6635         o_conv = ChannelConfig_clone(&o_conv);
6636         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6637         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
6638         return (long)ret_conv;
6639 }
6640
6641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6642         LDKDecodeError e_conv;
6643         e_conv.inner = (void*)(e & (~1));
6644         e_conv.is_owned = (e & 1) || (e == 0);
6645         e_conv = DecodeError_clone(&e_conv);
6646         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6647         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
6648         return (long)ret_conv;
6649 }
6650
6651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6652         if ((_res & 1) != 0) return;
6653         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
6654         FREE((void*)_res);
6655         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
6656 }
6657
6658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6659         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
6660         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6661         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
6662         return (long)ret_conv;
6663 }
6664
6665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
6666         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6667         *ret_conv = CResult_boolLightningErrorZ_ok(o);
6668         return (long)ret_conv;
6669 }
6670
6671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6672         LDKLightningError e_conv;
6673         e_conv.inner = (void*)(e & (~1));
6674         e_conv.is_owned = (e & 1) || (e == 0);
6675         e_conv = LightningError_clone(&e_conv);
6676         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6677         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
6678         return (long)ret_conv;
6679 }
6680
6681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6682         if ((_res & 1) != 0) return;
6683         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
6684         FREE((void*)_res);
6685         CResult_boolLightningErrorZ_free(_res_conv);
6686 }
6687
6688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6689         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
6690         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6691         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
6692         return (long)ret_conv;
6693 }
6694
6695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6696         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
6697         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6698         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
6699         return (long)ret_ref;
6700 }
6701
6702 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) {
6703         LDKChannelAnnouncement a_conv;
6704         a_conv.inner = (void*)(a & (~1));
6705         a_conv.is_owned = (a & 1) || (a == 0);
6706         a_conv = ChannelAnnouncement_clone(&a_conv);
6707         LDKChannelUpdate b_conv;
6708         b_conv.inner = (void*)(b & (~1));
6709         b_conv.is_owned = (b & 1) || (b == 0);
6710         b_conv = ChannelUpdate_clone(&b_conv);
6711         LDKChannelUpdate c_conv;
6712         c_conv.inner = (void*)(c & (~1));
6713         c_conv.is_owned = (c & 1) || (c == 0);
6714         c_conv = ChannelUpdate_clone(&c_conv);
6715         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6716         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
6717         return (long)ret_ref;
6718 }
6719
6720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6721         if ((_res & 1) != 0) return;
6722         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
6723         FREE((void*)_res);
6724         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
6725 }
6726
6727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
6728         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
6729         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
6730         if (_res_constr.datalen > 0)
6731                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
6732         else
6733                 _res_constr.data = NULL;
6734         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
6735         for (size_t l = 0; l < _res_constr.datalen; l++) {
6736                 int64_t arr_conv_63 = _res_vals[l];
6737                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_conv_63) & ~1);
6738                 FREE((void*)arr_conv_63);
6739                 _res_constr.data[l] = arr_conv_63_conv;
6740         }
6741         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
6742         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
6743 }
6744
6745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
6746         LDKCVec_NodeAnnouncementZ _res_constr;
6747         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
6748         if (_res_constr.datalen > 0)
6749                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
6750         else
6751                 _res_constr.data = NULL;
6752         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
6753         for (size_t s = 0; s < _res_constr.datalen; s++) {
6754                 int64_t arr_conv_18 = _res_vals[s];
6755                 LDKNodeAnnouncement arr_conv_18_conv;
6756                 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
6757                 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
6758                 _res_constr.data[s] = arr_conv_18_conv;
6759         }
6760         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
6761         CVec_NodeAnnouncementZ_free(_res_constr);
6762 }
6763
6764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
6765         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6766         *ret_conv = CResult_NoneLightningErrorZ_ok();
6767         return (long)ret_conv;
6768 }
6769
6770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6771         LDKLightningError e_conv;
6772         e_conv.inner = (void*)(e & (~1));
6773         e_conv.is_owned = (e & 1) || (e == 0);
6774         e_conv = LightningError_clone(&e_conv);
6775         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6776         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
6777         return (long)ret_conv;
6778 }
6779
6780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6781         if ((_res & 1) != 0) return;
6782         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
6783         FREE((void*)_res);
6784         CResult_NoneLightningErrorZ_free(_res_conv);
6785 }
6786
6787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6788         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
6789         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6790         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
6791         return (long)ret_conv;
6792 }
6793
6794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
6795         LDKCVec_MessageSendEventZ _res_constr;
6796         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
6797         if (_res_constr.datalen > 0)
6798                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
6799         else
6800                 _res_constr.data = NULL;
6801         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
6802         for (size_t s = 0; s < _res_constr.datalen; s++) {
6803                 int64_t arr_conv_18 = _res_vals[s];
6804                 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_conv_18) & ~1);
6805                 FREE((void*)arr_conv_18);
6806                 _res_constr.data[s] = arr_conv_18_conv;
6807         }
6808         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
6809         CVec_MessageSendEventZ_free(_res_constr);
6810 }
6811
6812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6813         LDKDirectionalChannelInfo o_conv;
6814         o_conv.inner = (void*)(o & (~1));
6815         o_conv.is_owned = (o & 1) || (o == 0);
6816         o_conv = DirectionalChannelInfo_clone(&o_conv);
6817         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
6818         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
6819         return (long)ret_conv;
6820 }
6821
6822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6823         LDKDecodeError e_conv;
6824         e_conv.inner = (void*)(e & (~1));
6825         e_conv.is_owned = (e & 1) || (e == 0);
6826         e_conv = DecodeError_clone(&e_conv);
6827         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
6828         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
6829         return (long)ret_conv;
6830 }
6831
6832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6833         if ((_res & 1) != 0) return;
6834         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6835         FREE((void*)_res);
6836         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
6837 }
6838
6839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6840         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
6841         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
6842         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
6843         return (long)ret_conv;
6844 }
6845
6846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6847         LDKChannelInfo o_conv;
6848         o_conv.inner = (void*)(o & (~1));
6849         o_conv.is_owned = (o & 1) || (o == 0);
6850         // Warning: we need a move here but no clone is available for LDKChannelInfo
6851         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
6852         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
6853         return (long)ret_conv;
6854 }
6855
6856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6857         LDKDecodeError e_conv;
6858         e_conv.inner = (void*)(e & (~1));
6859         e_conv.is_owned = (e & 1) || (e == 0);
6860         e_conv = DecodeError_clone(&e_conv);
6861         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
6862         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
6863         return (long)ret_conv;
6864 }
6865
6866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6867         if ((_res & 1) != 0) return;
6868         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6869         FREE((void*)_res);
6870         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
6871 }
6872
6873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6874         LDKRoutingFees o_conv;
6875         o_conv.inner = (void*)(o & (~1));
6876         o_conv.is_owned = (o & 1) || (o == 0);
6877         o_conv = RoutingFees_clone(&o_conv);
6878         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6879         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
6880         return (long)ret_conv;
6881 }
6882
6883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6884         LDKDecodeError e_conv;
6885         e_conv.inner = (void*)(e & (~1));
6886         e_conv.is_owned = (e & 1) || (e == 0);
6887         e_conv = DecodeError_clone(&e_conv);
6888         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6889         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
6890         return (long)ret_conv;
6891 }
6892
6893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6894         if ((_res & 1) != 0) return;
6895         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6896         FREE((void*)_res);
6897         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
6898 }
6899
6900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6901         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
6902         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6903         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
6904         return (long)ret_conv;
6905 }
6906
6907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
6908         LDKCVec_NetAddressZ _res_constr;
6909         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
6910         if (_res_constr.datalen > 0)
6911                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
6912         else
6913                 _res_constr.data = NULL;
6914         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
6915         for (size_t m = 0; m < _res_constr.datalen; m++) {
6916                 int64_t arr_conv_12 = _res_vals[m];
6917                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)(((uint64_t)arr_conv_12) & ~1);
6918                 FREE((void*)arr_conv_12);
6919                 _res_constr.data[m] = arr_conv_12_conv;
6920         }
6921         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
6922         CVec_NetAddressZ_free(_res_constr);
6923 }
6924
6925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6926         LDKNodeAnnouncementInfo o_conv;
6927         o_conv.inner = (void*)(o & (~1));
6928         o_conv.is_owned = (o & 1) || (o == 0);
6929         o_conv = NodeAnnouncementInfo_clone(&o_conv);
6930         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6931         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
6932         return (long)ret_conv;
6933 }
6934
6935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6936         LDKDecodeError e_conv;
6937         e_conv.inner = (void*)(e & (~1));
6938         e_conv.is_owned = (e & 1) || (e == 0);
6939         e_conv = DecodeError_clone(&e_conv);
6940         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6941         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
6942         return (long)ret_conv;
6943 }
6944
6945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6946         if ((_res & 1) != 0) return;
6947         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6948         FREE((void*)_res);
6949         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
6950 }
6951
6952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6953         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
6954         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6955         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
6956         return (long)ret_conv;
6957 }
6958
6959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
6960         LDKCVec_u64Z _res_constr;
6961         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
6962         if (_res_constr.datalen > 0)
6963                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
6964         else
6965                 _res_constr.data = NULL;
6966         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
6967         for (size_t g = 0; g < _res_constr.datalen; g++) {
6968                 int64_t arr_conv_6 = _res_vals[g];
6969                 _res_constr.data[g] = arr_conv_6;
6970         }
6971         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
6972         CVec_u64Z_free(_res_constr);
6973 }
6974
6975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6976         LDKNodeInfo o_conv;
6977         o_conv.inner = (void*)(o & (~1));
6978         o_conv.is_owned = (o & 1) || (o == 0);
6979         o_conv = NodeInfo_clone(&o_conv);
6980         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6981         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
6982         return (long)ret_conv;
6983 }
6984
6985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6986         LDKDecodeError e_conv;
6987         e_conv.inner = (void*)(e & (~1));
6988         e_conv.is_owned = (e & 1) || (e == 0);
6989         e_conv = DecodeError_clone(&e_conv);
6990         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6991         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
6992         return (long)ret_conv;
6993 }
6994
6995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6996         if ((_res & 1) != 0) return;
6997         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6998         FREE((void*)_res);
6999         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
7000 }
7001
7002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7003         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
7004         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
7005         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
7006         return (long)ret_conv;
7007 }
7008
7009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7010         LDKNetworkGraph o_conv;
7011         o_conv.inner = (void*)(o & (~1));
7012         o_conv.is_owned = (o & 1) || (o == 0);
7013         // Warning: we need a move here but no clone is available for LDKNetworkGraph
7014         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
7015         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
7016         return (long)ret_conv;
7017 }
7018
7019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7020         LDKDecodeError e_conv;
7021         e_conv.inner = (void*)(e & (~1));
7022         e_conv.is_owned = (e & 1) || (e == 0);
7023         e_conv = DecodeError_clone(&e_conv);
7024         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
7025         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
7026         return (long)ret_conv;
7027 }
7028
7029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7030         if ((_res & 1) != 0) return;
7031         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
7032         FREE((void*)_res);
7033         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
7034 }
7035
7036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
7037         LDKTransaction b_ref;
7038         b_ref.datalen = (*env)->GetArrayLength(env, b);
7039         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
7040         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7041         b_ref.data_is_owned = true;
7042         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7043         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
7044         return (long)ret_ref;
7045 }
7046
7047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7048         if ((_res & 1) != 0) return;
7049         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
7050         FREE((void*)_res);
7051         C2Tuple_usizeTransactionZ_free(_res_conv);
7052 }
7053
7054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7055         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
7056         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7057         if (_res_constr.datalen > 0)
7058                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7059         else
7060                 _res_constr.data = NULL;
7061         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7062         for (size_t y = 0; y < _res_constr.datalen; y++) {
7063                 int64_t arr_conv_24 = _res_vals[y];
7064                 LDKC2Tuple_usizeTransactionZ arr_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_conv_24) & ~1);
7065                 FREE((void*)arr_conv_24);
7066                 _res_constr.data[y] = arr_conv_24_conv;
7067         }
7068         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7069         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
7070 }
7071
7072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
7073         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7074         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
7075         return (long)ret_conv;
7076 }
7077
7078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
7079         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
7080         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7081         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
7082         return (long)ret_conv;
7083 }
7084
7085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7086         if ((_res & 1) != 0) return;
7087         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
7088         FREE((void*)_res);
7089         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
7090 }
7091
7092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7093         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
7094         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7095         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
7096         return (long)ret_conv;
7097 }
7098
7099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7100         LDKCVec_MonitorEventZ _res_constr;
7101         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7102         if (_res_constr.datalen > 0)
7103                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
7104         else
7105                 _res_constr.data = NULL;
7106         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7107         for (size_t o = 0; o < _res_constr.datalen; o++) {
7108                 int64_t arr_conv_14 = _res_vals[o];
7109                 LDKMonitorEvent arr_conv_14_conv;
7110                 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
7111                 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
7112                 _res_constr.data[o] = arr_conv_14_conv;
7113         }
7114         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7115         CVec_MonitorEventZ_free(_res_constr);
7116 }
7117
7118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7119         LDKCVec_EventZ _res_constr;
7120         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7121         if (_res_constr.datalen > 0)
7122                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
7123         else
7124                 _res_constr.data = NULL;
7125         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7126         for (size_t h = 0; h < _res_constr.datalen; h++) {
7127                 int64_t arr_conv_7 = _res_vals[h];
7128                 LDKEvent arr_conv_7_conv = *(LDKEvent*)(((uint64_t)arr_conv_7) & ~1);
7129                 FREE((void*)arr_conv_7);
7130                 _res_constr.data[h] = arr_conv_7_conv;
7131         }
7132         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7133         CVec_EventZ_free(_res_constr);
7134 }
7135
7136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7137         LDKOutPoint o_conv;
7138         o_conv.inner = (void*)(o & (~1));
7139         o_conv.is_owned = (o & 1) || (o == 0);
7140         o_conv = OutPoint_clone(&o_conv);
7141         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
7142         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
7143         return (long)ret_conv;
7144 }
7145
7146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7147         LDKDecodeError e_conv;
7148         e_conv.inner = (void*)(e & (~1));
7149         e_conv.is_owned = (e & 1) || (e == 0);
7150         e_conv = DecodeError_clone(&e_conv);
7151         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
7152         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
7153         return (long)ret_conv;
7154 }
7155
7156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7157         if ((_res & 1) != 0) return;
7158         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
7159         FREE((void*)_res);
7160         CResult_OutPointDecodeErrorZ_free(_res_conv);
7161 }
7162
7163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7164         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
7165         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
7166         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
7167         return (long)ret_conv;
7168 }
7169
7170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7171         LDKChannelMonitorUpdate o_conv;
7172         o_conv.inner = (void*)(o & (~1));
7173         o_conv.is_owned = (o & 1) || (o == 0);
7174         o_conv = ChannelMonitorUpdate_clone(&o_conv);
7175         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7176         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
7177         return (long)ret_conv;
7178 }
7179
7180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7181         LDKDecodeError e_conv;
7182         e_conv.inner = (void*)(e & (~1));
7183         e_conv.is_owned = (e & 1) || (e == 0);
7184         e_conv = DecodeError_clone(&e_conv);
7185         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7186         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
7187         return (long)ret_conv;
7188 }
7189
7190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7191         if ((_res & 1) != 0) return;
7192         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
7193         FREE((void*)_res);
7194         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
7195 }
7196
7197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7198         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
7199         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7200         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
7201         return (long)ret_conv;
7202 }
7203
7204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7205         LDKHTLCUpdate o_conv;
7206         o_conv.inner = (void*)(o & (~1));
7207         o_conv.is_owned = (o & 1) || (o == 0);
7208         o_conv = HTLCUpdate_clone(&o_conv);
7209         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7210         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
7211         return (long)ret_conv;
7212 }
7213
7214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7215         LDKDecodeError e_conv;
7216         e_conv.inner = (void*)(e & (~1));
7217         e_conv.is_owned = (e & 1) || (e == 0);
7218         e_conv = DecodeError_clone(&e_conv);
7219         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7220         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
7221         return (long)ret_conv;
7222 }
7223
7224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7225         if ((_res & 1) != 0) return;
7226         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
7227         FREE((void*)_res);
7228         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
7229 }
7230
7231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7232         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
7233         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7234         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
7235         return (long)ret_conv;
7236 }
7237
7238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
7239         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7240         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
7241         return (long)ret_conv;
7242 }
7243
7244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7245         LDKMonitorUpdateError e_conv;
7246         e_conv.inner = (void*)(e & (~1));
7247         e_conv.is_owned = (e & 1) || (e == 0);
7248         e_conv = MonitorUpdateError_clone(&e_conv);
7249         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7250         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
7251         return (long)ret_conv;
7252 }
7253
7254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7255         if ((_res & 1) != 0) return;
7256         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
7257         FREE((void*)_res);
7258         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
7259 }
7260
7261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7262         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
7263         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7264         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
7265         return (long)ret_conv;
7266 }
7267
7268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7269         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
7270         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
7271         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
7272         return (long)ret_ref;
7273 }
7274
7275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
7276         LDKOutPoint a_conv;
7277         a_conv.inner = (void*)(a & (~1));
7278         a_conv.is_owned = (a & 1) || (a == 0);
7279         a_conv = OutPoint_clone(&a_conv);
7280         LDKCVec_u8Z b_ref;
7281         b_ref.datalen = (*env)->GetArrayLength(env, b);
7282         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
7283         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7284         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
7285         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
7286         return (long)ret_ref;
7287 }
7288
7289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7290         if ((_res & 1) != 0) return;
7291         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
7292         FREE((void*)_res);
7293         C2Tuple_OutPointScriptZ_free(_res_conv);
7294 }
7295
7296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
7297         LDKCVec_TransactionZ _res_constr;
7298         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7299         if (_res_constr.datalen > 0)
7300                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
7301         else
7302                 _res_constr.data = NULL;
7303         for (size_t i = 0; i < _res_constr.datalen; i++) {
7304                 int8_tArray arr_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
7305                 LDKTransaction arr_conv_8_ref;
7306                 arr_conv_8_ref.datalen = (*env)->GetArrayLength(env, arr_conv_8);
7307                 arr_conv_8_ref.data = MALLOC(arr_conv_8_ref.datalen, "LDKTransaction Bytes");
7308                 (*env)->GetByteArrayRegion(env, arr_conv_8, 0, arr_conv_8_ref.datalen, arr_conv_8_ref.data);
7309                 arr_conv_8_ref.data_is_owned = true;
7310                 _res_constr.data[i] = arr_conv_8_ref;
7311         }
7312         CVec_TransactionZ_free(_res_constr);
7313 }
7314
7315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7316         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
7317         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7318         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
7319         return (long)ret_ref;
7320 }
7321
7322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
7323         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
7324         FREE((void*)b);
7325         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7326         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
7327         return (long)ret_ref;
7328 }
7329
7330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7331         if ((_res & 1) != 0) return;
7332         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
7333         FREE((void*)_res);
7334         C2Tuple_u32TxOutZ_free(_res_conv);
7335 }
7336
7337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7338         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
7339         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7340         if (_res_constr.datalen > 0)
7341                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
7342         else
7343                 _res_constr.data = NULL;
7344         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7345         for (size_t a = 0; a < _res_constr.datalen; a++) {
7346                 int64_t arr_conv_26 = _res_vals[a];
7347                 LDKC2Tuple_u32TxOutZ arr_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_conv_26) & ~1);
7348                 FREE((void*)arr_conv_26);
7349                 _res_constr.data[a] = arr_conv_26_conv;
7350         }
7351         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7352         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
7353 }
7354
7355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
7356         LDKThirtyTwoBytes a_ref;
7357         CHECK((*env)->GetArrayLength(env, a) == 32);
7358         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
7359         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
7360         b_constr.datalen = (*env)->GetArrayLength(env, b);
7361         if (b_constr.datalen > 0)
7362                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
7363         else
7364                 b_constr.data = NULL;
7365         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
7366         for (size_t a = 0; a < b_constr.datalen; a++) {
7367                 int64_t arr_conv_26 = b_vals[a];
7368                 LDKC2Tuple_u32TxOutZ arr_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_conv_26) & ~1);
7369                 FREE((void*)arr_conv_26);
7370                 b_constr.data[a] = arr_conv_26_conv;
7371         }
7372         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
7373         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
7374         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
7375         return (long)ret_ref;
7376 }
7377
7378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7379         if ((_res & 1) != 0) return;
7380         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
7381         FREE((void*)_res);
7382         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
7383 }
7384
7385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7386         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
7387         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7388         if (_res_constr.datalen > 0)
7389                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
7390         else
7391                 _res_constr.data = NULL;
7392         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7393         for (size_t u = 0; u < _res_constr.datalen; u++) {
7394                 int64_t arr_conv_46 = _res_vals[u];
7395                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_conv_46) & ~1);
7396                 FREE((void*)arr_conv_46);
7397                 _res_constr.data[u] = arr_conv_46_conv;
7398         }
7399         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7400         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
7401 }
7402
7403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
7404         LDKThirtyTwoBytes a_ref;
7405         CHECK((*env)->GetArrayLength(env, a) == 32);
7406         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
7407         LDKChannelMonitor b_conv;
7408         b_conv.inner = (void*)(b & (~1));
7409         b_conv.is_owned = (b & 1) || (b == 0);
7410         b_conv = ChannelMonitor_clone(&b_conv);
7411         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7412         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
7413         return (long)ret_ref;
7414 }
7415
7416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7417         if ((_res & 1) != 0) return;
7418         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
7419         FREE((void*)_res);
7420         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
7421 }
7422
7423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7424         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
7425         FREE((void*)o);
7426         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
7427         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
7428         return (long)ret_conv;
7429 }
7430
7431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7432         LDKDecodeError e_conv;
7433         e_conv.inner = (void*)(e & (~1));
7434         e_conv.is_owned = (e & 1) || (e == 0);
7435         e_conv = DecodeError_clone(&e_conv);
7436         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
7437         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
7438         return (long)ret_conv;
7439 }
7440
7441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7442         if ((_res & 1) != 0) return;
7443         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
7444         FREE((void*)_res);
7445         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
7446 }
7447
7448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7449         LDKCVec_SpendableOutputDescriptorZ _res_constr;
7450         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7451         if (_res_constr.datalen > 0)
7452                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
7453         else
7454                 _res_constr.data = NULL;
7455         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7456         for (size_t b = 0; b < _res_constr.datalen; b++) {
7457                 int64_t arr_conv_27 = _res_vals[b];
7458                 LDKSpendableOutputDescriptor arr_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_conv_27) & ~1);
7459                 FREE((void*)arr_conv_27);
7460                 _res_constr.data[b] = arr_conv_27_conv;
7461         }
7462         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7463         CVec_SpendableOutputDescriptorZ_free(_res_constr);
7464 }
7465
7466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7467         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
7468         FREE((void*)o);
7469         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7470         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
7471         return (long)ret_conv;
7472 }
7473
7474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
7475         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
7476         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7477         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
7478         return (long)ret_conv;
7479 }
7480
7481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7482         if ((_res & 1) != 0) return;
7483         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
7484         FREE((void*)_res);
7485         CResult_TxOutAccessErrorZ_free(_res_conv);
7486 }
7487
7488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7489         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
7490         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7491         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
7492         return (long)ret_conv;
7493 }
7494
7495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
7496         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7497         *ret_conv = CResult_NoneAPIErrorZ_ok();
7498         return (long)ret_conv;
7499 }
7500
7501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7502         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
7503         FREE((void*)e);
7504         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7505         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
7506         return (long)ret_conv;
7507 }
7508
7509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7510         if ((_res & 1) != 0) return;
7511         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
7512         FREE((void*)_res);
7513         CResult_NoneAPIErrorZ_free(_res_conv);
7514 }
7515
7516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7517         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
7518         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7519         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
7520         return (long)ret_conv;
7521 }
7522
7523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7524         LDKCVec_ChannelDetailsZ _res_constr;
7525         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7526         if (_res_constr.datalen > 0)
7527                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7528         else
7529                 _res_constr.data = NULL;
7530         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7531         for (size_t q = 0; q < _res_constr.datalen; q++) {
7532                 int64_t arr_conv_16 = _res_vals[q];
7533                 LDKChannelDetails arr_conv_16_conv;
7534                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
7535                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
7536                 _res_constr.data[q] = arr_conv_16_conv;
7537         }
7538         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7539         CVec_ChannelDetailsZ_free(_res_constr);
7540 }
7541
7542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
7543         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7544         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
7545         return (long)ret_conv;
7546 }
7547
7548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7549         LDKPaymentSendFailure e_conv;
7550         e_conv.inner = (void*)(e & (~1));
7551         e_conv.is_owned = (e & 1) || (e == 0);
7552         e_conv = PaymentSendFailure_clone(&e_conv);
7553         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7554         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
7555         return (long)ret_conv;
7556 }
7557
7558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7559         if ((_res & 1) != 0) return;
7560         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
7561         FREE((void*)_res);
7562         CResult_NonePaymentSendFailureZ_free(_res_conv);
7563 }
7564
7565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7566         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
7567         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7568         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
7569         return (long)ret_conv;
7570 }
7571
7572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7573         LDKCVec_ChannelMonitorZ _res_constr;
7574         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7575         if (_res_constr.datalen > 0)
7576                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
7577         else
7578                 _res_constr.data = NULL;
7579         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7580         for (size_t q = 0; q < _res_constr.datalen; q++) {
7581                 int64_t arr_conv_16 = _res_vals[q];
7582                 LDKChannelMonitor arr_conv_16_conv;
7583                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
7584                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
7585                 _res_constr.data[q] = arr_conv_16_conv;
7586         }
7587         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7588         CVec_ChannelMonitorZ_free(_res_constr);
7589 }
7590
7591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
7592         LDKThirtyTwoBytes a_ref;
7593         CHECK((*env)->GetArrayLength(env, a) == 32);
7594         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
7595         LDKChannelManager b_conv;
7596         b_conv.inner = (void*)(b & (~1));
7597         b_conv.is_owned = (b & 1) || (b == 0);
7598         // Warning: we need a move here but no clone is available for LDKChannelManager
7599         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
7600         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
7601         return (long)ret_ref;
7602 }
7603
7604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7605         if ((_res & 1) != 0) return;
7606         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
7607         FREE((void*)_res);
7608         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
7609 }
7610
7611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7612         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
7613         FREE((void*)o);
7614         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
7615         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
7616         return (long)ret_conv;
7617 }
7618
7619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7620         LDKDecodeError e_conv;
7621         e_conv.inner = (void*)(e & (~1));
7622         e_conv.is_owned = (e & 1) || (e == 0);
7623         e_conv = DecodeError_clone(&e_conv);
7624         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
7625         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
7626         return (long)ret_conv;
7627 }
7628
7629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7630         if ((_res & 1) != 0) return;
7631         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
7632         FREE((void*)_res);
7633         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
7634 }
7635
7636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7637         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)(orig & ~1);
7638         LDKC2Tuple_u64u64Z* ret_ref = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
7639         *ret_ref = C2Tuple_u64u64Z_clone(orig_conv);
7640         return (long)ret_ref;
7641 }
7642
7643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
7644         LDKC2Tuple_u64u64Z* ret_ref = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
7645         *ret_ref = C2Tuple_u64u64Z_new(a, b);
7646         return (long)ret_ref;
7647 }
7648
7649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
7650         if ((_res & 1) != 0) return;
7651         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(((uint64_t)_res) & ~1);
7652         FREE((void*)_res);
7653         C2Tuple_u64u64Z_free(_res_conv);
7654 }
7655
7656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7657         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
7658         FREE((void*)o);
7659         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7660         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
7661         return (long)ret_conv;
7662 }
7663
7664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7665         LDKDecodeError e_conv;
7666         e_conv.inner = (void*)(e & (~1));
7667         e_conv.is_owned = (e & 1) || (e == 0);
7668         e_conv = DecodeError_clone(&e_conv);
7669         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7670         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
7671         return (long)ret_conv;
7672 }
7673
7674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7675         if ((_res & 1) != 0) return;
7676         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7677         FREE((void*)_res);
7678         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
7679 }
7680
7681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7682         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
7683         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7684         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
7685         return (long)ret_conv;
7686 }
7687
7688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7689         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
7690         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7691         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
7692         return (long)ret_ref;
7693 }
7694
7695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
7696         LDKSignature a_ref;
7697         CHECK((*env)->GetArrayLength(env, a) == 64);
7698         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
7699         LDKCVec_SignatureZ b_constr;
7700         b_constr.datalen = (*env)->GetArrayLength(env, b);
7701         if (b_constr.datalen > 0)
7702                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7703         else
7704                 b_constr.data = NULL;
7705         for (size_t i = 0; i < b_constr.datalen; i++) {
7706                 int8_tArray arr_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
7707                 LDKSignature arr_conv_8_ref;
7708                 CHECK((*env)->GetArrayLength(env, arr_conv_8) == 64);
7709                 (*env)->GetByteArrayRegion(env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
7710                 b_constr.data[i] = arr_conv_8_ref;
7711         }
7712         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7713         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
7714         return (long)ret_ref;
7715 }
7716
7717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7718         if ((_res & 1) != 0) return;
7719         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
7720         FREE((void*)_res);
7721         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
7722 }
7723
7724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7725         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
7726         FREE((void*)o);
7727         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7728         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
7729         return (long)ret_conv;
7730 }
7731
7732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
7733         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7734         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
7735         return (long)ret_conv;
7736 }
7737
7738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7739         if ((_res & 1) != 0) return;
7740         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
7741         FREE((void*)_res);
7742         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
7743 }
7744
7745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7746         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
7747         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7748         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
7749         return (long)ret_conv;
7750 }
7751
7752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
7753         LDKSignature o_ref;
7754         CHECK((*env)->GetArrayLength(env, o) == 64);
7755         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
7756         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7757         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
7758         return (long)ret_conv;
7759 }
7760
7761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
7762         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7763         *ret_conv = CResult_SignatureNoneZ_err();
7764         return (long)ret_conv;
7765 }
7766
7767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7768         if ((_res & 1) != 0) return;
7769         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
7770         FREE((void*)_res);
7771         CResult_SignatureNoneZ_free(_res_conv);
7772 }
7773
7774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7775         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
7776         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7777         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
7778         return (long)ret_conv;
7779 }
7780
7781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7782         LDKChannelKeys o_conv = *(LDKChannelKeys*)(((uint64_t)o) & ~1);
7783         if (o_conv.free == LDKChannelKeys_JCalls_free) {
7784                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7785                 LDKChannelKeys_JCalls_clone(o_conv.this_arg);
7786         }
7787         LDKCResult_ChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelKeysDecodeErrorZ), "LDKCResult_ChannelKeysDecodeErrorZ");
7788         *ret_conv = CResult_ChannelKeysDecodeErrorZ_ok(o_conv);
7789         return (long)ret_conv;
7790 }
7791
7792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7793         LDKDecodeError e_conv;
7794         e_conv.inner = (void*)(e & (~1));
7795         e_conv.is_owned = (e & 1) || (e == 0);
7796         e_conv = DecodeError_clone(&e_conv);
7797         LDKCResult_ChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelKeysDecodeErrorZ), "LDKCResult_ChannelKeysDecodeErrorZ");
7798         *ret_conv = CResult_ChannelKeysDecodeErrorZ_err(e_conv);
7799         return (long)ret_conv;
7800 }
7801
7802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7803         if ((_res & 1) != 0) return;
7804         LDKCResult_ChannelKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
7805         FREE((void*)_res);
7806         CResult_ChannelKeysDecodeErrorZ_free(_res_conv);
7807 }
7808
7809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7810         LDKCResult_ChannelKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelKeysDecodeErrorZ*)(orig & ~1);
7811         LDKCResult_ChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelKeysDecodeErrorZ), "LDKCResult_ChannelKeysDecodeErrorZ");
7812         *ret_conv = CResult_ChannelKeysDecodeErrorZ_clone(orig_conv);
7813         return (long)ret_conv;
7814 }
7815
7816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemoryChannelKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7817         LDKInMemoryChannelKeys o_conv;
7818         o_conv.inner = (void*)(o & (~1));
7819         o_conv.is_owned = (o & 1) || (o == 0);
7820         o_conv = InMemoryChannelKeys_clone(&o_conv);
7821         LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
7822         *ret_conv = CResult_InMemoryChannelKeysDecodeErrorZ_ok(o_conv);
7823         return (long)ret_conv;
7824 }
7825
7826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemoryChannelKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7827         LDKDecodeError e_conv;
7828         e_conv.inner = (void*)(e & (~1));
7829         e_conv.is_owned = (e & 1) || (e == 0);
7830         e_conv = DecodeError_clone(&e_conv);
7831         LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
7832         *ret_conv = CResult_InMemoryChannelKeysDecodeErrorZ_err(e_conv);
7833         return (long)ret_conv;
7834 }
7835
7836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemoryChannelKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7837         if ((_res & 1) != 0) return;
7838         LDKCResult_InMemoryChannelKeysDecodeErrorZ _res_conv = *(LDKCResult_InMemoryChannelKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
7839         FREE((void*)_res);
7840         CResult_InMemoryChannelKeysDecodeErrorZ_free(_res_conv);
7841 }
7842
7843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemoryChannelKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7844         LDKCResult_InMemoryChannelKeysDecodeErrorZ* orig_conv = (LDKCResult_InMemoryChannelKeysDecodeErrorZ*)(orig & ~1);
7845         LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
7846         *ret_conv = CResult_InMemoryChannelKeysDecodeErrorZ_clone(orig_conv);
7847         return (long)ret_conv;
7848 }
7849
7850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7851         LDKCVec_RouteHopZ _res_constr;
7852         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7853         if (_res_constr.datalen > 0)
7854                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7855         else
7856                 _res_constr.data = NULL;
7857         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7858         for (size_t k = 0; k < _res_constr.datalen; k++) {
7859                 int64_t arr_conv_10 = _res_vals[k];
7860                 LDKRouteHop arr_conv_10_conv;
7861                 arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
7862                 arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
7863                 _res_constr.data[k] = arr_conv_10_conv;
7864         }
7865         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7866         CVec_RouteHopZ_free(_res_constr);
7867 }
7868
7869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
7870         LDKCVec_CVec_RouteHopZZ _res_constr;
7871         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7872         if (_res_constr.datalen > 0)
7873                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
7874         else
7875                 _res_constr.data = NULL;
7876         for (size_t m = 0; m < _res_constr.datalen; m++) {
7877                 int64_tArray arr_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
7878                 LDKCVec_RouteHopZ arr_conv_12_constr;
7879                 arr_conv_12_constr.datalen = (*env)->GetArrayLength(env, arr_conv_12);
7880                 if (arr_conv_12_constr.datalen > 0)
7881                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7882                 else
7883                         arr_conv_12_constr.data = NULL;
7884                 int64_t* arr_conv_12_vals = (*env)->GetLongArrayElements (env, arr_conv_12, NULL);
7885                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
7886                         int64_t arr_conv_10 = arr_conv_12_vals[k];
7887                         LDKRouteHop arr_conv_10_conv;
7888                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
7889                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
7890                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
7891                 }
7892                 (*env)->ReleaseLongArrayElements(env, arr_conv_12, arr_conv_12_vals, 0);
7893                 _res_constr.data[m] = arr_conv_12_constr;
7894         }
7895         CVec_CVec_RouteHopZZ_free(_res_constr);
7896 }
7897
7898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7899         LDKRoute o_conv;
7900         o_conv.inner = (void*)(o & (~1));
7901         o_conv.is_owned = (o & 1) || (o == 0);
7902         o_conv = Route_clone(&o_conv);
7903         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7904         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
7905         return (long)ret_conv;
7906 }
7907
7908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7909         LDKDecodeError e_conv;
7910         e_conv.inner = (void*)(e & (~1));
7911         e_conv.is_owned = (e & 1) || (e == 0);
7912         e_conv = DecodeError_clone(&e_conv);
7913         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7914         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
7915         return (long)ret_conv;
7916 }
7917
7918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7919         if ((_res & 1) != 0) return;
7920         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
7921         FREE((void*)_res);
7922         CResult_RouteDecodeErrorZ_free(_res_conv);
7923 }
7924
7925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7926         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
7927         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7928         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
7929         return (long)ret_conv;
7930 }
7931
7932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7933         LDKCVec_RouteHintZ _res_constr;
7934         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7935         if (_res_constr.datalen > 0)
7936                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
7937         else
7938                 _res_constr.data = NULL;
7939         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7940         for (size_t l = 0; l < _res_constr.datalen; l++) {
7941                 int64_t arr_conv_11 = _res_vals[l];
7942                 LDKRouteHint arr_conv_11_conv;
7943                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
7944                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
7945                 _res_constr.data[l] = arr_conv_11_conv;
7946         }
7947         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7948         CVec_RouteHintZ_free(_res_constr);
7949 }
7950
7951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7952         LDKRoute o_conv;
7953         o_conv.inner = (void*)(o & (~1));
7954         o_conv.is_owned = (o & 1) || (o == 0);
7955         o_conv = Route_clone(&o_conv);
7956         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7957         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
7958         return (long)ret_conv;
7959 }
7960
7961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7962         LDKLightningError e_conv;
7963         e_conv.inner = (void*)(e & (~1));
7964         e_conv.is_owned = (e & 1) || (e == 0);
7965         e_conv = LightningError_clone(&e_conv);
7966         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7967         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
7968         return (long)ret_conv;
7969 }
7970
7971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7972         if ((_res & 1) != 0) return;
7973         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
7974         FREE((void*)_res);
7975         CResult_RouteLightningErrorZ_free(_res_conv);
7976 }
7977
7978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7979         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
7980         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7981         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
7982         return (long)ret_conv;
7983 }
7984
7985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
7986         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
7987         FREE((void*)o);
7988         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
7989         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
7990         return (long)ret_conv;
7991 }
7992
7993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
7994         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
7995         *ret_conv = CResult_NetAddressu8Z_err(e);
7996         return (long)ret_conv;
7997 }
7998
7999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
8000         if ((_res & 1) != 0) return;
8001         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
8002         FREE((void*)_res);
8003         CResult_NetAddressu8Z_free(_res_conv);
8004 }
8005
8006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8007         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
8008         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8009         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
8010         return (long)ret_conv;
8011 }
8012
8013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8014         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
8015         FREE((void*)o);
8016         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8017         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
8018         return (long)ret_conv;
8019 }
8020
8021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8022         LDKDecodeError e_conv;
8023         e_conv.inner = (void*)(e & (~1));
8024         e_conv.is_owned = (e & 1) || (e == 0);
8025         e_conv = DecodeError_clone(&e_conv);
8026         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8027         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
8028         return (long)ret_conv;
8029 }
8030
8031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8032         if ((_res & 1) != 0) return;
8033         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8034         FREE((void*)_res);
8035         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
8036 }
8037
8038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8039         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
8040         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8041         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
8042         return (long)ret_conv;
8043 }
8044
8045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8046         LDKCVec_UpdateAddHTLCZ _res_constr;
8047         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8048         if (_res_constr.datalen > 0)
8049                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
8050         else
8051                 _res_constr.data = NULL;
8052         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8053         for (size_t p = 0; p < _res_constr.datalen; p++) {
8054                 int64_t arr_conv_15 = _res_vals[p];
8055                 LDKUpdateAddHTLC arr_conv_15_conv;
8056                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
8057                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
8058                 _res_constr.data[p] = arr_conv_15_conv;
8059         }
8060         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8061         CVec_UpdateAddHTLCZ_free(_res_constr);
8062 }
8063
8064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8065         LDKCVec_UpdateFulfillHTLCZ _res_constr;
8066         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8067         if (_res_constr.datalen > 0)
8068                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
8069         else
8070                 _res_constr.data = NULL;
8071         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8072         for (size_t t = 0; t < _res_constr.datalen; t++) {
8073                 int64_t arr_conv_19 = _res_vals[t];
8074                 LDKUpdateFulfillHTLC arr_conv_19_conv;
8075                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
8076                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
8077                 _res_constr.data[t] = arr_conv_19_conv;
8078         }
8079         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8080         CVec_UpdateFulfillHTLCZ_free(_res_constr);
8081 }
8082
8083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8084         LDKCVec_UpdateFailHTLCZ _res_constr;
8085         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8086         if (_res_constr.datalen > 0)
8087                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
8088         else
8089                 _res_constr.data = NULL;
8090         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8091         for (size_t q = 0; q < _res_constr.datalen; q++) {
8092                 int64_t arr_conv_16 = _res_vals[q];
8093                 LDKUpdateFailHTLC arr_conv_16_conv;
8094                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
8095                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
8096                 _res_constr.data[q] = arr_conv_16_conv;
8097         }
8098         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8099         CVec_UpdateFailHTLCZ_free(_res_constr);
8100 }
8101
8102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8103         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
8104         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8105         if (_res_constr.datalen > 0)
8106                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
8107         else
8108                 _res_constr.data = NULL;
8109         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8110         for (size_t z = 0; z < _res_constr.datalen; z++) {
8111                 int64_t arr_conv_25 = _res_vals[z];
8112                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
8113                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
8114                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
8115                 _res_constr.data[z] = arr_conv_25_conv;
8116         }
8117         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8118         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
8119 }
8120
8121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8122         LDKAcceptChannel o_conv;
8123         o_conv.inner = (void*)(o & (~1));
8124         o_conv.is_owned = (o & 1) || (o == 0);
8125         o_conv = AcceptChannel_clone(&o_conv);
8126         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
8127         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
8128         return (long)ret_conv;
8129 }
8130
8131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8132         LDKDecodeError e_conv;
8133         e_conv.inner = (void*)(e & (~1));
8134         e_conv.is_owned = (e & 1) || (e == 0);
8135         e_conv = DecodeError_clone(&e_conv);
8136         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
8137         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
8138         return (long)ret_conv;
8139 }
8140
8141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8142         if ((_res & 1) != 0) return;
8143         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
8144         FREE((void*)_res);
8145         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
8146 }
8147
8148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8149         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
8150         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
8151         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
8152         return (long)ret_conv;
8153 }
8154
8155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8156         LDKAnnouncementSignatures o_conv;
8157         o_conv.inner = (void*)(o & (~1));
8158         o_conv.is_owned = (o & 1) || (o == 0);
8159         o_conv = AnnouncementSignatures_clone(&o_conv);
8160         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
8161         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
8162         return (long)ret_conv;
8163 }
8164
8165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8166         LDKDecodeError e_conv;
8167         e_conv.inner = (void*)(e & (~1));
8168         e_conv.is_owned = (e & 1) || (e == 0);
8169         e_conv = DecodeError_clone(&e_conv);
8170         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
8171         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
8172         return (long)ret_conv;
8173 }
8174
8175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8176         if ((_res & 1) != 0) return;
8177         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8178         FREE((void*)_res);
8179         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
8180 }
8181
8182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8183         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
8184         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
8185         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
8186         return (long)ret_conv;
8187 }
8188
8189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8190         LDKChannelReestablish o_conv;
8191         o_conv.inner = (void*)(o & (~1));
8192         o_conv.is_owned = (o & 1) || (o == 0);
8193         o_conv = ChannelReestablish_clone(&o_conv);
8194         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
8195         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
8196         return (long)ret_conv;
8197 }
8198
8199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8200         LDKDecodeError e_conv;
8201         e_conv.inner = (void*)(e & (~1));
8202         e_conv.is_owned = (e & 1) || (e == 0);
8203         e_conv = DecodeError_clone(&e_conv);
8204         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
8205         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
8206         return (long)ret_conv;
8207 }
8208
8209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8210         if ((_res & 1) != 0) return;
8211         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
8212         FREE((void*)_res);
8213         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
8214 }
8215
8216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8217         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
8218         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
8219         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
8220         return (long)ret_conv;
8221 }
8222
8223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8224         LDKClosingSigned o_conv;
8225         o_conv.inner = (void*)(o & (~1));
8226         o_conv.is_owned = (o & 1) || (o == 0);
8227         o_conv = ClosingSigned_clone(&o_conv);
8228         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
8229         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
8230         return (long)ret_conv;
8231 }
8232
8233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8234         LDKDecodeError e_conv;
8235         e_conv.inner = (void*)(e & (~1));
8236         e_conv.is_owned = (e & 1) || (e == 0);
8237         e_conv = DecodeError_clone(&e_conv);
8238         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
8239         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
8240         return (long)ret_conv;
8241 }
8242
8243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8244         if ((_res & 1) != 0) return;
8245         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8246         FREE((void*)_res);
8247         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
8248 }
8249
8250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8251         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
8252         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
8253         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
8254         return (long)ret_conv;
8255 }
8256
8257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8258         LDKCommitmentSigned o_conv;
8259         o_conv.inner = (void*)(o & (~1));
8260         o_conv.is_owned = (o & 1) || (o == 0);
8261         o_conv = CommitmentSigned_clone(&o_conv);
8262         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8263         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
8264         return (long)ret_conv;
8265 }
8266
8267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8268         LDKDecodeError e_conv;
8269         e_conv.inner = (void*)(e & (~1));
8270         e_conv.is_owned = (e & 1) || (e == 0);
8271         e_conv = DecodeError_clone(&e_conv);
8272         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8273         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
8274         return (long)ret_conv;
8275 }
8276
8277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8278         if ((_res & 1) != 0) return;
8279         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8280         FREE((void*)_res);
8281         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
8282 }
8283
8284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8285         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
8286         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8287         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
8288         return (long)ret_conv;
8289 }
8290
8291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8292         LDKFundingCreated o_conv;
8293         o_conv.inner = (void*)(o & (~1));
8294         o_conv.is_owned = (o & 1) || (o == 0);
8295         o_conv = FundingCreated_clone(&o_conv);
8296         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8297         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
8298         return (long)ret_conv;
8299 }
8300
8301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8302         LDKDecodeError e_conv;
8303         e_conv.inner = (void*)(e & (~1));
8304         e_conv.is_owned = (e & 1) || (e == 0);
8305         e_conv = DecodeError_clone(&e_conv);
8306         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8307         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
8308         return (long)ret_conv;
8309 }
8310
8311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8312         if ((_res & 1) != 0) return;
8313         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8314         FREE((void*)_res);
8315         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
8316 }
8317
8318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8319         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
8320         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8321         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
8322         return (long)ret_conv;
8323 }
8324
8325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8326         LDKFundingSigned o_conv;
8327         o_conv.inner = (void*)(o & (~1));
8328         o_conv.is_owned = (o & 1) || (o == 0);
8329         o_conv = FundingSigned_clone(&o_conv);
8330         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8331         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
8332         return (long)ret_conv;
8333 }
8334
8335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8336         LDKDecodeError e_conv;
8337         e_conv.inner = (void*)(e & (~1));
8338         e_conv.is_owned = (e & 1) || (e == 0);
8339         e_conv = DecodeError_clone(&e_conv);
8340         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8341         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
8342         return (long)ret_conv;
8343 }
8344
8345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8346         if ((_res & 1) != 0) return;
8347         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8348         FREE((void*)_res);
8349         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
8350 }
8351
8352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8353         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
8354         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8355         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
8356         return (long)ret_conv;
8357 }
8358
8359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8360         LDKFundingLocked o_conv;
8361         o_conv.inner = (void*)(o & (~1));
8362         o_conv.is_owned = (o & 1) || (o == 0);
8363         o_conv = FundingLocked_clone(&o_conv);
8364         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
8365         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
8366         return (long)ret_conv;
8367 }
8368
8369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8370         LDKDecodeError e_conv;
8371         e_conv.inner = (void*)(e & (~1));
8372         e_conv.is_owned = (e & 1) || (e == 0);
8373         e_conv = DecodeError_clone(&e_conv);
8374         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
8375         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
8376         return (long)ret_conv;
8377 }
8378
8379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8380         if ((_res & 1) != 0) return;
8381         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8382         FREE((void*)_res);
8383         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
8384 }
8385
8386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8387         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
8388         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
8389         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
8390         return (long)ret_conv;
8391 }
8392
8393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8394         LDKInit o_conv;
8395         o_conv.inner = (void*)(o & (~1));
8396         o_conv.is_owned = (o & 1) || (o == 0);
8397         o_conv = Init_clone(&o_conv);
8398         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
8399         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
8400         return (long)ret_conv;
8401 }
8402
8403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8404         LDKDecodeError e_conv;
8405         e_conv.inner = (void*)(e & (~1));
8406         e_conv.is_owned = (e & 1) || (e == 0);
8407         e_conv = DecodeError_clone(&e_conv);
8408         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
8409         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
8410         return (long)ret_conv;
8411 }
8412
8413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8414         if ((_res & 1) != 0) return;
8415         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
8416         FREE((void*)_res);
8417         CResult_InitDecodeErrorZ_free(_res_conv);
8418 }
8419
8420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8421         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
8422         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
8423         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
8424         return (long)ret_conv;
8425 }
8426
8427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8428         LDKOpenChannel o_conv;
8429         o_conv.inner = (void*)(o & (~1));
8430         o_conv.is_owned = (o & 1) || (o == 0);
8431         o_conv = OpenChannel_clone(&o_conv);
8432         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
8433         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
8434         return (long)ret_conv;
8435 }
8436
8437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8438         LDKDecodeError e_conv;
8439         e_conv.inner = (void*)(e & (~1));
8440         e_conv.is_owned = (e & 1) || (e == 0);
8441         e_conv = DecodeError_clone(&e_conv);
8442         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
8443         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
8444         return (long)ret_conv;
8445 }
8446
8447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8448         if ((_res & 1) != 0) return;
8449         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
8450         FREE((void*)_res);
8451         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
8452 }
8453
8454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8455         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
8456         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
8457         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
8458         return (long)ret_conv;
8459 }
8460
8461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8462         LDKRevokeAndACK o_conv;
8463         o_conv.inner = (void*)(o & (~1));
8464         o_conv.is_owned = (o & 1) || (o == 0);
8465         o_conv = RevokeAndACK_clone(&o_conv);
8466         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
8467         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
8468         return (long)ret_conv;
8469 }
8470
8471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8472         LDKDecodeError e_conv;
8473         e_conv.inner = (void*)(e & (~1));
8474         e_conv.is_owned = (e & 1) || (e == 0);
8475         e_conv = DecodeError_clone(&e_conv);
8476         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
8477         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
8478         return (long)ret_conv;
8479 }
8480
8481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8482         if ((_res & 1) != 0) return;
8483         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
8484         FREE((void*)_res);
8485         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
8486 }
8487
8488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8489         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
8490         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
8491         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
8492         return (long)ret_conv;
8493 }
8494
8495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8496         LDKShutdown o_conv;
8497         o_conv.inner = (void*)(o & (~1));
8498         o_conv.is_owned = (o & 1) || (o == 0);
8499         o_conv = Shutdown_clone(&o_conv);
8500         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
8501         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
8502         return (long)ret_conv;
8503 }
8504
8505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8506         LDKDecodeError e_conv;
8507         e_conv.inner = (void*)(e & (~1));
8508         e_conv.is_owned = (e & 1) || (e == 0);
8509         e_conv = DecodeError_clone(&e_conv);
8510         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
8511         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
8512         return (long)ret_conv;
8513 }
8514
8515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8516         if ((_res & 1) != 0) return;
8517         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
8518         FREE((void*)_res);
8519         CResult_ShutdownDecodeErrorZ_free(_res_conv);
8520 }
8521
8522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8523         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
8524         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
8525         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
8526         return (long)ret_conv;
8527 }
8528
8529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8530         LDKUpdateFailHTLC o_conv;
8531         o_conv.inner = (void*)(o & (~1));
8532         o_conv.is_owned = (o & 1) || (o == 0);
8533         o_conv = UpdateFailHTLC_clone(&o_conv);
8534         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
8535         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
8536         return (long)ret_conv;
8537 }
8538
8539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8540         LDKDecodeError e_conv;
8541         e_conv.inner = (void*)(e & (~1));
8542         e_conv.is_owned = (e & 1) || (e == 0);
8543         e_conv = DecodeError_clone(&e_conv);
8544         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
8545         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
8546         return (long)ret_conv;
8547 }
8548
8549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8550         if ((_res & 1) != 0) return;
8551         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8552         FREE((void*)_res);
8553         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
8554 }
8555
8556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8557         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
8558         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
8559         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
8560         return (long)ret_conv;
8561 }
8562
8563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8564         LDKUpdateFailMalformedHTLC o_conv;
8565         o_conv.inner = (void*)(o & (~1));
8566         o_conv.is_owned = (o & 1) || (o == 0);
8567         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
8568         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
8569         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
8570         return (long)ret_conv;
8571 }
8572
8573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8574         LDKDecodeError e_conv;
8575         e_conv.inner = (void*)(e & (~1));
8576         e_conv.is_owned = (e & 1) || (e == 0);
8577         e_conv = DecodeError_clone(&e_conv);
8578         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
8579         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
8580         return (long)ret_conv;
8581 }
8582
8583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8584         if ((_res & 1) != 0) return;
8585         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8586         FREE((void*)_res);
8587         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
8588 }
8589
8590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8591         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
8592         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
8593         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
8594         return (long)ret_conv;
8595 }
8596
8597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8598         LDKUpdateFee o_conv;
8599         o_conv.inner = (void*)(o & (~1));
8600         o_conv.is_owned = (o & 1) || (o == 0);
8601         o_conv = UpdateFee_clone(&o_conv);
8602         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
8603         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
8604         return (long)ret_conv;
8605 }
8606
8607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8608         LDKDecodeError e_conv;
8609         e_conv.inner = (void*)(e & (~1));
8610         e_conv.is_owned = (e & 1) || (e == 0);
8611         e_conv = DecodeError_clone(&e_conv);
8612         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
8613         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
8614         return (long)ret_conv;
8615 }
8616
8617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8618         if ((_res & 1) != 0) return;
8619         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
8620         FREE((void*)_res);
8621         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
8622 }
8623
8624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8625         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
8626         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
8627         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
8628         return (long)ret_conv;
8629 }
8630
8631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8632         LDKUpdateFulfillHTLC o_conv;
8633         o_conv.inner = (void*)(o & (~1));
8634         o_conv.is_owned = (o & 1) || (o == 0);
8635         o_conv = UpdateFulfillHTLC_clone(&o_conv);
8636         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
8637         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
8638         return (long)ret_conv;
8639 }
8640
8641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8642         LDKDecodeError e_conv;
8643         e_conv.inner = (void*)(e & (~1));
8644         e_conv.is_owned = (e & 1) || (e == 0);
8645         e_conv = DecodeError_clone(&e_conv);
8646         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
8647         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
8648         return (long)ret_conv;
8649 }
8650
8651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8652         if ((_res & 1) != 0) return;
8653         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8654         FREE((void*)_res);
8655         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
8656 }
8657
8658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8659         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
8660         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
8661         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
8662         return (long)ret_conv;
8663 }
8664
8665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8666         LDKUpdateAddHTLC o_conv;
8667         o_conv.inner = (void*)(o & (~1));
8668         o_conv.is_owned = (o & 1) || (o == 0);
8669         o_conv = UpdateAddHTLC_clone(&o_conv);
8670         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
8671         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
8672         return (long)ret_conv;
8673 }
8674
8675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8676         LDKDecodeError e_conv;
8677         e_conv.inner = (void*)(e & (~1));
8678         e_conv.is_owned = (e & 1) || (e == 0);
8679         e_conv = DecodeError_clone(&e_conv);
8680         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
8681         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
8682         return (long)ret_conv;
8683 }
8684
8685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8686         if ((_res & 1) != 0) return;
8687         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8688         FREE((void*)_res);
8689         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
8690 }
8691
8692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8693         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
8694         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
8695         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
8696         return (long)ret_conv;
8697 }
8698
8699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8700         LDKPing o_conv;
8701         o_conv.inner = (void*)(o & (~1));
8702         o_conv.is_owned = (o & 1) || (o == 0);
8703         o_conv = Ping_clone(&o_conv);
8704         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
8705         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
8706         return (long)ret_conv;
8707 }
8708
8709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8710         LDKDecodeError e_conv;
8711         e_conv.inner = (void*)(e & (~1));
8712         e_conv.is_owned = (e & 1) || (e == 0);
8713         e_conv = DecodeError_clone(&e_conv);
8714         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
8715         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
8716         return (long)ret_conv;
8717 }
8718
8719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8720         if ((_res & 1) != 0) return;
8721         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
8722         FREE((void*)_res);
8723         CResult_PingDecodeErrorZ_free(_res_conv);
8724 }
8725
8726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8727         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
8728         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
8729         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
8730         return (long)ret_conv;
8731 }
8732
8733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8734         LDKPong o_conv;
8735         o_conv.inner = (void*)(o & (~1));
8736         o_conv.is_owned = (o & 1) || (o == 0);
8737         o_conv = Pong_clone(&o_conv);
8738         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
8739         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
8740         return (long)ret_conv;
8741 }
8742
8743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8744         LDKDecodeError e_conv;
8745         e_conv.inner = (void*)(e & (~1));
8746         e_conv.is_owned = (e & 1) || (e == 0);
8747         e_conv = DecodeError_clone(&e_conv);
8748         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
8749         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
8750         return (long)ret_conv;
8751 }
8752
8753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8754         if ((_res & 1) != 0) return;
8755         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
8756         FREE((void*)_res);
8757         CResult_PongDecodeErrorZ_free(_res_conv);
8758 }
8759
8760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8761         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
8762         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
8763         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
8764         return (long)ret_conv;
8765 }
8766
8767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8768         LDKUnsignedChannelAnnouncement o_conv;
8769         o_conv.inner = (void*)(o & (~1));
8770         o_conv.is_owned = (o & 1) || (o == 0);
8771         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
8772         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
8773         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
8774         return (long)ret_conv;
8775 }
8776
8777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8778         LDKDecodeError e_conv;
8779         e_conv.inner = (void*)(e & (~1));
8780         e_conv.is_owned = (e & 1) || (e == 0);
8781         e_conv = DecodeError_clone(&e_conv);
8782         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
8783         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
8784         return (long)ret_conv;
8785 }
8786
8787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8788         if ((_res & 1) != 0) return;
8789         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8790         FREE((void*)_res);
8791         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
8792 }
8793
8794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8795         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
8796         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
8797         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
8798         return (long)ret_conv;
8799 }
8800
8801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8802         LDKChannelAnnouncement o_conv;
8803         o_conv.inner = (void*)(o & (~1));
8804         o_conv.is_owned = (o & 1) || (o == 0);
8805         o_conv = ChannelAnnouncement_clone(&o_conv);
8806         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
8807         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
8808         return (long)ret_conv;
8809 }
8810
8811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8812         LDKDecodeError e_conv;
8813         e_conv.inner = (void*)(e & (~1));
8814         e_conv.is_owned = (e & 1) || (e == 0);
8815         e_conv = DecodeError_clone(&e_conv);
8816         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
8817         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
8818         return (long)ret_conv;
8819 }
8820
8821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8822         if ((_res & 1) != 0) return;
8823         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8824         FREE((void*)_res);
8825         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
8826 }
8827
8828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8829         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
8830         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
8831         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
8832         return (long)ret_conv;
8833 }
8834
8835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8836         LDKUnsignedChannelUpdate o_conv;
8837         o_conv.inner = (void*)(o & (~1));
8838         o_conv.is_owned = (o & 1) || (o == 0);
8839         o_conv = UnsignedChannelUpdate_clone(&o_conv);
8840         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
8841         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
8842         return (long)ret_conv;
8843 }
8844
8845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8846         LDKDecodeError e_conv;
8847         e_conv.inner = (void*)(e & (~1));
8848         e_conv.is_owned = (e & 1) || (e == 0);
8849         e_conv = DecodeError_clone(&e_conv);
8850         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
8851         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
8852         return (long)ret_conv;
8853 }
8854
8855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8856         if ((_res & 1) != 0) return;
8857         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8858         FREE((void*)_res);
8859         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
8860 }
8861
8862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8863         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
8864         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
8865         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
8866         return (long)ret_conv;
8867 }
8868
8869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8870         LDKChannelUpdate o_conv;
8871         o_conv.inner = (void*)(o & (~1));
8872         o_conv.is_owned = (o & 1) || (o == 0);
8873         o_conv = ChannelUpdate_clone(&o_conv);
8874         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
8875         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
8876         return (long)ret_conv;
8877 }
8878
8879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8880         LDKDecodeError e_conv;
8881         e_conv.inner = (void*)(e & (~1));
8882         e_conv.is_owned = (e & 1) || (e == 0);
8883         e_conv = DecodeError_clone(&e_conv);
8884         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
8885         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
8886         return (long)ret_conv;
8887 }
8888
8889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8890         if ((_res & 1) != 0) return;
8891         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8892         FREE((void*)_res);
8893         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
8894 }
8895
8896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8897         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
8898         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
8899         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
8900         return (long)ret_conv;
8901 }
8902
8903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8904         LDKErrorMessage o_conv;
8905         o_conv.inner = (void*)(o & (~1));
8906         o_conv.is_owned = (o & 1) || (o == 0);
8907         o_conv = ErrorMessage_clone(&o_conv);
8908         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
8909         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
8910         return (long)ret_conv;
8911 }
8912
8913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8914         LDKDecodeError e_conv;
8915         e_conv.inner = (void*)(e & (~1));
8916         e_conv.is_owned = (e & 1) || (e == 0);
8917         e_conv = DecodeError_clone(&e_conv);
8918         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
8919         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
8920         return (long)ret_conv;
8921 }
8922
8923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8924         if ((_res & 1) != 0) return;
8925         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
8926         FREE((void*)_res);
8927         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
8928 }
8929
8930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8931         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
8932         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
8933         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
8934         return (long)ret_conv;
8935 }
8936
8937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8938         LDKUnsignedNodeAnnouncement o_conv;
8939         o_conv.inner = (void*)(o & (~1));
8940         o_conv.is_owned = (o & 1) || (o == 0);
8941         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
8942         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
8943         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
8944         return (long)ret_conv;
8945 }
8946
8947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8948         LDKDecodeError e_conv;
8949         e_conv.inner = (void*)(e & (~1));
8950         e_conv.is_owned = (e & 1) || (e == 0);
8951         e_conv = DecodeError_clone(&e_conv);
8952         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
8953         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
8954         return (long)ret_conv;
8955 }
8956
8957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8958         if ((_res & 1) != 0) return;
8959         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8960         FREE((void*)_res);
8961         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
8962 }
8963
8964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8965         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
8966         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
8967         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
8968         return (long)ret_conv;
8969 }
8970
8971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8972         LDKNodeAnnouncement o_conv;
8973         o_conv.inner = (void*)(o & (~1));
8974         o_conv.is_owned = (o & 1) || (o == 0);
8975         o_conv = NodeAnnouncement_clone(&o_conv);
8976         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
8977         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
8978         return (long)ret_conv;
8979 }
8980
8981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8982         LDKDecodeError e_conv;
8983         e_conv.inner = (void*)(e & (~1));
8984         e_conv.is_owned = (e & 1) || (e == 0);
8985         e_conv = DecodeError_clone(&e_conv);
8986         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
8987         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
8988         return (long)ret_conv;
8989 }
8990
8991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8992         if ((_res & 1) != 0) return;
8993         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8994         FREE((void*)_res);
8995         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
8996 }
8997
8998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8999         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
9000         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9001         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
9002         return (long)ret_conv;
9003 }
9004
9005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9006         LDKQueryShortChannelIds o_conv;
9007         o_conv.inner = (void*)(o & (~1));
9008         o_conv.is_owned = (o & 1) || (o == 0);
9009         o_conv = QueryShortChannelIds_clone(&o_conv);
9010         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9011         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
9012         return (long)ret_conv;
9013 }
9014
9015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9016         LDKDecodeError e_conv;
9017         e_conv.inner = (void*)(e & (~1));
9018         e_conv.is_owned = (e & 1) || (e == 0);
9019         e_conv = DecodeError_clone(&e_conv);
9020         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9021         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
9022         return (long)ret_conv;
9023 }
9024
9025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9026         if ((_res & 1) != 0) return;
9027         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
9028         FREE((void*)_res);
9029         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
9030 }
9031
9032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9033         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
9034         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9035         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
9036         return (long)ret_conv;
9037 }
9038
9039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9040         LDKReplyShortChannelIdsEnd o_conv;
9041         o_conv.inner = (void*)(o & (~1));
9042         o_conv.is_owned = (o & 1) || (o == 0);
9043         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
9044         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9045         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
9046         return (long)ret_conv;
9047 }
9048
9049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9050         LDKDecodeError e_conv;
9051         e_conv.inner = (void*)(e & (~1));
9052         e_conv.is_owned = (e & 1) || (e == 0);
9053         e_conv = DecodeError_clone(&e_conv);
9054         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9055         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
9056         return (long)ret_conv;
9057 }
9058
9059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9060         if ((_res & 1) != 0) return;
9061         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
9062         FREE((void*)_res);
9063         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
9064 }
9065
9066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9067         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
9068         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9069         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
9070         return (long)ret_conv;
9071 }
9072
9073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9074         LDKQueryChannelRange o_conv;
9075         o_conv.inner = (void*)(o & (~1));
9076         o_conv.is_owned = (o & 1) || (o == 0);
9077         o_conv = QueryChannelRange_clone(&o_conv);
9078         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9079         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
9080         return (long)ret_conv;
9081 }
9082
9083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9084         LDKDecodeError e_conv;
9085         e_conv.inner = (void*)(e & (~1));
9086         e_conv.is_owned = (e & 1) || (e == 0);
9087         e_conv = DecodeError_clone(&e_conv);
9088         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9089         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
9090         return (long)ret_conv;
9091 }
9092
9093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9094         if ((_res & 1) != 0) return;
9095         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9096         FREE((void*)_res);
9097         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
9098 }
9099
9100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9101         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
9102         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9103         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
9104         return (long)ret_conv;
9105 }
9106
9107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9108         LDKReplyChannelRange o_conv;
9109         o_conv.inner = (void*)(o & (~1));
9110         o_conv.is_owned = (o & 1) || (o == 0);
9111         o_conv = ReplyChannelRange_clone(&o_conv);
9112         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
9113         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
9114         return (long)ret_conv;
9115 }
9116
9117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9118         LDKDecodeError e_conv;
9119         e_conv.inner = (void*)(e & (~1));
9120         e_conv.is_owned = (e & 1) || (e == 0);
9121         e_conv = DecodeError_clone(&e_conv);
9122         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
9123         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
9124         return (long)ret_conv;
9125 }
9126
9127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9128         if ((_res & 1) != 0) return;
9129         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9130         FREE((void*)_res);
9131         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
9132 }
9133
9134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9135         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
9136         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
9137         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
9138         return (long)ret_conv;
9139 }
9140
9141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9142         LDKGossipTimestampFilter o_conv;
9143         o_conv.inner = (void*)(o & (~1));
9144         o_conv.is_owned = (o & 1) || (o == 0);
9145         o_conv = GossipTimestampFilter_clone(&o_conv);
9146         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
9147         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
9148         return (long)ret_conv;
9149 }
9150
9151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9152         LDKDecodeError e_conv;
9153         e_conv.inner = (void*)(e & (~1));
9154         e_conv.is_owned = (e & 1) || (e == 0);
9155         e_conv = DecodeError_clone(&e_conv);
9156         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
9157         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
9158         return (long)ret_conv;
9159 }
9160
9161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9162         if ((_res & 1) != 0) return;
9163         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
9164         FREE((void*)_res);
9165         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
9166 }
9167
9168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9169         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
9170         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
9171         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
9172         return (long)ret_conv;
9173 }
9174
9175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9176         if ((this_ptr & 1) != 0) return;
9177         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
9178         FREE((void*)this_ptr);
9179         Event_free(this_ptr_conv);
9180 }
9181
9182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9183         LDKEvent* orig_conv = (LDKEvent*)orig;
9184         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
9185         *ret_copy = Event_clone(orig_conv);
9186         long ret_ref = (long)ret_copy;
9187         return ret_ref;
9188 }
9189
9190 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
9191         LDKEvent* obj_conv = (LDKEvent*)obj;
9192         LDKCVec_u8Z arg_var = Event_write(obj_conv);
9193         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
9194         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
9195         CVec_u8Z_free(arg_var);
9196         return arg_arr;
9197 }
9198
9199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9200         if ((this_ptr & 1) != 0) return;
9201         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
9202         FREE((void*)this_ptr);
9203         MessageSendEvent_free(this_ptr_conv);
9204 }
9205
9206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9207         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
9208         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
9209         *ret_copy = MessageSendEvent_clone(orig_conv);
9210         long ret_ref = (long)ret_copy;
9211         return ret_ref;
9212 }
9213
9214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9215         if ((this_ptr & 1) != 0) return;
9216         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
9217         FREE((void*)this_ptr);
9218         MessageSendEventsProvider_free(this_ptr_conv);
9219 }
9220
9221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9222         if ((this_ptr & 1) != 0) return;
9223         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
9224         FREE((void*)this_ptr);
9225         EventsProvider_free(this_ptr_conv);
9226 }
9227
9228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9229         if ((this_ptr & 1) != 0) return;
9230         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
9231         FREE((void*)this_ptr);
9232         APIError_free(this_ptr_conv);
9233 }
9234
9235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9236         LDKAPIError* orig_conv = (LDKAPIError*)orig;
9237         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
9238         *ret_copy = APIError_clone(orig_conv);
9239         long ret_ref = (long)ret_copy;
9240         return ret_ref;
9241 }
9242
9243 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9244         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
9245         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
9246         return ret_conv;
9247 }
9248
9249 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
9250         jclass ret_conv = LDKLevel_to_java(env, Level_max());
9251         return ret_conv;
9252 }
9253
9254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9255         if ((this_ptr & 1) != 0) return;
9256         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
9257         FREE((void*)this_ptr);
9258         Logger_free(this_ptr_conv);
9259 }
9260
9261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9262         LDKChannelHandshakeConfig this_ptr_conv;
9263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9264         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9265         ChannelHandshakeConfig_free(this_ptr_conv);
9266 }
9267
9268 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
9269         LDKChannelHandshakeConfig this_ptr_conv;
9270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9271         this_ptr_conv.is_owned = false;
9272         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
9273         return ret_val;
9274 }
9275
9276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
9277         LDKChannelHandshakeConfig this_ptr_conv;
9278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9279         this_ptr_conv.is_owned = false;
9280         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
9281 }
9282
9283 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
9284         LDKChannelHandshakeConfig this_ptr_conv;
9285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9286         this_ptr_conv.is_owned = false;
9287         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
9288         return ret_val;
9289 }
9290
9291 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) {
9292         LDKChannelHandshakeConfig this_ptr_conv;
9293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9294         this_ptr_conv.is_owned = false;
9295         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
9296 }
9297
9298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
9299         LDKChannelHandshakeConfig this_ptr_conv;
9300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9301         this_ptr_conv.is_owned = false;
9302         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
9303         return ret_val;
9304 }
9305
9306 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) {
9307         LDKChannelHandshakeConfig this_ptr_conv;
9308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9309         this_ptr_conv.is_owned = false;
9310         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
9311 }
9312
9313 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) {
9314         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
9315         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9316         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9317         long ret_ref = (long)ret_var.inner;
9318         if (ret_var.is_owned) {
9319                 ret_ref |= 1;
9320         }
9321         return ret_ref;
9322 }
9323
9324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9325         LDKChannelHandshakeConfig orig_conv;
9326         orig_conv.inner = (void*)(orig & (~1));
9327         orig_conv.is_owned = false;
9328         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
9329         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9330         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9331         long ret_ref = (long)ret_var.inner;
9332         if (ret_var.is_owned) {
9333                 ret_ref |= 1;
9334         }
9335         return ret_ref;
9336 }
9337
9338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
9339         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
9340         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9341         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9342         long ret_ref = (long)ret_var.inner;
9343         if (ret_var.is_owned) {
9344                 ret_ref |= 1;
9345         }
9346         return ret_ref;
9347 }
9348
9349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9350         LDKChannelHandshakeLimits this_ptr_conv;
9351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9352         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9353         ChannelHandshakeLimits_free(this_ptr_conv);
9354 }
9355
9356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
9357         LDKChannelHandshakeLimits this_ptr_conv;
9358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9359         this_ptr_conv.is_owned = false;
9360         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
9361         return ret_val;
9362 }
9363
9364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
9365         LDKChannelHandshakeLimits this_ptr_conv;
9366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9367         this_ptr_conv.is_owned = false;
9368         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
9369 }
9370
9371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
9372         LDKChannelHandshakeLimits this_ptr_conv;
9373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9374         this_ptr_conv.is_owned = false;
9375         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
9376         return ret_val;
9377 }
9378
9379 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) {
9380         LDKChannelHandshakeLimits this_ptr_conv;
9381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9382         this_ptr_conv.is_owned = false;
9383         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
9384 }
9385
9386 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) {
9387         LDKChannelHandshakeLimits this_ptr_conv;
9388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9389         this_ptr_conv.is_owned = false;
9390         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
9391         return ret_val;
9392 }
9393
9394 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) {
9395         LDKChannelHandshakeLimits this_ptr_conv;
9396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9397         this_ptr_conv.is_owned = false;
9398         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
9399 }
9400
9401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
9402         LDKChannelHandshakeLimits this_ptr_conv;
9403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9404         this_ptr_conv.is_owned = false;
9405         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
9406         return ret_val;
9407 }
9408
9409 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) {
9410         LDKChannelHandshakeLimits this_ptr_conv;
9411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9412         this_ptr_conv.is_owned = false;
9413         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
9414 }
9415
9416 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
9417         LDKChannelHandshakeLimits this_ptr_conv;
9418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9419         this_ptr_conv.is_owned = false;
9420         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
9421         return ret_val;
9422 }
9423
9424 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) {
9425         LDKChannelHandshakeLimits this_ptr_conv;
9426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9427         this_ptr_conv.is_owned = false;
9428         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
9429 }
9430
9431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
9432         LDKChannelHandshakeLimits this_ptr_conv;
9433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9434         this_ptr_conv.is_owned = false;
9435         int64_t ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
9436         return ret_val;
9437 }
9438
9439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
9440         LDKChannelHandshakeLimits this_ptr_conv;
9441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9442         this_ptr_conv.is_owned = false;
9443         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
9444 }
9445
9446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
9447         LDKChannelHandshakeLimits this_ptr_conv;
9448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9449         this_ptr_conv.is_owned = false;
9450         int64_t ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
9451         return ret_val;
9452 }
9453
9454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
9455         LDKChannelHandshakeLimits this_ptr_conv;
9456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9457         this_ptr_conv.is_owned = false;
9458         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
9459 }
9460
9461 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
9462         LDKChannelHandshakeLimits this_ptr_conv;
9463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9464         this_ptr_conv.is_owned = false;
9465         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
9466         return ret_val;
9467 }
9468
9469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
9470         LDKChannelHandshakeLimits this_ptr_conv;
9471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9472         this_ptr_conv.is_owned = false;
9473         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
9474 }
9475
9476 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
9477         LDKChannelHandshakeLimits this_ptr_conv;
9478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9479         this_ptr_conv.is_owned = false;
9480         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
9481         return ret_val;
9482 }
9483
9484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
9485         LDKChannelHandshakeLimits this_ptr_conv;
9486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9487         this_ptr_conv.is_owned = false;
9488         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
9489 }
9490
9491 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
9492         LDKChannelHandshakeLimits this_ptr_conv;
9493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9494         this_ptr_conv.is_owned = false;
9495         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
9496         return ret_val;
9497 }
9498
9499 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) {
9500         LDKChannelHandshakeLimits this_ptr_conv;
9501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9502         this_ptr_conv.is_owned = false;
9503         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
9504 }
9505
9506 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, int64_t min_dust_limit_satoshis_arg, int64_t max_dust_limit_satoshis_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
9507         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, min_dust_limit_satoshis_arg, max_dust_limit_satoshis_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
9508         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9509         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9510         long ret_ref = (long)ret_var.inner;
9511         if (ret_var.is_owned) {
9512                 ret_ref |= 1;
9513         }
9514         return ret_ref;
9515 }
9516
9517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9518         LDKChannelHandshakeLimits orig_conv;
9519         orig_conv.inner = (void*)(orig & (~1));
9520         orig_conv.is_owned = false;
9521         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
9522         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9523         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9524         long ret_ref = (long)ret_var.inner;
9525         if (ret_var.is_owned) {
9526                 ret_ref |= 1;
9527         }
9528         return ret_ref;
9529 }
9530
9531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
9532         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
9533         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9534         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9535         long ret_ref = (long)ret_var.inner;
9536         if (ret_var.is_owned) {
9537                 ret_ref |= 1;
9538         }
9539         return ret_ref;
9540 }
9541
9542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9543         LDKChannelConfig this_ptr_conv;
9544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9545         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9546         ChannelConfig_free(this_ptr_conv);
9547 }
9548
9549 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
9550         LDKChannelConfig this_ptr_conv;
9551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9552         this_ptr_conv.is_owned = false;
9553         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
9554         return ret_val;
9555 }
9556
9557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
9558         LDKChannelConfig this_ptr_conv;
9559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9560         this_ptr_conv.is_owned = false;
9561         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
9562 }
9563
9564 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
9565         LDKChannelConfig this_ptr_conv;
9566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9567         this_ptr_conv.is_owned = false;
9568         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
9569         return ret_val;
9570 }
9571
9572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
9573         LDKChannelConfig this_ptr_conv;
9574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9575         this_ptr_conv.is_owned = false;
9576         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
9577 }
9578
9579 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
9580         LDKChannelConfig this_ptr_conv;
9581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9582         this_ptr_conv.is_owned = false;
9583         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
9584         return ret_val;
9585 }
9586
9587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
9588         LDKChannelConfig this_ptr_conv;
9589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9590         this_ptr_conv.is_owned = false;
9591         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
9592 }
9593
9594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t fee_proportional_millionths_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
9595         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
9596         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9597         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9598         long ret_ref = (long)ret_var.inner;
9599         if (ret_var.is_owned) {
9600                 ret_ref |= 1;
9601         }
9602         return ret_ref;
9603 }
9604
9605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9606         LDKChannelConfig orig_conv;
9607         orig_conv.inner = (void*)(orig & (~1));
9608         orig_conv.is_owned = false;
9609         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
9610         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9611         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9612         long ret_ref = (long)ret_var.inner;
9613         if (ret_var.is_owned) {
9614                 ret_ref |= 1;
9615         }
9616         return ret_ref;
9617 }
9618
9619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
9620         LDKChannelConfig ret_var = ChannelConfig_default();
9621         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9622         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9623         long ret_ref = (long)ret_var.inner;
9624         if (ret_var.is_owned) {
9625                 ret_ref |= 1;
9626         }
9627         return ret_ref;
9628 }
9629
9630 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
9631         LDKChannelConfig obj_conv;
9632         obj_conv.inner = (void*)(obj & (~1));
9633         obj_conv.is_owned = false;
9634         LDKCVec_u8Z arg_var = ChannelConfig_write(&obj_conv);
9635         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
9636         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
9637         CVec_u8Z_free(arg_var);
9638         return arg_arr;
9639 }
9640
9641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
9642         LDKu8slice ser_ref;
9643         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
9644         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
9645         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9646         *ret_conv = ChannelConfig_read(ser_ref);
9647         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
9648         return (long)ret_conv;
9649 }
9650
9651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9652         LDKUserConfig this_ptr_conv;
9653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9654         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9655         UserConfig_free(this_ptr_conv);
9656 }
9657
9658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
9659         LDKUserConfig this_ptr_conv;
9660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9661         this_ptr_conv.is_owned = false;
9662         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
9663         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9664         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9665         long ret_ref = (long)ret_var.inner;
9666         if (ret_var.is_owned) {
9667                 ret_ref |= 1;
9668         }
9669         return ret_ref;
9670 }
9671
9672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
9673         LDKUserConfig this_ptr_conv;
9674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9675         this_ptr_conv.is_owned = false;
9676         LDKChannelHandshakeConfig val_conv;
9677         val_conv.inner = (void*)(val & (~1));
9678         val_conv.is_owned = (val & 1) || (val == 0);
9679         val_conv = ChannelHandshakeConfig_clone(&val_conv);
9680         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
9681 }
9682
9683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
9684         LDKUserConfig this_ptr_conv;
9685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9686         this_ptr_conv.is_owned = false;
9687         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
9688         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9689         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9690         long ret_ref = (long)ret_var.inner;
9691         if (ret_var.is_owned) {
9692                 ret_ref |= 1;
9693         }
9694         return ret_ref;
9695 }
9696
9697 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) {
9698         LDKUserConfig this_ptr_conv;
9699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9700         this_ptr_conv.is_owned = false;
9701         LDKChannelHandshakeLimits val_conv;
9702         val_conv.inner = (void*)(val & (~1));
9703         val_conv.is_owned = (val & 1) || (val == 0);
9704         val_conv = ChannelHandshakeLimits_clone(&val_conv);
9705         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
9706 }
9707
9708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
9709         LDKUserConfig this_ptr_conv;
9710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9711         this_ptr_conv.is_owned = false;
9712         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
9713         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9714         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9715         long ret_ref = (long)ret_var.inner;
9716         if (ret_var.is_owned) {
9717                 ret_ref |= 1;
9718         }
9719         return ret_ref;
9720 }
9721
9722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
9723         LDKUserConfig this_ptr_conv;
9724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9725         this_ptr_conv.is_owned = false;
9726         LDKChannelConfig val_conv;
9727         val_conv.inner = (void*)(val & (~1));
9728         val_conv.is_owned = (val & 1) || (val == 0);
9729         val_conv = ChannelConfig_clone(&val_conv);
9730         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
9731 }
9732
9733 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) {
9734         LDKChannelHandshakeConfig own_channel_config_arg_conv;
9735         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
9736         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
9737         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
9738         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
9739         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
9740         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
9741         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
9742         LDKChannelConfig channel_options_arg_conv;
9743         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
9744         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
9745         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
9746         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
9747         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9748         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9749         long ret_ref = (long)ret_var.inner;
9750         if (ret_var.is_owned) {
9751                 ret_ref |= 1;
9752         }
9753         return ret_ref;
9754 }
9755
9756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9757         LDKUserConfig orig_conv;
9758         orig_conv.inner = (void*)(orig & (~1));
9759         orig_conv.is_owned = false;
9760         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
9761         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9762         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9763         long ret_ref = (long)ret_var.inner;
9764         if (ret_var.is_owned) {
9765                 ret_ref |= 1;
9766         }
9767         return ret_ref;
9768 }
9769
9770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
9771         LDKUserConfig ret_var = UserConfig_default();
9772         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9773         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9774         long ret_ref = (long)ret_var.inner;
9775         if (ret_var.is_owned) {
9776                 ret_ref |= 1;
9777         }
9778         return ret_ref;
9779 }
9780
9781 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9782         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
9783         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
9784         return ret_conv;
9785 }
9786
9787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9788         if ((this_ptr & 1) != 0) return;
9789         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
9790         FREE((void*)this_ptr);
9791         Access_free(this_ptr_conv);
9792 }
9793
9794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9795         if ((this_ptr & 1) != 0) return;
9796         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
9797         FREE((void*)this_ptr);
9798         Watch_free(this_ptr_conv);
9799 }
9800
9801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9802         if ((this_ptr & 1) != 0) return;
9803         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
9804         FREE((void*)this_ptr);
9805         Filter_free(this_ptr_conv);
9806 }
9807
9808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9809         if ((this_ptr & 1) != 0) return;
9810         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
9811         FREE((void*)this_ptr);
9812         BroadcasterInterface_free(this_ptr_conv);
9813 }
9814
9815 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9816         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
9817         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
9818         return ret_conv;
9819 }
9820
9821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9822         if ((this_ptr & 1) != 0) return;
9823         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
9824         FREE((void*)this_ptr);
9825         FeeEstimator_free(this_ptr_conv);
9826 }
9827
9828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9829         LDKChainMonitor this_ptr_conv;
9830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9831         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9832         ChainMonitor_free(this_ptr_conv);
9833 }
9834
9835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
9836         LDKChainMonitor this_arg_conv;
9837         this_arg_conv.inner = (void*)(this_arg & (~1));
9838         this_arg_conv.is_owned = false;
9839         unsigned char header_arr[80];
9840         CHECK((*env)->GetArrayLength(env, header) == 80);
9841         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
9842         unsigned char (*header_ref)[80] = &header_arr;
9843         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
9844         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
9845         if (txdata_constr.datalen > 0)
9846                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9847         else
9848                 txdata_constr.data = NULL;
9849         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
9850         for (size_t y = 0; y < txdata_constr.datalen; y++) {
9851                 int64_t arr_conv_24 = txdata_vals[y];
9852                 LDKC2Tuple_usizeTransactionZ arr_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_conv_24) & ~1);
9853                 FREE((void*)arr_conv_24);
9854                 txdata_constr.data[y] = arr_conv_24_conv;
9855         }
9856         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
9857         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
9858 }
9859
9860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t disconnected_height) {
9861         LDKChainMonitor this_arg_conv;
9862         this_arg_conv.inner = (void*)(this_arg & (~1));
9863         this_arg_conv.is_owned = false;
9864         unsigned char header_arr[80];
9865         CHECK((*env)->GetArrayLength(env, header) == 80);
9866         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
9867         unsigned char (*header_ref)[80] = &header_arr;
9868         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
9869 }
9870
9871 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) {
9872         LDKFilter* chain_source_conv = (LDKFilter*)chain_source;
9873         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
9874         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
9875                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9876                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
9877         }
9878         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
9879         if (logger_conv.free == LDKLogger_JCalls_free) {
9880                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9881                 LDKLogger_JCalls_clone(logger_conv.this_arg);
9882         }
9883         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
9884         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
9885                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9886                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
9887         }
9888         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
9889         if (persister_conv.free == LDKPersist_JCalls_free) {
9890                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9891                 LDKPersist_JCalls_clone(persister_conv.this_arg);
9892         }
9893         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
9894         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9895         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9896         long ret_ref = (long)ret_var.inner;
9897         if (ret_var.is_owned) {
9898                 ret_ref |= 1;
9899         }
9900         return ret_ref;
9901 }
9902
9903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
9904         LDKChainMonitor this_arg_conv;
9905         this_arg_conv.inner = (void*)(this_arg & (~1));
9906         this_arg_conv.is_owned = false;
9907         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
9908         *ret = ChainMonitor_as_Watch(&this_arg_conv);
9909         return (long)ret;
9910 }
9911
9912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
9913         LDKChainMonitor this_arg_conv;
9914         this_arg_conv.inner = (void*)(this_arg & (~1));
9915         this_arg_conv.is_owned = false;
9916         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
9917         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
9918         return (long)ret;
9919 }
9920
9921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9922         LDKChannelMonitorUpdate this_ptr_conv;
9923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9924         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9925         ChannelMonitorUpdate_free(this_ptr_conv);
9926 }
9927
9928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
9929         LDKChannelMonitorUpdate this_ptr_conv;
9930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9931         this_ptr_conv.is_owned = false;
9932         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
9933         return ret_val;
9934 }
9935
9936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
9937         LDKChannelMonitorUpdate this_ptr_conv;
9938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9939         this_ptr_conv.is_owned = false;
9940         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
9941 }
9942
9943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9944         LDKChannelMonitorUpdate orig_conv;
9945         orig_conv.inner = (void*)(orig & (~1));
9946         orig_conv.is_owned = false;
9947         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
9948         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9949         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9950         long ret_ref = (long)ret_var.inner;
9951         if (ret_var.is_owned) {
9952                 ret_ref |= 1;
9953         }
9954         return ret_ref;
9955 }
9956
9957 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
9958         LDKChannelMonitorUpdate obj_conv;
9959         obj_conv.inner = (void*)(obj & (~1));
9960         obj_conv.is_owned = false;
9961         LDKCVec_u8Z arg_var = ChannelMonitorUpdate_write(&obj_conv);
9962         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
9963         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
9964         CVec_u8Z_free(arg_var);
9965         return arg_arr;
9966 }
9967
9968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
9969         LDKu8slice ser_ref;
9970         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
9971         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
9972         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
9973         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
9974         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
9975         return (long)ret_conv;
9976 }
9977
9978 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9979         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
9980         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
9981         return ret_conv;
9982 }
9983
9984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9985         LDKMonitorUpdateError this_ptr_conv;
9986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9987         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9988         MonitorUpdateError_free(this_ptr_conv);
9989 }
9990
9991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9992         LDKMonitorUpdateError orig_conv;
9993         orig_conv.inner = (void*)(orig & (~1));
9994         orig_conv.is_owned = false;
9995         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
9996         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9997         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9998         long ret_ref = (long)ret_var.inner;
9999         if (ret_var.is_owned) {
10000                 ret_ref |= 1;
10001         }
10002         return ret_ref;
10003 }
10004
10005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10006         LDKMonitorEvent this_ptr_conv;
10007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10008         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10009         MonitorEvent_free(this_ptr_conv);
10010 }
10011
10012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10013         LDKMonitorEvent orig_conv;
10014         orig_conv.inner = (void*)(orig & (~1));
10015         orig_conv.is_owned = false;
10016         LDKMonitorEvent ret_var = MonitorEvent_clone(&orig_conv);
10017         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10018         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10019         long ret_ref = (long)ret_var.inner;
10020         if (ret_var.is_owned) {
10021                 ret_ref |= 1;
10022         }
10023         return ret_ref;
10024 }
10025
10026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10027         LDKHTLCUpdate this_ptr_conv;
10028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10029         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10030         HTLCUpdate_free(this_ptr_conv);
10031 }
10032
10033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10034         LDKHTLCUpdate orig_conv;
10035         orig_conv.inner = (void*)(orig & (~1));
10036         orig_conv.is_owned = false;
10037         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
10038         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10039         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10040         long ret_ref = (long)ret_var.inner;
10041         if (ret_var.is_owned) {
10042                 ret_ref |= 1;
10043         }
10044         return ret_ref;
10045 }
10046
10047 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
10048         LDKHTLCUpdate obj_conv;
10049         obj_conv.inner = (void*)(obj & (~1));
10050         obj_conv.is_owned = false;
10051         LDKCVec_u8Z arg_var = HTLCUpdate_write(&obj_conv);
10052         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
10053         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
10054         CVec_u8Z_free(arg_var);
10055         return arg_arr;
10056 }
10057
10058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10059         LDKu8slice ser_ref;
10060         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10061         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10062         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10063         *ret_conv = HTLCUpdate_read(ser_ref);
10064         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10065         return (long)ret_conv;
10066 }
10067
10068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10069         LDKChannelMonitor this_ptr_conv;
10070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10071         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10072         ChannelMonitor_free(this_ptr_conv);
10073 }
10074
10075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10076         LDKChannelMonitor orig_conv;
10077         orig_conv.inner = (void*)(orig & (~1));
10078         orig_conv.is_owned = false;
10079         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
10080         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10081         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10082         long ret_ref = (long)ret_var.inner;
10083         if (ret_var.is_owned) {
10084                 ret_ref |= 1;
10085         }
10086         return ret_ref;
10087 }
10088
10089 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
10090         LDKChannelMonitor obj_conv;
10091         obj_conv.inner = (void*)(obj & (~1));
10092         obj_conv.is_owned = false;
10093         LDKCVec_u8Z arg_var = ChannelMonitor_write(&obj_conv);
10094         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
10095         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
10096         CVec_u8Z_free(arg_var);
10097         return arg_arr;
10098 }
10099
10100 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) {
10101         LDKChannelMonitor this_arg_conv;
10102         this_arg_conv.inner = (void*)(this_arg & (~1));
10103         this_arg_conv.is_owned = false;
10104         LDKChannelMonitorUpdate updates_conv;
10105         updates_conv.inner = (void*)(updates & (~1));
10106         updates_conv.is_owned = false;
10107         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster;
10108         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator;
10109         LDKLogger* logger_conv = (LDKLogger*)logger;
10110         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10111         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
10112         return (long)ret_conv;
10113 }
10114
10115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
10116         LDKChannelMonitor this_arg_conv;
10117         this_arg_conv.inner = (void*)(this_arg & (~1));
10118         this_arg_conv.is_owned = false;
10119         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
10120         return ret_val;
10121 }
10122
10123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
10124         LDKChannelMonitor this_arg_conv;
10125         this_arg_conv.inner = (void*)(this_arg & (~1));
10126         this_arg_conv.is_owned = false;
10127         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
10128         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
10129         return (long)ret_ref;
10130 }
10131
10132 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10133         LDKChannelMonitor this_arg_conv;
10134         this_arg_conv.inner = (void*)(this_arg & (~1));
10135         this_arg_conv.is_owned = false;
10136         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
10137         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10138         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10139         for (size_t o = 0; o < ret_var.datalen; o++) {
10140                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
10141                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10142                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10143                 long arr_conv_14_ref = (long)arr_conv_14_var.inner;
10144                 if (arr_conv_14_var.is_owned) {
10145                         arr_conv_14_ref |= 1;
10146                 }
10147                 ret_arr_ptr[o] = arr_conv_14_ref;
10148         }
10149         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10150         FREE(ret_var.data);
10151         return ret_arr;
10152 }
10153
10154 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10155         LDKChannelMonitor this_arg_conv;
10156         this_arg_conv.inner = (void*)(this_arg & (~1));
10157         this_arg_conv.is_owned = false;
10158         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
10159         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10160         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10161         for (size_t h = 0; h < ret_var.datalen; h++) {
10162                 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
10163                 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
10164                 long arr_conv_7_ref = (long)arr_conv_7_copy;
10165                 ret_arr_ptr[h] = arr_conv_7_ref;
10166         }
10167         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10168         FREE(ret_var.data);
10169         return ret_arr;
10170 }
10171
10172 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) {
10173         LDKChannelMonitor this_arg_conv;
10174         this_arg_conv.inner = (void*)(this_arg & (~1));
10175         this_arg_conv.is_owned = false;
10176         LDKLogger* logger_conv = (LDKLogger*)logger;
10177         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
10178         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
10179         ;
10180         for (size_t i = 0; i < ret_var.datalen; i++) {
10181                 LDKTransaction arr_conv_8_var = ret_var.data[i];
10182                 int8_tArray arr_conv_8_arr = (*env)->NewByteArray(env, arr_conv_8_var.datalen);
10183                 (*env)->SetByteArrayRegion(env, arr_conv_8_arr, 0, arr_conv_8_var.datalen, arr_conv_8_var.data);
10184                 Transaction_free(arr_conv_8_var);
10185                 (*env)->SetObjectArrayElement(env, ret_arr, i, arr_conv_8_arr);
10186         }
10187         FREE(ret_var.data);
10188         return ret_arr;
10189 }
10190
10191 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) {
10192         LDKChannelMonitor this_arg_conv;
10193         this_arg_conv.inner = (void*)(this_arg & (~1));
10194         this_arg_conv.is_owned = false;
10195         unsigned char header_arr[80];
10196         CHECK((*env)->GetArrayLength(env, header) == 80);
10197         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10198         unsigned char (*header_ref)[80] = &header_arr;
10199         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10200         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
10201         if (txdata_constr.datalen > 0)
10202                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10203         else
10204                 txdata_constr.data = NULL;
10205         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
10206         for (size_t y = 0; y < txdata_constr.datalen; y++) {
10207                 int64_t arr_conv_24 = txdata_vals[y];
10208                 LDKC2Tuple_usizeTransactionZ arr_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_conv_24) & ~1);
10209                 FREE((void*)arr_conv_24);
10210                 txdata_constr.data[y] = arr_conv_24_conv;
10211         }
10212         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
10213         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10214         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
10215                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10216                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
10217         }
10218         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
10219         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
10220                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10221                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
10222         }
10223         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10224         if (logger_conv.free == LDKLogger_JCalls_free) {
10225                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10226                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10227         }
10228         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);
10229         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10230         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10231         for (size_t u = 0; u < ret_var.datalen; u++) {
10232                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arr_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10233                 *arr_conv_46_ref = ret_var.data[u];
10234                 ret_arr_ptr[u] = (long)arr_conv_46_ref;
10235         }
10236         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10237         FREE(ret_var.data);
10238         return ret_arr;
10239 }
10240
10241 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) {
10242         LDKChannelMonitor this_arg_conv;
10243         this_arg_conv.inner = (void*)(this_arg & (~1));
10244         this_arg_conv.is_owned = false;
10245         unsigned char header_arr[80];
10246         CHECK((*env)->GetArrayLength(env, header) == 80);
10247         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10248         unsigned char (*header_ref)[80] = &header_arr;
10249         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10250         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
10251                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10252                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
10253         }
10254         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
10255         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
10256                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10257                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
10258         }
10259         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10260         if (logger_conv.free == LDKLogger_JCalls_free) {
10261                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10262                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10263         }
10264         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
10265 }
10266
10267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10268         if ((this_ptr & 1) != 0) return;
10269         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
10270         FREE((void*)this_ptr);
10271         Persist_free(this_ptr_conv);
10272 }
10273
10274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
10275         LDKu8slice ser_ref;
10276         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10277         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10278         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
10279         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10280         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
10281         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10282         return (long)ret_conv;
10283 }
10284
10285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10286         LDKOutPoint this_ptr_conv;
10287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10288         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10289         OutPoint_free(this_ptr_conv);
10290 }
10291
10292 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
10293         LDKOutPoint this_ptr_conv;
10294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10295         this_ptr_conv.is_owned = false;
10296         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10297         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
10298         return ret_arr;
10299 }
10300
10301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10302         LDKOutPoint this_ptr_conv;
10303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10304         this_ptr_conv.is_owned = false;
10305         LDKThirtyTwoBytes val_ref;
10306         CHECK((*env)->GetArrayLength(env, val) == 32);
10307         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
10308         OutPoint_set_txid(&this_ptr_conv, val_ref);
10309 }
10310
10311 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
10312         LDKOutPoint this_ptr_conv;
10313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10314         this_ptr_conv.is_owned = false;
10315         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
10316         return ret_val;
10317 }
10318
10319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
10320         LDKOutPoint this_ptr_conv;
10321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10322         this_ptr_conv.is_owned = false;
10323         OutPoint_set_index(&this_ptr_conv, val);
10324 }
10325
10326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
10327         LDKThirtyTwoBytes txid_arg_ref;
10328         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
10329         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
10330         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
10331         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10332         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10333         long ret_ref = (long)ret_var.inner;
10334         if (ret_var.is_owned) {
10335                 ret_ref |= 1;
10336         }
10337         return ret_ref;
10338 }
10339
10340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10341         LDKOutPoint orig_conv;
10342         orig_conv.inner = (void*)(orig & (~1));
10343         orig_conv.is_owned = false;
10344         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
10345         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10346         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10347         long ret_ref = (long)ret_var.inner;
10348         if (ret_var.is_owned) {
10349                 ret_ref |= 1;
10350         }
10351         return ret_ref;
10352 }
10353
10354 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
10355         LDKOutPoint this_arg_conv;
10356         this_arg_conv.inner = (void*)(this_arg & (~1));
10357         this_arg_conv.is_owned = false;
10358         int8_tArray arg_arr = (*env)->NewByteArray(env, 32);
10359         (*env)->SetByteArrayRegion(env, arg_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
10360         return arg_arr;
10361 }
10362
10363 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
10364         LDKOutPoint obj_conv;
10365         obj_conv.inner = (void*)(obj & (~1));
10366         obj_conv.is_owned = false;
10367         LDKCVec_u8Z arg_var = OutPoint_write(&obj_conv);
10368         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
10369         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
10370         CVec_u8Z_free(arg_var);
10371         return arg_arr;
10372 }
10373
10374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10375         LDKu8slice ser_ref;
10376         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10377         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10378         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10379         *ret_conv = OutPoint_read(ser_ref);
10380         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10381         return (long)ret_conv;
10382 }
10383
10384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10385         if ((this_ptr & 1) != 0) return;
10386         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
10387         FREE((void*)this_ptr);
10388         SpendableOutputDescriptor_free(this_ptr_conv);
10389 }
10390
10391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10392         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
10393         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
10394         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
10395         long ret_ref = (long)ret_copy;
10396         return ret_ref;
10397 }
10398
10399 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
10400         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
10401         LDKCVec_u8Z arg_var = SpendableOutputDescriptor_write(obj_conv);
10402         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
10403         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
10404         CVec_u8Z_free(arg_var);
10405         return arg_arr;
10406 }
10407
10408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10409         LDKu8slice ser_ref;
10410         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10411         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10412         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10413         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
10414         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10415         return (long)ret_conv;
10416 }
10417
10418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10419         LDKChannelKeys* orig_conv = (LDKChannelKeys*)orig;
10420         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
10421         *ret = ChannelKeys_clone(orig_conv);
10422         return (long)ret;
10423 }
10424
10425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10426         if ((this_ptr & 1) != 0) return;
10427         LDKChannelKeys this_ptr_conv = *(LDKChannelKeys*)(((uint64_t)this_ptr) & ~1);
10428         FREE((void*)this_ptr);
10429         ChannelKeys_free(this_ptr_conv);
10430 }
10431
10432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10433         if ((this_ptr & 1) != 0) return;
10434         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
10435         FREE((void*)this_ptr);
10436         KeysInterface_free(this_ptr_conv);
10437 }
10438
10439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10440         LDKInMemoryChannelKeys this_ptr_conv;
10441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10442         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10443         InMemoryChannelKeys_free(this_ptr_conv);
10444 }
10445
10446 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
10447         LDKInMemoryChannelKeys this_ptr_conv;
10448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10449         this_ptr_conv.is_owned = false;
10450         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10451         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemoryChannelKeys_get_funding_key(&this_ptr_conv));
10452         return ret_arr;
10453 }
10454
10455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10456         LDKInMemoryChannelKeys this_ptr_conv;
10457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10458         this_ptr_conv.is_owned = false;
10459         LDKSecretKey val_ref;
10460         CHECK((*env)->GetArrayLength(env, val) == 32);
10461         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
10462         InMemoryChannelKeys_set_funding_key(&this_ptr_conv, val_ref);
10463 }
10464
10465 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
10466         LDKInMemoryChannelKeys this_ptr_conv;
10467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10468         this_ptr_conv.is_owned = false;
10469         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10470         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemoryChannelKeys_get_revocation_base_key(&this_ptr_conv));
10471         return ret_arr;
10472 }
10473
10474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10475         LDKInMemoryChannelKeys this_ptr_conv;
10476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10477         this_ptr_conv.is_owned = false;
10478         LDKSecretKey val_ref;
10479         CHECK((*env)->GetArrayLength(env, val) == 32);
10480         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
10481         InMemoryChannelKeys_set_revocation_base_key(&this_ptr_conv, val_ref);
10482 }
10483
10484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
10485         LDKInMemoryChannelKeys this_ptr_conv;
10486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10487         this_ptr_conv.is_owned = false;
10488         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10489         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemoryChannelKeys_get_payment_key(&this_ptr_conv));
10490         return ret_arr;
10491 }
10492
10493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10494         LDKInMemoryChannelKeys this_ptr_conv;
10495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10496         this_ptr_conv.is_owned = false;
10497         LDKSecretKey val_ref;
10498         CHECK((*env)->GetArrayLength(env, val) == 32);
10499         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
10500         InMemoryChannelKeys_set_payment_key(&this_ptr_conv, val_ref);
10501 }
10502
10503 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
10504         LDKInMemoryChannelKeys this_ptr_conv;
10505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10506         this_ptr_conv.is_owned = false;
10507         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10508         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemoryChannelKeys_get_delayed_payment_base_key(&this_ptr_conv));
10509         return ret_arr;
10510 }
10511
10512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10513         LDKInMemoryChannelKeys this_ptr_conv;
10514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10515         this_ptr_conv.is_owned = false;
10516         LDKSecretKey val_ref;
10517         CHECK((*env)->GetArrayLength(env, val) == 32);
10518         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
10519         InMemoryChannelKeys_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
10520 }
10521
10522 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
10523         LDKInMemoryChannelKeys this_ptr_conv;
10524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10525         this_ptr_conv.is_owned = false;
10526         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10527         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemoryChannelKeys_get_htlc_base_key(&this_ptr_conv));
10528         return ret_arr;
10529 }
10530
10531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10532         LDKInMemoryChannelKeys this_ptr_conv;
10533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10534         this_ptr_conv.is_owned = false;
10535         LDKSecretKey val_ref;
10536         CHECK((*env)->GetArrayLength(env, val) == 32);
10537         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
10538         InMemoryChannelKeys_set_htlc_base_key(&this_ptr_conv, val_ref);
10539 }
10540
10541 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
10542         LDKInMemoryChannelKeys this_ptr_conv;
10543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10544         this_ptr_conv.is_owned = false;
10545         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10546         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemoryChannelKeys_get_commitment_seed(&this_ptr_conv));
10547         return ret_arr;
10548 }
10549
10550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10551         LDKInMemoryChannelKeys this_ptr_conv;
10552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10553         this_ptr_conv.is_owned = false;
10554         LDKThirtyTwoBytes val_ref;
10555         CHECK((*env)->GetArrayLength(env, val) == 32);
10556         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
10557         InMemoryChannelKeys_set_commitment_seed(&this_ptr_conv, val_ref);
10558 }
10559
10560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10561         LDKInMemoryChannelKeys orig_conv;
10562         orig_conv.inner = (void*)(orig & (~1));
10563         orig_conv.is_owned = false;
10564         LDKInMemoryChannelKeys ret_var = InMemoryChannelKeys_clone(&orig_conv);
10565         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10566         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10567         long ret_ref = (long)ret_var.inner;
10568         if (ret_var.is_owned) {
10569                 ret_ref |= 1;
10570         }
10571         return ret_ref;
10572 }
10573
10574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_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, int64_t key_derivation_params) {
10575         LDKSecretKey funding_key_ref;
10576         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
10577         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
10578         LDKSecretKey revocation_base_key_ref;
10579         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
10580         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
10581         LDKSecretKey payment_key_ref;
10582         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
10583         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
10584         LDKSecretKey delayed_payment_base_key_ref;
10585         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
10586         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
10587         LDKSecretKey htlc_base_key_ref;
10588         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
10589         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
10590         LDKThirtyTwoBytes commitment_seed_ref;
10591         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
10592         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
10593         LDKC2Tuple_u64u64Z key_derivation_params_conv = *(LDKC2Tuple_u64u64Z*)(((uint64_t)key_derivation_params) & ~1);
10594         FREE((void*)key_derivation_params);
10595         LDKInMemoryChannelKeys ret_var = InMemoryChannelKeys_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, key_derivation_params_conv);
10596         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10597         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10598         long ret_ref = (long)ret_var.inner;
10599         if (ret_var.is_owned) {
10600                 ret_ref |= 1;
10601         }
10602         return ret_ref;
10603 }
10604
10605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
10606         LDKInMemoryChannelKeys this_arg_conv;
10607         this_arg_conv.inner = (void*)(this_arg & (~1));
10608         this_arg_conv.is_owned = false;
10609         LDKChannelPublicKeys ret_var = InMemoryChannelKeys_counterparty_pubkeys(&this_arg_conv);
10610         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10611         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10612         long ret_ref = (long)ret_var.inner;
10613         if (ret_var.is_owned) {
10614                 ret_ref |= 1;
10615         }
10616         return ret_ref;
10617 }
10618
10619 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
10620         LDKInMemoryChannelKeys this_arg_conv;
10621         this_arg_conv.inner = (void*)(this_arg & (~1));
10622         this_arg_conv.is_owned = false;
10623         int16_t ret_val = InMemoryChannelKeys_counterparty_selected_contest_delay(&this_arg_conv);
10624         return ret_val;
10625 }
10626
10627 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
10628         LDKInMemoryChannelKeys this_arg_conv;
10629         this_arg_conv.inner = (void*)(this_arg & (~1));
10630         this_arg_conv.is_owned = false;
10631         int16_t ret_val = InMemoryChannelKeys_holder_selected_contest_delay(&this_arg_conv);
10632         return ret_val;
10633 }
10634
10635 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
10636         LDKInMemoryChannelKeys this_arg_conv;
10637         this_arg_conv.inner = (void*)(this_arg & (~1));
10638         this_arg_conv.is_owned = false;
10639         jboolean ret_val = InMemoryChannelKeys_is_outbound(&this_arg_conv);
10640         return ret_val;
10641 }
10642
10643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
10644         LDKInMemoryChannelKeys this_arg_conv;
10645         this_arg_conv.inner = (void*)(this_arg & (~1));
10646         this_arg_conv.is_owned = false;
10647         LDKOutPoint ret_var = InMemoryChannelKeys_funding_outpoint(&this_arg_conv);
10648         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10649         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10650         long ret_ref = (long)ret_var.inner;
10651         if (ret_var.is_owned) {
10652                 ret_ref |= 1;
10653         }
10654         return ret_ref;
10655 }
10656
10657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
10658         LDKInMemoryChannelKeys this_arg_conv;
10659         this_arg_conv.inner = (void*)(this_arg & (~1));
10660         this_arg_conv.is_owned = false;
10661         LDKChannelTransactionParameters ret_var = InMemoryChannelKeys_get_channel_parameters(&this_arg_conv);
10662         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10663         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10664         long ret_ref = (long)ret_var.inner;
10665         if (ret_var.is_owned) {
10666                 ret_ref |= 1;
10667         }
10668         return ret_ref;
10669 }
10670
10671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1as_1ChannelKeys(JNIEnv *env, jclass clz, int64_t this_arg) {
10672         LDKInMemoryChannelKeys this_arg_conv;
10673         this_arg_conv.inner = (void*)(this_arg & (~1));
10674         this_arg_conv.is_owned = false;
10675         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
10676         *ret = InMemoryChannelKeys_as_ChannelKeys(&this_arg_conv);
10677         return (long)ret;
10678 }
10679
10680 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
10681         LDKInMemoryChannelKeys obj_conv;
10682         obj_conv.inner = (void*)(obj & (~1));
10683         obj_conv.is_owned = false;
10684         LDKCVec_u8Z arg_var = InMemoryChannelKeys_write(&obj_conv);
10685         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
10686         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
10687         CVec_u8Z_free(arg_var);
10688         return arg_arr;
10689 }
10690
10691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10692         LDKu8slice ser_ref;
10693         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10694         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10695         LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
10696         *ret_conv = InMemoryChannelKeys_read(ser_ref);
10697         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10698         return (long)ret_conv;
10699 }
10700
10701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10702         LDKKeysManager this_ptr_conv;
10703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10704         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10705         KeysManager_free(this_ptr_conv);
10706 }
10707
10708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1new(JNIEnv *env, jclass clz, int8_tArray seed, jclass network, int64_t starting_time_secs, int32_t starting_time_nanos) {
10709         unsigned char seed_arr[32];
10710         CHECK((*env)->GetArrayLength(env, seed) == 32);
10711         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
10712         unsigned char (*seed_ref)[32] = &seed_arr;
10713         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
10714         LDKKeysManager ret_var = KeysManager_new(seed_ref, network_conv, starting_time_secs, starting_time_nanos);
10715         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10716         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10717         long ret_ref = (long)ret_var.inner;
10718         if (ret_var.is_owned) {
10719                 ret_ref |= 1;
10720         }
10721         return ret_ref;
10722 }
10723
10724 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, int64_t params_1, int64_t params_2) {
10725         LDKKeysManager this_arg_conv;
10726         this_arg_conv.inner = (void*)(this_arg & (~1));
10727         this_arg_conv.is_owned = false;
10728         LDKInMemoryChannelKeys ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_1, params_2);
10729         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10730         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10731         long ret_ref = (long)ret_var.inner;
10732         if (ret_var.is_owned) {
10733                 ret_ref |= 1;
10734         }
10735         return ret_ref;
10736 }
10737
10738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
10739         LDKKeysManager this_arg_conv;
10740         this_arg_conv.inner = (void*)(this_arg & (~1));
10741         this_arg_conv.is_owned = false;
10742         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
10743         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
10744         return (long)ret;
10745 }
10746
10747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10748         LDKChannelManager this_ptr_conv;
10749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10750         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10751         ChannelManager_free(this_ptr_conv);
10752 }
10753
10754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10755         LDKChannelDetails this_ptr_conv;
10756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10757         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10758         ChannelDetails_free(this_ptr_conv);
10759 }
10760
10761 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
10762         LDKChannelDetails this_ptr_conv;
10763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10764         this_ptr_conv.is_owned = false;
10765         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10766         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
10767         return ret_arr;
10768 }
10769
10770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10771         LDKChannelDetails this_ptr_conv;
10772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10773         this_ptr_conv.is_owned = false;
10774         LDKThirtyTwoBytes val_ref;
10775         CHECK((*env)->GetArrayLength(env, val) == 32);
10776         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
10777         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
10778 }
10779
10780 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
10781         LDKChannelDetails this_ptr_conv;
10782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10783         this_ptr_conv.is_owned = false;
10784         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
10785         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form);
10786         return arg_arr;
10787 }
10788
10789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10790         LDKChannelDetails this_ptr_conv;
10791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10792         this_ptr_conv.is_owned = false;
10793         LDKPublicKey val_ref;
10794         CHECK((*env)->GetArrayLength(env, val) == 33);
10795         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
10796         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
10797 }
10798
10799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
10800         LDKChannelDetails this_ptr_conv;
10801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10802         this_ptr_conv.is_owned = false;
10803         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
10804         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10805         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10806         long ret_ref = (long)ret_var.inner;
10807         if (ret_var.is_owned) {
10808                 ret_ref |= 1;
10809         }
10810         return ret_ref;
10811 }
10812
10813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10814         LDKChannelDetails this_ptr_conv;
10815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10816         this_ptr_conv.is_owned = false;
10817         LDKInitFeatures val_conv;
10818         val_conv.inner = (void*)(val & (~1));
10819         val_conv.is_owned = (val & 1) || (val == 0);
10820         val_conv = InitFeatures_clone(&val_conv);
10821         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
10822 }
10823
10824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10825         LDKChannelDetails this_ptr_conv;
10826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10827         this_ptr_conv.is_owned = false;
10828         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
10829         return ret_val;
10830 }
10831
10832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10833         LDKChannelDetails this_ptr_conv;
10834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10835         this_ptr_conv.is_owned = false;
10836         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
10837 }
10838
10839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
10840         LDKChannelDetails this_ptr_conv;
10841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10842         this_ptr_conv.is_owned = false;
10843         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
10844         return ret_val;
10845 }
10846
10847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10848         LDKChannelDetails this_ptr_conv;
10849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10850         this_ptr_conv.is_owned = false;
10851         ChannelDetails_set_user_id(&this_ptr_conv, val);
10852 }
10853
10854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
10855         LDKChannelDetails this_ptr_conv;
10856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10857         this_ptr_conv.is_owned = false;
10858         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
10859         return ret_val;
10860 }
10861
10862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10863         LDKChannelDetails this_ptr_conv;
10864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10865         this_ptr_conv.is_owned = false;
10866         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
10867 }
10868
10869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
10870         LDKChannelDetails this_ptr_conv;
10871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10872         this_ptr_conv.is_owned = false;
10873         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
10874         return ret_val;
10875 }
10876
10877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10878         LDKChannelDetails this_ptr_conv;
10879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10880         this_ptr_conv.is_owned = false;
10881         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
10882 }
10883
10884 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1live(JNIEnv *env, jclass clz, int64_t this_ptr) {
10885         LDKChannelDetails this_ptr_conv;
10886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10887         this_ptr_conv.is_owned = false;
10888         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
10889         return ret_val;
10890 }
10891
10892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1live(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
10893         LDKChannelDetails this_ptr_conv;
10894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10895         this_ptr_conv.is_owned = false;
10896         ChannelDetails_set_is_live(&this_ptr_conv, val);
10897 }
10898
10899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10900         LDKChannelDetails orig_conv;
10901         orig_conv.inner = (void*)(orig & (~1));
10902         orig_conv.is_owned = false;
10903         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
10904         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10905         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10906         long ret_ref = (long)ret_var.inner;
10907         if (ret_var.is_owned) {
10908                 ret_ref |= 1;
10909         }
10910         return ret_ref;
10911 }
10912
10913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10914         LDKPaymentSendFailure this_ptr_conv;
10915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10916         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10917         PaymentSendFailure_free(this_ptr_conv);
10918 }
10919
10920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10921         LDKPaymentSendFailure orig_conv;
10922         orig_conv.inner = (void*)(orig & (~1));
10923         orig_conv.is_owned = false;
10924         LDKPaymentSendFailure ret_var = PaymentSendFailure_clone(&orig_conv);
10925         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10926         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10927         long ret_ref = (long)ret_var.inner;
10928         if (ret_var.is_owned) {
10929                 ret_ref |= 1;
10930         }
10931         return ret_ref;
10932 }
10933
10934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1new(JNIEnv *env, jclass clz, jclass network, int64_t fee_est, int64_t chain_monitor, int64_t tx_broadcaster, int64_t logger, int64_t keys_manager, int64_t config, int64_t current_blockchain_height) {
10935         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
10936         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
10937         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
10938                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10939                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
10940         }
10941         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
10942         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
10943                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10944                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
10945         }
10946         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
10947         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
10948                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10949                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
10950         }
10951         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10952         if (logger_conv.free == LDKLogger_JCalls_free) {
10953                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10954                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10955         }
10956         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
10957         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
10958                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10959                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
10960         }
10961         LDKUserConfig config_conv;
10962         config_conv.inner = (void*)(config & (~1));
10963         config_conv.is_owned = (config & 1) || (config == 0);
10964         config_conv = UserConfig_clone(&config_conv);
10965         LDKChannelManager ret_var = ChannelManager_new(network_conv, fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, current_blockchain_height);
10966         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10967         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10968         long ret_ref = (long)ret_var.inner;
10969         if (ret_var.is_owned) {
10970                 ret_ref |= 1;
10971         }
10972         return ret_ref;
10973 }
10974
10975 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_id, int64_t override_config) {
10976         LDKChannelManager this_arg_conv;
10977         this_arg_conv.inner = (void*)(this_arg & (~1));
10978         this_arg_conv.is_owned = false;
10979         LDKPublicKey their_network_key_ref;
10980         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
10981         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
10982         LDKUserConfig override_config_conv;
10983         override_config_conv.inner = (void*)(override_config & (~1));
10984         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
10985         override_config_conv = UserConfig_clone(&override_config_conv);
10986         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10987         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
10988         return (long)ret_conv;
10989 }
10990
10991 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
10992         LDKChannelManager this_arg_conv;
10993         this_arg_conv.inner = (void*)(this_arg & (~1));
10994         this_arg_conv.is_owned = false;
10995         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
10996         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10997         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10998         for (size_t q = 0; q < ret_var.datalen; q++) {
10999                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
11000                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11001                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11002                 long arr_conv_16_ref = (long)arr_conv_16_var.inner;
11003                 if (arr_conv_16_var.is_owned) {
11004                         arr_conv_16_ref |= 1;
11005                 }
11006                 ret_arr_ptr[q] = arr_conv_16_ref;
11007         }
11008         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11009         FREE(ret_var.data);
11010         return ret_arr;
11011 }
11012
11013 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
11014         LDKChannelManager this_arg_conv;
11015         this_arg_conv.inner = (void*)(this_arg & (~1));
11016         this_arg_conv.is_owned = false;
11017         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
11018         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11019         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11020         for (size_t q = 0; q < ret_var.datalen; q++) {
11021                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
11022                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11023                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11024                 long arr_conv_16_ref = (long)arr_conv_16_var.inner;
11025                 if (arr_conv_16_var.is_owned) {
11026                         arr_conv_16_ref |= 1;
11027                 }
11028                 ret_arr_ptr[q] = arr_conv_16_ref;
11029         }
11030         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11031         FREE(ret_var.data);
11032         return ret_arr;
11033 }
11034
11035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
11036         LDKChannelManager this_arg_conv;
11037         this_arg_conv.inner = (void*)(this_arg & (~1));
11038         this_arg_conv.is_owned = false;
11039         unsigned char channel_id_arr[32];
11040         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
11041         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
11042         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
11043         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11044         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
11045         return (long)ret_conv;
11046 }
11047
11048 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) {
11049         LDKChannelManager this_arg_conv;
11050         this_arg_conv.inner = (void*)(this_arg & (~1));
11051         this_arg_conv.is_owned = false;
11052         unsigned char channel_id_arr[32];
11053         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
11054         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
11055         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
11056         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11057         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
11058         return (long)ret_conv;
11059 }
11060
11061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
11062         LDKChannelManager this_arg_conv;
11063         this_arg_conv.inner = (void*)(this_arg & (~1));
11064         this_arg_conv.is_owned = false;
11065         ChannelManager_force_close_all_channels(&this_arg_conv);
11066 }
11067
11068 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) {
11069         LDKChannelManager this_arg_conv;
11070         this_arg_conv.inner = (void*)(this_arg & (~1));
11071         this_arg_conv.is_owned = false;
11072         LDKRoute route_conv;
11073         route_conv.inner = (void*)(route & (~1));
11074         route_conv.is_owned = false;
11075         LDKThirtyTwoBytes payment_hash_ref;
11076         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
11077         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
11078         LDKThirtyTwoBytes payment_secret_ref;
11079         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
11080         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
11081         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11082         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
11083         return (long)ret_conv;
11084 }
11085
11086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1transaction_1generated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int64_t funding_txo) {
11087         LDKChannelManager this_arg_conv;
11088         this_arg_conv.inner = (void*)(this_arg & (~1));
11089         this_arg_conv.is_owned = false;
11090         unsigned char temporary_channel_id_arr[32];
11091         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
11092         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
11093         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
11094         LDKOutPoint funding_txo_conv;
11095         funding_txo_conv.inner = (void*)(funding_txo & (~1));
11096         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
11097         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
11098         ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
11099 }
11100
11101 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) {
11102         LDKChannelManager this_arg_conv;
11103         this_arg_conv.inner = (void*)(this_arg & (~1));
11104         this_arg_conv.is_owned = false;
11105         LDKThreeBytes rgb_ref;
11106         CHECK((*env)->GetArrayLength(env, rgb) == 3);
11107         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
11108         LDKThirtyTwoBytes alias_ref;
11109         CHECK((*env)->GetArrayLength(env, alias) == 32);
11110         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
11111         LDKCVec_NetAddressZ addresses_constr;
11112         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
11113         if (addresses_constr.datalen > 0)
11114                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
11115         else
11116                 addresses_constr.data = NULL;
11117         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
11118         for (size_t m = 0; m < addresses_constr.datalen; m++) {
11119                 int64_t arr_conv_12 = addresses_vals[m];
11120                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)(((uint64_t)arr_conv_12) & ~1);
11121                 FREE((void*)arr_conv_12);
11122                 addresses_constr.data[m] = arr_conv_12_conv;
11123         }
11124         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
11125         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
11126 }
11127
11128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
11129         LDKChannelManager this_arg_conv;
11130         this_arg_conv.inner = (void*)(this_arg & (~1));
11131         this_arg_conv.is_owned = false;
11132         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
11133 }
11134
11135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1chan_1freshness_1every_1min(JNIEnv *env, jclass clz, int64_t this_arg) {
11136         LDKChannelManager this_arg_conv;
11137         this_arg_conv.inner = (void*)(this_arg & (~1));
11138         this_arg_conv.is_owned = false;
11139         ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
11140 }
11141
11142 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
11143         LDKChannelManager this_arg_conv;
11144         this_arg_conv.inner = (void*)(this_arg & (~1));
11145         this_arg_conv.is_owned = false;
11146         unsigned char payment_hash_arr[32];
11147         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
11148         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
11149         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
11150         LDKThirtyTwoBytes payment_secret_ref;
11151         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
11152         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
11153         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
11154         return ret_val;
11155 }
11156
11157 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t expected_amount) {
11158         LDKChannelManager this_arg_conv;
11159         this_arg_conv.inner = (void*)(this_arg & (~1));
11160         this_arg_conv.is_owned = false;
11161         LDKThirtyTwoBytes payment_preimage_ref;
11162         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
11163         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
11164         LDKThirtyTwoBytes payment_secret_ref;
11165         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
11166         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
11167         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
11168         return ret_val;
11169 }
11170
11171 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
11172         LDKChannelManager this_arg_conv;
11173         this_arg_conv.inner = (void*)(this_arg & (~1));
11174         this_arg_conv.is_owned = false;
11175         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
11176         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
11177         return arg_arr;
11178 }
11179
11180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1monitor_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t highest_applied_update_id) {
11181         LDKChannelManager this_arg_conv;
11182         this_arg_conv.inner = (void*)(this_arg & (~1));
11183         this_arg_conv.is_owned = false;
11184         LDKOutPoint funding_txo_conv;
11185         funding_txo_conv.inner = (void*)(funding_txo & (~1));
11186         funding_txo_conv.is_owned = false;
11187         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
11188 }
11189
11190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
11191         LDKChannelManager this_arg_conv;
11192         this_arg_conv.inner = (void*)(this_arg & (~1));
11193         this_arg_conv.is_owned = false;
11194         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
11195         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
11196         return (long)ret;
11197 }
11198
11199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
11200         LDKChannelManager this_arg_conv;
11201         this_arg_conv.inner = (void*)(this_arg & (~1));
11202         this_arg_conv.is_owned = false;
11203         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
11204         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
11205         return (long)ret;
11206 }
11207
11208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
11209         LDKChannelManager this_arg_conv;
11210         this_arg_conv.inner = (void*)(this_arg & (~1));
11211         this_arg_conv.is_owned = false;
11212         unsigned char header_arr[80];
11213         CHECK((*env)->GetArrayLength(env, header) == 80);
11214         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11215         unsigned char (*header_ref)[80] = &header_arr;
11216         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11217         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11218         if (txdata_constr.datalen > 0)
11219                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11220         else
11221                 txdata_constr.data = NULL;
11222         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11223         for (size_t y = 0; y < txdata_constr.datalen; y++) {
11224                 int64_t arr_conv_24 = txdata_vals[y];
11225                 LDKC2Tuple_usizeTransactionZ arr_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_conv_24) & ~1);
11226                 FREE((void*)arr_conv_24);
11227                 txdata_constr.data[y] = arr_conv_24_conv;
11228         }
11229         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11230         ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
11231 }
11232
11233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header) {
11234         LDKChannelManager this_arg_conv;
11235         this_arg_conv.inner = (void*)(this_arg & (~1));
11236         this_arg_conv.is_owned = false;
11237         unsigned char header_arr[80];
11238         CHECK((*env)->GetArrayLength(env, header) == 80);
11239         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11240         unsigned char (*header_ref)[80] = &header_arr;
11241         ChannelManager_block_disconnected(&this_arg_conv, header_ref);
11242 }
11243
11244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
11245         LDKChannelManager this_arg_conv;
11246         this_arg_conv.inner = (void*)(this_arg & (~1));
11247         this_arg_conv.is_owned = false;
11248         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
11249         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
11250         return (long)ret;
11251 }
11252
11253 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
11254         LDKChannelManager obj_conv;
11255         obj_conv.inner = (void*)(obj & (~1));
11256         obj_conv.is_owned = false;
11257         LDKCVec_u8Z arg_var = ChannelManager_write(&obj_conv);
11258         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
11259         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
11260         CVec_u8Z_free(arg_var);
11261         return arg_arr;
11262 }
11263
11264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11265         LDKChannelManagerReadArgs this_ptr_conv;
11266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11267         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11268         ChannelManagerReadArgs_free(this_ptr_conv);
11269 }
11270
11271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
11272         LDKChannelManagerReadArgs this_ptr_conv;
11273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11274         this_ptr_conv.is_owned = false;
11275         long ret_ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
11276         return ret_ret;
11277 }
11278
11279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11280         LDKChannelManagerReadArgs this_ptr_conv;
11281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11282         this_ptr_conv.is_owned = false;
11283         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
11284         if (val_conv.free == LDKKeysInterface_JCalls_free) {
11285                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11286                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
11287         }
11288         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
11289 }
11290
11291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
11292         LDKChannelManagerReadArgs this_ptr_conv;
11293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11294         this_ptr_conv.is_owned = false;
11295         long ret_ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
11296         return ret_ret;
11297 }
11298
11299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11300         LDKChannelManagerReadArgs this_ptr_conv;
11301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11302         this_ptr_conv.is_owned = false;
11303         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
11304         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
11305                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11306                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
11307         }
11308         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
11309 }
11310
11311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
11312         LDKChannelManagerReadArgs this_ptr_conv;
11313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11314         this_ptr_conv.is_owned = false;
11315         long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
11316         return ret_ret;
11317 }
11318
11319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11320         LDKChannelManagerReadArgs this_ptr_conv;
11321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11322         this_ptr_conv.is_owned = false;
11323         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
11324         if (val_conv.free == LDKWatch_JCalls_free) {
11325                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11326                 LDKWatch_JCalls_clone(val_conv.this_arg);
11327         }
11328         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
11329 }
11330
11331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
11332         LDKChannelManagerReadArgs this_ptr_conv;
11333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11334         this_ptr_conv.is_owned = false;
11335         long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
11336         return ret_ret;
11337 }
11338
11339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11340         LDKChannelManagerReadArgs this_ptr_conv;
11341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11342         this_ptr_conv.is_owned = false;
11343         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
11344         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
11345                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11346                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
11347         }
11348         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
11349 }
11350
11351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
11352         LDKChannelManagerReadArgs this_ptr_conv;
11353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11354         this_ptr_conv.is_owned = false;
11355         long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
11356         return ret_ret;
11357 }
11358
11359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11360         LDKChannelManagerReadArgs this_ptr_conv;
11361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11362         this_ptr_conv.is_owned = false;
11363         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
11364         if (val_conv.free == LDKLogger_JCalls_free) {
11365                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11366                 LDKLogger_JCalls_clone(val_conv.this_arg);
11367         }
11368         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
11369 }
11370
11371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
11372         LDKChannelManagerReadArgs this_ptr_conv;
11373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11374         this_ptr_conv.is_owned = false;
11375         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
11376         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11377         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11378         long ret_ref = (long)ret_var.inner;
11379         if (ret_var.is_owned) {
11380                 ret_ref |= 1;
11381         }
11382         return ret_ref;
11383 }
11384
11385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11386         LDKChannelManagerReadArgs this_ptr_conv;
11387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11388         this_ptr_conv.is_owned = false;
11389         LDKUserConfig val_conv;
11390         val_conv.inner = (void*)(val & (~1));
11391         val_conv.is_owned = (val & 1) || (val == 0);
11392         val_conv = UserConfig_clone(&val_conv);
11393         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
11394 }
11395
11396 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) {
11397         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
11398         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
11399                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11400                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
11401         }
11402         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11403         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
11404                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11405                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
11406         }
11407         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
11408         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
11409                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11410                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
11411         }
11412         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
11413         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11414                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11415                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
11416         }
11417         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11418         if (logger_conv.free == LDKLogger_JCalls_free) {
11419                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11420                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11421         }
11422         LDKUserConfig default_config_conv;
11423         default_config_conv.inner = (void*)(default_config & (~1));
11424         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
11425         default_config_conv = UserConfig_clone(&default_config_conv);
11426         LDKCVec_ChannelMonitorZ channel_monitors_constr;
11427         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
11428         if (channel_monitors_constr.datalen > 0)
11429                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
11430         else
11431                 channel_monitors_constr.data = NULL;
11432         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
11433         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
11434                 int64_t arr_conv_16 = channel_monitors_vals[q];
11435                 LDKChannelMonitor arr_conv_16_conv;
11436                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
11437                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
11438                 channel_monitors_constr.data[q] = arr_conv_16_conv;
11439         }
11440         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
11441         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);
11442         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11443         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11444         long ret_ref = (long)ret_var.inner;
11445         if (ret_var.is_owned) {
11446                 ret_ref |= 1;
11447         }
11448         return ret_ref;
11449 }
11450
11451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
11452         LDKu8slice ser_ref;
11453         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11454         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11455         LDKChannelManagerReadArgs arg_conv;
11456         arg_conv.inner = (void*)(arg & (~1));
11457         arg_conv.is_owned = (arg & 1) || (arg == 0);
11458         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
11459         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
11460         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
11461         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11462         return (long)ret_conv;
11463 }
11464
11465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11466         LDKDecodeError this_ptr_conv;
11467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11468         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11469         DecodeError_free(this_ptr_conv);
11470 }
11471
11472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11473         LDKDecodeError orig_conv;
11474         orig_conv.inner = (void*)(orig & (~1));
11475         orig_conv.is_owned = false;
11476         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
11477         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11478         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11479         long ret_ref = (long)ret_var.inner;
11480         if (ret_var.is_owned) {
11481                 ret_ref |= 1;
11482         }
11483         return ret_ref;
11484 }
11485
11486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11487         LDKInit this_ptr_conv;
11488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11489         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11490         Init_free(this_ptr_conv);
11491 }
11492
11493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11494         LDKInit orig_conv;
11495         orig_conv.inner = (void*)(orig & (~1));
11496         orig_conv.is_owned = false;
11497         LDKInit ret_var = Init_clone(&orig_conv);
11498         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11499         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11500         long ret_ref = (long)ret_var.inner;
11501         if (ret_var.is_owned) {
11502                 ret_ref |= 1;
11503         }
11504         return ret_ref;
11505 }
11506
11507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11508         LDKErrorMessage this_ptr_conv;
11509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11510         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11511         ErrorMessage_free(this_ptr_conv);
11512 }
11513
11514 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11515         LDKErrorMessage this_ptr_conv;
11516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11517         this_ptr_conv.is_owned = false;
11518         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11519         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
11520         return ret_arr;
11521 }
11522
11523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11524         LDKErrorMessage this_ptr_conv;
11525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11526         this_ptr_conv.is_owned = false;
11527         LDKThirtyTwoBytes val_ref;
11528         CHECK((*env)->GetArrayLength(env, val) == 32);
11529         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11530         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
11531 }
11532
11533 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
11534         LDKErrorMessage this_ptr_conv;
11535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11536         this_ptr_conv.is_owned = false;
11537         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
11538         jstring _conv = str_ref_to_java(env, _str.chars, _str.len);
11539         return _conv;
11540 }
11541
11542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11543         LDKErrorMessage this_ptr_conv;
11544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11545         this_ptr_conv.is_owned = false;
11546         LDKCVec_u8Z val_ref;
11547         val_ref.datalen = (*env)->GetArrayLength(env, val);
11548         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
11549         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
11550         ErrorMessage_set_data(&this_ptr_conv, val_ref);
11551 }
11552
11553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray data_arg) {
11554         LDKThirtyTwoBytes channel_id_arg_ref;
11555         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
11556         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
11557         LDKCVec_u8Z data_arg_ref;
11558         data_arg_ref.datalen = (*env)->GetArrayLength(env, data_arg);
11559         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
11560         (*env)->GetByteArrayRegion(env, data_arg, 0, data_arg_ref.datalen, data_arg_ref.data);
11561         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
11562         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11563         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11564         long ret_ref = (long)ret_var.inner;
11565         if (ret_var.is_owned) {
11566                 ret_ref |= 1;
11567         }
11568         return ret_ref;
11569 }
11570
11571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11572         LDKErrorMessage orig_conv;
11573         orig_conv.inner = (void*)(orig & (~1));
11574         orig_conv.is_owned = false;
11575         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
11576         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11577         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11578         long ret_ref = (long)ret_var.inner;
11579         if (ret_var.is_owned) {
11580                 ret_ref |= 1;
11581         }
11582         return ret_ref;
11583 }
11584
11585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11586         LDKPing this_ptr_conv;
11587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11588         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11589         Ping_free(this_ptr_conv);
11590 }
11591
11592 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
11593         LDKPing this_ptr_conv;
11594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11595         this_ptr_conv.is_owned = false;
11596         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
11597         return ret_val;
11598 }
11599
11600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
11601         LDKPing this_ptr_conv;
11602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11603         this_ptr_conv.is_owned = false;
11604         Ping_set_ponglen(&this_ptr_conv, val);
11605 }
11606
11607 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
11608         LDKPing this_ptr_conv;
11609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11610         this_ptr_conv.is_owned = false;
11611         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
11612         return ret_val;
11613 }
11614
11615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
11616         LDKPing this_ptr_conv;
11617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11618         this_ptr_conv.is_owned = false;
11619         Ping_set_byteslen(&this_ptr_conv, val);
11620 }
11621
11622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
11623         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
11624         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11625         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11626         long ret_ref = (long)ret_var.inner;
11627         if (ret_var.is_owned) {
11628                 ret_ref |= 1;
11629         }
11630         return ret_ref;
11631 }
11632
11633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11634         LDKPing orig_conv;
11635         orig_conv.inner = (void*)(orig & (~1));
11636         orig_conv.is_owned = false;
11637         LDKPing ret_var = Ping_clone(&orig_conv);
11638         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11639         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11640         long ret_ref = (long)ret_var.inner;
11641         if (ret_var.is_owned) {
11642                 ret_ref |= 1;
11643         }
11644         return ret_ref;
11645 }
11646
11647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11648         LDKPong this_ptr_conv;
11649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11650         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11651         Pong_free(this_ptr_conv);
11652 }
11653
11654 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
11655         LDKPong this_ptr_conv;
11656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11657         this_ptr_conv.is_owned = false;
11658         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
11659         return ret_val;
11660 }
11661
11662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
11663         LDKPong this_ptr_conv;
11664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11665         this_ptr_conv.is_owned = false;
11666         Pong_set_byteslen(&this_ptr_conv, val);
11667 }
11668
11669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
11670         LDKPong ret_var = Pong_new(byteslen_arg);
11671         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11672         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11673         long ret_ref = (long)ret_var.inner;
11674         if (ret_var.is_owned) {
11675                 ret_ref |= 1;
11676         }
11677         return ret_ref;
11678 }
11679
11680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11681         LDKPong orig_conv;
11682         orig_conv.inner = (void*)(orig & (~1));
11683         orig_conv.is_owned = false;
11684         LDKPong ret_var = Pong_clone(&orig_conv);
11685         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11686         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11687         long ret_ref = (long)ret_var.inner;
11688         if (ret_var.is_owned) {
11689                 ret_ref |= 1;
11690         }
11691         return ret_ref;
11692 }
11693
11694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11695         LDKOpenChannel this_ptr_conv;
11696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11697         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11698         OpenChannel_free(this_ptr_conv);
11699 }
11700
11701 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
11702         LDKOpenChannel this_ptr_conv;
11703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11704         this_ptr_conv.is_owned = false;
11705         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11706         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
11707         return ret_arr;
11708 }
11709
11710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11711         LDKOpenChannel this_ptr_conv;
11712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11713         this_ptr_conv.is_owned = false;
11714         LDKThirtyTwoBytes val_ref;
11715         CHECK((*env)->GetArrayLength(env, val) == 32);
11716         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11717         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
11718 }
11719
11720 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11721         LDKOpenChannel this_ptr_conv;
11722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11723         this_ptr_conv.is_owned = false;
11724         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11725         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
11726         return ret_arr;
11727 }
11728
11729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11730         LDKOpenChannel this_ptr_conv;
11731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11732         this_ptr_conv.is_owned = false;
11733         LDKThirtyTwoBytes val_ref;
11734         CHECK((*env)->GetArrayLength(env, val) == 32);
11735         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11736         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
11737 }
11738
11739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
11740         LDKOpenChannel this_ptr_conv;
11741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11742         this_ptr_conv.is_owned = false;
11743         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
11744         return ret_val;
11745 }
11746
11747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11748         LDKOpenChannel this_ptr_conv;
11749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11750         this_ptr_conv.is_owned = false;
11751         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
11752 }
11753
11754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
11755         LDKOpenChannel this_ptr_conv;
11756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11757         this_ptr_conv.is_owned = false;
11758         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
11759         return ret_val;
11760 }
11761
11762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11763         LDKOpenChannel this_ptr_conv;
11764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11765         this_ptr_conv.is_owned = false;
11766         OpenChannel_set_push_msat(&this_ptr_conv, val);
11767 }
11768
11769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
11770         LDKOpenChannel this_ptr_conv;
11771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11772         this_ptr_conv.is_owned = false;
11773         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
11774         return ret_val;
11775 }
11776
11777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11778         LDKOpenChannel this_ptr_conv;
11779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11780         this_ptr_conv.is_owned = false;
11781         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
11782 }
11783
11784 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) {
11785         LDKOpenChannel this_ptr_conv;
11786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11787         this_ptr_conv.is_owned = false;
11788         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
11789         return ret_val;
11790 }
11791
11792 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) {
11793         LDKOpenChannel this_ptr_conv;
11794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11795         this_ptr_conv.is_owned = false;
11796         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
11797 }
11798
11799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
11800         LDKOpenChannel this_ptr_conv;
11801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11802         this_ptr_conv.is_owned = false;
11803         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
11804         return ret_val;
11805 }
11806
11807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11808         LDKOpenChannel this_ptr_conv;
11809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11810         this_ptr_conv.is_owned = false;
11811         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
11812 }
11813
11814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
11815         LDKOpenChannel this_ptr_conv;
11816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11817         this_ptr_conv.is_owned = false;
11818         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
11819         return ret_val;
11820 }
11821
11822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11823         LDKOpenChannel this_ptr_conv;
11824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11825         this_ptr_conv.is_owned = false;
11826         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
11827 }
11828
11829 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
11830         LDKOpenChannel this_ptr_conv;
11831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11832         this_ptr_conv.is_owned = false;
11833         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
11834         return ret_val;
11835 }
11836
11837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
11838         LDKOpenChannel this_ptr_conv;
11839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11840         this_ptr_conv.is_owned = false;
11841         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
11842 }
11843
11844 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
11845         LDKOpenChannel this_ptr_conv;
11846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11847         this_ptr_conv.is_owned = false;
11848         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
11849         return ret_val;
11850 }
11851
11852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
11853         LDKOpenChannel this_ptr_conv;
11854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11855         this_ptr_conv.is_owned = false;
11856         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
11857 }
11858
11859 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
11860         LDKOpenChannel this_ptr_conv;
11861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11862         this_ptr_conv.is_owned = false;
11863         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
11864         return ret_val;
11865 }
11866
11867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
11868         LDKOpenChannel this_ptr_conv;
11869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11870         this_ptr_conv.is_owned = false;
11871         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
11872 }
11873
11874 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
11875         LDKOpenChannel this_ptr_conv;
11876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11877         this_ptr_conv.is_owned = false;
11878         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
11879         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
11880         return arg_arr;
11881 }
11882
11883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11884         LDKOpenChannel this_ptr_conv;
11885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11886         this_ptr_conv.is_owned = false;
11887         LDKPublicKey val_ref;
11888         CHECK((*env)->GetArrayLength(env, val) == 33);
11889         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11890         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
11891 }
11892
11893 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
11894         LDKOpenChannel this_ptr_conv;
11895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11896         this_ptr_conv.is_owned = false;
11897         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
11898         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
11899         return arg_arr;
11900 }
11901
11902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11903         LDKOpenChannel this_ptr_conv;
11904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11905         this_ptr_conv.is_owned = false;
11906         LDKPublicKey val_ref;
11907         CHECK((*env)->GetArrayLength(env, val) == 33);
11908         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11909         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
11910 }
11911
11912 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
11913         LDKOpenChannel this_ptr_conv;
11914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11915         this_ptr_conv.is_owned = false;
11916         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
11917         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
11918         return arg_arr;
11919 }
11920
11921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11922         LDKOpenChannel this_ptr_conv;
11923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11924         this_ptr_conv.is_owned = false;
11925         LDKPublicKey val_ref;
11926         CHECK((*env)->GetArrayLength(env, val) == 33);
11927         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11928         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
11929 }
11930
11931 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
11932         LDKOpenChannel this_ptr_conv;
11933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11934         this_ptr_conv.is_owned = false;
11935         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
11936         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
11937         return arg_arr;
11938 }
11939
11940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11941         LDKOpenChannel this_ptr_conv;
11942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11943         this_ptr_conv.is_owned = false;
11944         LDKPublicKey val_ref;
11945         CHECK((*env)->GetArrayLength(env, val) == 33);
11946         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11947         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
11948 }
11949
11950 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
11951         LDKOpenChannel this_ptr_conv;
11952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11953         this_ptr_conv.is_owned = false;
11954         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
11955         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
11956         return arg_arr;
11957 }
11958
11959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11960         LDKOpenChannel this_ptr_conv;
11961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11962         this_ptr_conv.is_owned = false;
11963         LDKPublicKey val_ref;
11964         CHECK((*env)->GetArrayLength(env, val) == 33);
11965         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11966         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
11967 }
11968
11969 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
11970         LDKOpenChannel this_ptr_conv;
11971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11972         this_ptr_conv.is_owned = false;
11973         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
11974         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
11975         return arg_arr;
11976 }
11977
11978 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) {
11979         LDKOpenChannel this_ptr_conv;
11980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11981         this_ptr_conv.is_owned = false;
11982         LDKPublicKey val_ref;
11983         CHECK((*env)->GetArrayLength(env, val) == 33);
11984         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11985         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
11986 }
11987
11988 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
11989         LDKOpenChannel this_ptr_conv;
11990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11991         this_ptr_conv.is_owned = false;
11992         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
11993         return ret_val;
11994 }
11995
11996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
11997         LDKOpenChannel this_ptr_conv;
11998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11999         this_ptr_conv.is_owned = false;
12000         OpenChannel_set_channel_flags(&this_ptr_conv, val);
12001 }
12002
12003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12004         LDKOpenChannel orig_conv;
12005         orig_conv.inner = (void*)(orig & (~1));
12006         orig_conv.is_owned = false;
12007         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
12008         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12009         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12010         long ret_ref = (long)ret_var.inner;
12011         if (ret_var.is_owned) {
12012                 ret_ref |= 1;
12013         }
12014         return ret_ref;
12015 }
12016
12017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12018         LDKAcceptChannel this_ptr_conv;
12019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12020         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12021         AcceptChannel_free(this_ptr_conv);
12022 }
12023
12024 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12025         LDKAcceptChannel this_ptr_conv;
12026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12027         this_ptr_conv.is_owned = false;
12028         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12029         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
12030         return ret_arr;
12031 }
12032
12033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12034         LDKAcceptChannel this_ptr_conv;
12035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12036         this_ptr_conv.is_owned = false;
12037         LDKThirtyTwoBytes val_ref;
12038         CHECK((*env)->GetArrayLength(env, val) == 32);
12039         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12040         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
12041 }
12042
12043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12044         LDKAcceptChannel this_ptr_conv;
12045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12046         this_ptr_conv.is_owned = false;
12047         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
12048         return ret_val;
12049 }
12050
12051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12052         LDKAcceptChannel this_ptr_conv;
12053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12054         this_ptr_conv.is_owned = false;
12055         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
12056 }
12057
12058 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) {
12059         LDKAcceptChannel this_ptr_conv;
12060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12061         this_ptr_conv.is_owned = false;
12062         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
12063         return ret_val;
12064 }
12065
12066 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) {
12067         LDKAcceptChannel this_ptr_conv;
12068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12069         this_ptr_conv.is_owned = false;
12070         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
12071 }
12072
12073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12074         LDKAcceptChannel this_ptr_conv;
12075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12076         this_ptr_conv.is_owned = false;
12077         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
12078         return ret_val;
12079 }
12080
12081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12082         LDKAcceptChannel this_ptr_conv;
12083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12084         this_ptr_conv.is_owned = false;
12085         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
12086 }
12087
12088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
12089         LDKAcceptChannel this_ptr_conv;
12090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12091         this_ptr_conv.is_owned = false;
12092         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
12093         return ret_val;
12094 }
12095
12096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12097         LDKAcceptChannel this_ptr_conv;
12098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12099         this_ptr_conv.is_owned = false;
12100         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
12101 }
12102
12103 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
12104         LDKAcceptChannel this_ptr_conv;
12105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12106         this_ptr_conv.is_owned = false;
12107         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
12108         return ret_val;
12109 }
12110
12111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
12112         LDKAcceptChannel this_ptr_conv;
12113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12114         this_ptr_conv.is_owned = false;
12115         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
12116 }
12117
12118 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
12119         LDKAcceptChannel this_ptr_conv;
12120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12121         this_ptr_conv.is_owned = false;
12122         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
12123         return ret_val;
12124 }
12125
12126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
12127         LDKAcceptChannel this_ptr_conv;
12128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12129         this_ptr_conv.is_owned = false;
12130         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
12131 }
12132
12133 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
12134         LDKAcceptChannel this_ptr_conv;
12135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12136         this_ptr_conv.is_owned = false;
12137         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
12138         return ret_val;
12139 }
12140
12141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
12142         LDKAcceptChannel this_ptr_conv;
12143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12144         this_ptr_conv.is_owned = false;
12145         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
12146 }
12147
12148 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
12149         LDKAcceptChannel this_ptr_conv;
12150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12151         this_ptr_conv.is_owned = false;
12152         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
12153         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
12154         return arg_arr;
12155 }
12156
12157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12158         LDKAcceptChannel this_ptr_conv;
12159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12160         this_ptr_conv.is_owned = false;
12161         LDKPublicKey val_ref;
12162         CHECK((*env)->GetArrayLength(env, val) == 33);
12163         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12164         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
12165 }
12166
12167 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
12168         LDKAcceptChannel this_ptr_conv;
12169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12170         this_ptr_conv.is_owned = false;
12171         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
12172         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
12173         return arg_arr;
12174 }
12175
12176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12177         LDKAcceptChannel this_ptr_conv;
12178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12179         this_ptr_conv.is_owned = false;
12180         LDKPublicKey val_ref;
12181         CHECK((*env)->GetArrayLength(env, val) == 33);
12182         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12183         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
12184 }
12185
12186 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
12187         LDKAcceptChannel this_ptr_conv;
12188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12189         this_ptr_conv.is_owned = false;
12190         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
12191         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
12192         return arg_arr;
12193 }
12194
12195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12196         LDKAcceptChannel this_ptr_conv;
12197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12198         this_ptr_conv.is_owned = false;
12199         LDKPublicKey val_ref;
12200         CHECK((*env)->GetArrayLength(env, val) == 33);
12201         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12202         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
12203 }
12204
12205 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
12206         LDKAcceptChannel this_ptr_conv;
12207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12208         this_ptr_conv.is_owned = false;
12209         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
12210         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
12211         return arg_arr;
12212 }
12213
12214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12215         LDKAcceptChannel this_ptr_conv;
12216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12217         this_ptr_conv.is_owned = false;
12218         LDKPublicKey val_ref;
12219         CHECK((*env)->GetArrayLength(env, val) == 33);
12220         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12221         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
12222 }
12223
12224 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
12225         LDKAcceptChannel this_ptr_conv;
12226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12227         this_ptr_conv.is_owned = false;
12228         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
12229         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
12230         return arg_arr;
12231 }
12232
12233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12234         LDKAcceptChannel this_ptr_conv;
12235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12236         this_ptr_conv.is_owned = false;
12237         LDKPublicKey val_ref;
12238         CHECK((*env)->GetArrayLength(env, val) == 33);
12239         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12240         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
12241 }
12242
12243 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
12244         LDKAcceptChannel this_ptr_conv;
12245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12246         this_ptr_conv.is_owned = false;
12247         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
12248         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
12249         return arg_arr;
12250 }
12251
12252 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) {
12253         LDKAcceptChannel this_ptr_conv;
12254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12255         this_ptr_conv.is_owned = false;
12256         LDKPublicKey val_ref;
12257         CHECK((*env)->GetArrayLength(env, val) == 33);
12258         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12259         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
12260 }
12261
12262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12263         LDKAcceptChannel orig_conv;
12264         orig_conv.inner = (void*)(orig & (~1));
12265         orig_conv.is_owned = false;
12266         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
12267         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12268         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12269         long ret_ref = (long)ret_var.inner;
12270         if (ret_var.is_owned) {
12271                 ret_ref |= 1;
12272         }
12273         return ret_ref;
12274 }
12275
12276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12277         LDKFundingCreated this_ptr_conv;
12278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12279         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12280         FundingCreated_free(this_ptr_conv);
12281 }
12282
12283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12284         LDKFundingCreated this_ptr_conv;
12285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12286         this_ptr_conv.is_owned = false;
12287         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12288         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
12289         return ret_arr;
12290 }
12291
12292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12293         LDKFundingCreated this_ptr_conv;
12294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12295         this_ptr_conv.is_owned = false;
12296         LDKThirtyTwoBytes val_ref;
12297         CHECK((*env)->GetArrayLength(env, val) == 32);
12298         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12299         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
12300 }
12301
12302 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
12303         LDKFundingCreated this_ptr_conv;
12304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12305         this_ptr_conv.is_owned = false;
12306         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12307         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
12308         return ret_arr;
12309 }
12310
12311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12312         LDKFundingCreated this_ptr_conv;
12313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12314         this_ptr_conv.is_owned = false;
12315         LDKThirtyTwoBytes val_ref;
12316         CHECK((*env)->GetArrayLength(env, val) == 32);
12317         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12318         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
12319 }
12320
12321 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
12322         LDKFundingCreated this_ptr_conv;
12323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12324         this_ptr_conv.is_owned = false;
12325         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
12326         return ret_val;
12327 }
12328
12329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
12330         LDKFundingCreated this_ptr_conv;
12331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12332         this_ptr_conv.is_owned = false;
12333         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
12334 }
12335
12336 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
12337         LDKFundingCreated this_ptr_conv;
12338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12339         this_ptr_conv.is_owned = false;
12340         int8_tArray arg_arr = (*env)->NewByteArray(env, 64);
12341         (*env)->SetByteArrayRegion(env, arg_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
12342         return arg_arr;
12343 }
12344
12345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12346         LDKFundingCreated this_ptr_conv;
12347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12348         this_ptr_conv.is_owned = false;
12349         LDKSignature val_ref;
12350         CHECK((*env)->GetArrayLength(env, val) == 64);
12351         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
12352         FundingCreated_set_signature(&this_ptr_conv, val_ref);
12353 }
12354
12355 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) {
12356         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
12357         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
12358         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
12359         LDKThirtyTwoBytes funding_txid_arg_ref;
12360         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
12361         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
12362         LDKSignature signature_arg_ref;
12363         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
12364         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
12365         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
12366         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12367         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12368         long ret_ref = (long)ret_var.inner;
12369         if (ret_var.is_owned) {
12370                 ret_ref |= 1;
12371         }
12372         return ret_ref;
12373 }
12374
12375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12376         LDKFundingCreated orig_conv;
12377         orig_conv.inner = (void*)(orig & (~1));
12378         orig_conv.is_owned = false;
12379         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
12380         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12381         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12382         long ret_ref = (long)ret_var.inner;
12383         if (ret_var.is_owned) {
12384                 ret_ref |= 1;
12385         }
12386         return ret_ref;
12387 }
12388
12389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12390         LDKFundingSigned this_ptr_conv;
12391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12392         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12393         FundingSigned_free(this_ptr_conv);
12394 }
12395
12396 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12397         LDKFundingSigned this_ptr_conv;
12398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12399         this_ptr_conv.is_owned = false;
12400         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12401         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
12402         return ret_arr;
12403 }
12404
12405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12406         LDKFundingSigned this_ptr_conv;
12407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12408         this_ptr_conv.is_owned = false;
12409         LDKThirtyTwoBytes val_ref;
12410         CHECK((*env)->GetArrayLength(env, val) == 32);
12411         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12412         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
12413 }
12414
12415 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
12416         LDKFundingSigned this_ptr_conv;
12417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12418         this_ptr_conv.is_owned = false;
12419         int8_tArray arg_arr = (*env)->NewByteArray(env, 64);
12420         (*env)->SetByteArrayRegion(env, arg_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
12421         return arg_arr;
12422 }
12423
12424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12425         LDKFundingSigned this_ptr_conv;
12426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12427         this_ptr_conv.is_owned = false;
12428         LDKSignature val_ref;
12429         CHECK((*env)->GetArrayLength(env, val) == 64);
12430         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
12431         FundingSigned_set_signature(&this_ptr_conv, val_ref);
12432 }
12433
12434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
12435         LDKThirtyTwoBytes channel_id_arg_ref;
12436         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
12437         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
12438         LDKSignature signature_arg_ref;
12439         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
12440         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
12441         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
12442         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12443         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12444         long ret_ref = (long)ret_var.inner;
12445         if (ret_var.is_owned) {
12446                 ret_ref |= 1;
12447         }
12448         return ret_ref;
12449 }
12450
12451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12452         LDKFundingSigned orig_conv;
12453         orig_conv.inner = (void*)(orig & (~1));
12454         orig_conv.is_owned = false;
12455         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
12456         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12457         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12458         long ret_ref = (long)ret_var.inner;
12459         if (ret_var.is_owned) {
12460                 ret_ref |= 1;
12461         }
12462         return ret_ref;
12463 }
12464
12465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12466         LDKFundingLocked this_ptr_conv;
12467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12468         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12469         FundingLocked_free(this_ptr_conv);
12470 }
12471
12472 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12473         LDKFundingLocked this_ptr_conv;
12474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12475         this_ptr_conv.is_owned = false;
12476         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12477         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
12478         return ret_arr;
12479 }
12480
12481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12482         LDKFundingLocked this_ptr_conv;
12483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12484         this_ptr_conv.is_owned = false;
12485         LDKThirtyTwoBytes val_ref;
12486         CHECK((*env)->GetArrayLength(env, val) == 32);
12487         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12488         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
12489 }
12490
12491 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
12492         LDKFundingLocked this_ptr_conv;
12493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12494         this_ptr_conv.is_owned = false;
12495         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
12496         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
12497         return arg_arr;
12498 }
12499
12500 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) {
12501         LDKFundingLocked this_ptr_conv;
12502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12503         this_ptr_conv.is_owned = false;
12504         LDKPublicKey val_ref;
12505         CHECK((*env)->GetArrayLength(env, val) == 33);
12506         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12507         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
12508 }
12509
12510 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) {
12511         LDKThirtyTwoBytes channel_id_arg_ref;
12512         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
12513         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
12514         LDKPublicKey next_per_commitment_point_arg_ref;
12515         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
12516         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
12517         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
12518         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12519         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12520         long ret_ref = (long)ret_var.inner;
12521         if (ret_var.is_owned) {
12522                 ret_ref |= 1;
12523         }
12524         return ret_ref;
12525 }
12526
12527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12528         LDKFundingLocked orig_conv;
12529         orig_conv.inner = (void*)(orig & (~1));
12530         orig_conv.is_owned = false;
12531         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
12532         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12533         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12534         long ret_ref = (long)ret_var.inner;
12535         if (ret_var.is_owned) {
12536                 ret_ref |= 1;
12537         }
12538         return ret_ref;
12539 }
12540
12541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12542         LDKShutdown this_ptr_conv;
12543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12544         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12545         Shutdown_free(this_ptr_conv);
12546 }
12547
12548 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12549         LDKShutdown this_ptr_conv;
12550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12551         this_ptr_conv.is_owned = false;
12552         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12553         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
12554         return ret_arr;
12555 }
12556
12557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12558         LDKShutdown this_ptr_conv;
12559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12560         this_ptr_conv.is_owned = false;
12561         LDKThirtyTwoBytes val_ref;
12562         CHECK((*env)->GetArrayLength(env, val) == 32);
12563         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12564         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
12565 }
12566
12567 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
12568         LDKShutdown this_ptr_conv;
12569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12570         this_ptr_conv.is_owned = false;
12571         LDKu8slice arg_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
12572         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
12573         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
12574         return arg_arr;
12575 }
12576
12577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12578         LDKShutdown this_ptr_conv;
12579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12580         this_ptr_conv.is_owned = false;
12581         LDKCVec_u8Z val_ref;
12582         val_ref.datalen = (*env)->GetArrayLength(env, val);
12583         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
12584         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
12585         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
12586 }
12587
12588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
12589         LDKThirtyTwoBytes channel_id_arg_ref;
12590         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
12591         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
12592         LDKCVec_u8Z scriptpubkey_arg_ref;
12593         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
12594         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
12595         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
12596         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
12597         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12598         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12599         long ret_ref = (long)ret_var.inner;
12600         if (ret_var.is_owned) {
12601                 ret_ref |= 1;
12602         }
12603         return ret_ref;
12604 }
12605
12606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12607         LDKShutdown orig_conv;
12608         orig_conv.inner = (void*)(orig & (~1));
12609         orig_conv.is_owned = false;
12610         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
12611         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12612         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12613         long ret_ref = (long)ret_var.inner;
12614         if (ret_var.is_owned) {
12615                 ret_ref |= 1;
12616         }
12617         return ret_ref;
12618 }
12619
12620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12621         LDKClosingSigned this_ptr_conv;
12622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12623         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12624         ClosingSigned_free(this_ptr_conv);
12625 }
12626
12627 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12628         LDKClosingSigned this_ptr_conv;
12629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12630         this_ptr_conv.is_owned = false;
12631         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12632         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
12633         return ret_arr;
12634 }
12635
12636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12637         LDKClosingSigned this_ptr_conv;
12638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12639         this_ptr_conv.is_owned = false;
12640         LDKThirtyTwoBytes val_ref;
12641         CHECK((*env)->GetArrayLength(env, val) == 32);
12642         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12643         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
12644 }
12645
12646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12647         LDKClosingSigned this_ptr_conv;
12648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12649         this_ptr_conv.is_owned = false;
12650         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
12651         return ret_val;
12652 }
12653
12654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12655         LDKClosingSigned this_ptr_conv;
12656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12657         this_ptr_conv.is_owned = false;
12658         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
12659 }
12660
12661 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
12662         LDKClosingSigned this_ptr_conv;
12663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12664         this_ptr_conv.is_owned = false;
12665         int8_tArray arg_arr = (*env)->NewByteArray(env, 64);
12666         (*env)->SetByteArrayRegion(env, arg_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
12667         return arg_arr;
12668 }
12669
12670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12671         LDKClosingSigned this_ptr_conv;
12672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12673         this_ptr_conv.is_owned = false;
12674         LDKSignature val_ref;
12675         CHECK((*env)->GetArrayLength(env, val) == 64);
12676         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
12677         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
12678 }
12679
12680 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) {
12681         LDKThirtyTwoBytes channel_id_arg_ref;
12682         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
12683         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
12684         LDKSignature signature_arg_ref;
12685         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
12686         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
12687         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
12688         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12689         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12690         long ret_ref = (long)ret_var.inner;
12691         if (ret_var.is_owned) {
12692                 ret_ref |= 1;
12693         }
12694         return ret_ref;
12695 }
12696
12697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12698         LDKClosingSigned orig_conv;
12699         orig_conv.inner = (void*)(orig & (~1));
12700         orig_conv.is_owned = false;
12701         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
12702         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12703         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12704         long ret_ref = (long)ret_var.inner;
12705         if (ret_var.is_owned) {
12706                 ret_ref |= 1;
12707         }
12708         return ret_ref;
12709 }
12710
12711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12712         LDKUpdateAddHTLC this_ptr_conv;
12713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12714         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12715         UpdateAddHTLC_free(this_ptr_conv);
12716 }
12717
12718 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12719         LDKUpdateAddHTLC this_ptr_conv;
12720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12721         this_ptr_conv.is_owned = false;
12722         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12723         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
12724         return ret_arr;
12725 }
12726
12727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12728         LDKUpdateAddHTLC this_ptr_conv;
12729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12730         this_ptr_conv.is_owned = false;
12731         LDKThirtyTwoBytes val_ref;
12732         CHECK((*env)->GetArrayLength(env, val) == 32);
12733         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12734         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
12735 }
12736
12737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12738         LDKUpdateAddHTLC this_ptr_conv;
12739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12740         this_ptr_conv.is_owned = false;
12741         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
12742         return ret_val;
12743 }
12744
12745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12746         LDKUpdateAddHTLC this_ptr_conv;
12747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12748         this_ptr_conv.is_owned = false;
12749         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
12750 }
12751
12752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
12753         LDKUpdateAddHTLC this_ptr_conv;
12754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12755         this_ptr_conv.is_owned = false;
12756         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
12757         return ret_val;
12758 }
12759
12760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12761         LDKUpdateAddHTLC this_ptr_conv;
12762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12763         this_ptr_conv.is_owned = false;
12764         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
12765 }
12766
12767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
12768         LDKUpdateAddHTLC this_ptr_conv;
12769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12770         this_ptr_conv.is_owned = false;
12771         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12772         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
12773         return ret_arr;
12774 }
12775
12776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12777         LDKUpdateAddHTLC this_ptr_conv;
12778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12779         this_ptr_conv.is_owned = false;
12780         LDKThirtyTwoBytes val_ref;
12781         CHECK((*env)->GetArrayLength(env, val) == 32);
12782         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12783         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
12784 }
12785
12786 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
12787         LDKUpdateAddHTLC this_ptr_conv;
12788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12789         this_ptr_conv.is_owned = false;
12790         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
12791         return ret_val;
12792 }
12793
12794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
12795         LDKUpdateAddHTLC this_ptr_conv;
12796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12797         this_ptr_conv.is_owned = false;
12798         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
12799 }
12800
12801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12802         LDKUpdateAddHTLC orig_conv;
12803         orig_conv.inner = (void*)(orig & (~1));
12804         orig_conv.is_owned = false;
12805         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
12806         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12807         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12808         long ret_ref = (long)ret_var.inner;
12809         if (ret_var.is_owned) {
12810                 ret_ref |= 1;
12811         }
12812         return ret_ref;
12813 }
12814
12815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12816         LDKUpdateFulfillHTLC this_ptr_conv;
12817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12818         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12819         UpdateFulfillHTLC_free(this_ptr_conv);
12820 }
12821
12822 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12823         LDKUpdateFulfillHTLC this_ptr_conv;
12824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12825         this_ptr_conv.is_owned = false;
12826         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12827         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
12828         return ret_arr;
12829 }
12830
12831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12832         LDKUpdateFulfillHTLC this_ptr_conv;
12833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12834         this_ptr_conv.is_owned = false;
12835         LDKThirtyTwoBytes val_ref;
12836         CHECK((*env)->GetArrayLength(env, val) == 32);
12837         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12838         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
12839 }
12840
12841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12842         LDKUpdateFulfillHTLC this_ptr_conv;
12843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12844         this_ptr_conv.is_owned = false;
12845         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
12846         return ret_val;
12847 }
12848
12849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12850         LDKUpdateFulfillHTLC this_ptr_conv;
12851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12852         this_ptr_conv.is_owned = false;
12853         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
12854 }
12855
12856 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
12857         LDKUpdateFulfillHTLC this_ptr_conv;
12858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12859         this_ptr_conv.is_owned = false;
12860         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12861         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
12862         return ret_arr;
12863 }
12864
12865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12866         LDKUpdateFulfillHTLC this_ptr_conv;
12867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12868         this_ptr_conv.is_owned = false;
12869         LDKThirtyTwoBytes val_ref;
12870         CHECK((*env)->GetArrayLength(env, val) == 32);
12871         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12872         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
12873 }
12874
12875 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) {
12876         LDKThirtyTwoBytes channel_id_arg_ref;
12877         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
12878         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
12879         LDKThirtyTwoBytes payment_preimage_arg_ref;
12880         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
12881         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
12882         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
12883         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12884         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12885         long ret_ref = (long)ret_var.inner;
12886         if (ret_var.is_owned) {
12887                 ret_ref |= 1;
12888         }
12889         return ret_ref;
12890 }
12891
12892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12893         LDKUpdateFulfillHTLC orig_conv;
12894         orig_conv.inner = (void*)(orig & (~1));
12895         orig_conv.is_owned = false;
12896         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
12897         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12898         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12899         long ret_ref = (long)ret_var.inner;
12900         if (ret_var.is_owned) {
12901                 ret_ref |= 1;
12902         }
12903         return ret_ref;
12904 }
12905
12906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12907         LDKUpdateFailHTLC this_ptr_conv;
12908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12909         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12910         UpdateFailHTLC_free(this_ptr_conv);
12911 }
12912
12913 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12914         LDKUpdateFailHTLC this_ptr_conv;
12915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12916         this_ptr_conv.is_owned = false;
12917         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12918         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
12919         return ret_arr;
12920 }
12921
12922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12923         LDKUpdateFailHTLC this_ptr_conv;
12924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12925         this_ptr_conv.is_owned = false;
12926         LDKThirtyTwoBytes val_ref;
12927         CHECK((*env)->GetArrayLength(env, val) == 32);
12928         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12929         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
12930 }
12931
12932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12933         LDKUpdateFailHTLC this_ptr_conv;
12934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12935         this_ptr_conv.is_owned = false;
12936         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
12937         return ret_val;
12938 }
12939
12940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12941         LDKUpdateFailHTLC this_ptr_conv;
12942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12943         this_ptr_conv.is_owned = false;
12944         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
12945 }
12946
12947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12948         LDKUpdateFailHTLC orig_conv;
12949         orig_conv.inner = (void*)(orig & (~1));
12950         orig_conv.is_owned = false;
12951         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
12952         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12953         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12954         long ret_ref = (long)ret_var.inner;
12955         if (ret_var.is_owned) {
12956                 ret_ref |= 1;
12957         }
12958         return ret_ref;
12959 }
12960
12961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12962         LDKUpdateFailMalformedHTLC this_ptr_conv;
12963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12964         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12965         UpdateFailMalformedHTLC_free(this_ptr_conv);
12966 }
12967
12968 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12969         LDKUpdateFailMalformedHTLC this_ptr_conv;
12970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12971         this_ptr_conv.is_owned = false;
12972         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12973         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
12974         return ret_arr;
12975 }
12976
12977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12978         LDKUpdateFailMalformedHTLC this_ptr_conv;
12979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12980         this_ptr_conv.is_owned = false;
12981         LDKThirtyTwoBytes val_ref;
12982         CHECK((*env)->GetArrayLength(env, val) == 32);
12983         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12984         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
12985 }
12986
12987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12988         LDKUpdateFailMalformedHTLC this_ptr_conv;
12989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12990         this_ptr_conv.is_owned = false;
12991         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
12992         return ret_val;
12993 }
12994
12995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12996         LDKUpdateFailMalformedHTLC this_ptr_conv;
12997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12998         this_ptr_conv.is_owned = false;
12999         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
13000 }
13001
13002 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
13003         LDKUpdateFailMalformedHTLC this_ptr_conv;
13004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13005         this_ptr_conv.is_owned = false;
13006         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
13007         return ret_val;
13008 }
13009
13010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13011         LDKUpdateFailMalformedHTLC this_ptr_conv;
13012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13013         this_ptr_conv.is_owned = false;
13014         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
13015 }
13016
13017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13018         LDKUpdateFailMalformedHTLC orig_conv;
13019         orig_conv.inner = (void*)(orig & (~1));
13020         orig_conv.is_owned = false;
13021         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
13022         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13023         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13024         long ret_ref = (long)ret_var.inner;
13025         if (ret_var.is_owned) {
13026                 ret_ref |= 1;
13027         }
13028         return ret_ref;
13029 }
13030
13031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13032         LDKCommitmentSigned this_ptr_conv;
13033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13034         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13035         CommitmentSigned_free(this_ptr_conv);
13036 }
13037
13038 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13039         LDKCommitmentSigned this_ptr_conv;
13040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13041         this_ptr_conv.is_owned = false;
13042         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13043         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
13044         return ret_arr;
13045 }
13046
13047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13048         LDKCommitmentSigned this_ptr_conv;
13049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13050         this_ptr_conv.is_owned = false;
13051         LDKThirtyTwoBytes val_ref;
13052         CHECK((*env)->GetArrayLength(env, val) == 32);
13053         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13054         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
13055 }
13056
13057 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
13058         LDKCommitmentSigned this_ptr_conv;
13059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13060         this_ptr_conv.is_owned = false;
13061         int8_tArray arg_arr = (*env)->NewByteArray(env, 64);
13062         (*env)->SetByteArrayRegion(env, arg_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
13063         return arg_arr;
13064 }
13065
13066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13067         LDKCommitmentSigned this_ptr_conv;
13068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13069         this_ptr_conv.is_owned = false;
13070         LDKSignature val_ref;
13071         CHECK((*env)->GetArrayLength(env, val) == 64);
13072         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
13073         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
13074 }
13075
13076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
13077         LDKCommitmentSigned this_ptr_conv;
13078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13079         this_ptr_conv.is_owned = false;
13080         LDKCVec_SignatureZ val_constr;
13081         val_constr.datalen = (*env)->GetArrayLength(env, val);
13082         if (val_constr.datalen > 0)
13083                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13084         else
13085                 val_constr.data = NULL;
13086         for (size_t i = 0; i < val_constr.datalen; i++) {
13087                 int8_tArray arr_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
13088                 LDKSignature arr_conv_8_ref;
13089                 CHECK((*env)->GetArrayLength(env, arr_conv_8) == 64);
13090                 (*env)->GetByteArrayRegion(env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
13091                 val_constr.data[i] = arr_conv_8_ref;
13092         }
13093         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
13094 }
13095
13096 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) {
13097         LDKThirtyTwoBytes channel_id_arg_ref;
13098         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13099         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13100         LDKSignature signature_arg_ref;
13101         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
13102         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
13103         LDKCVec_SignatureZ htlc_signatures_arg_constr;
13104         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
13105         if (htlc_signatures_arg_constr.datalen > 0)
13106                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13107         else
13108                 htlc_signatures_arg_constr.data = NULL;
13109         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
13110                 int8_tArray arr_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
13111                 LDKSignature arr_conv_8_ref;
13112                 CHECK((*env)->GetArrayLength(env, arr_conv_8) == 64);
13113                 (*env)->GetByteArrayRegion(env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
13114                 htlc_signatures_arg_constr.data[i] = arr_conv_8_ref;
13115         }
13116         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
13117         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13118         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13119         long ret_ref = (long)ret_var.inner;
13120         if (ret_var.is_owned) {
13121                 ret_ref |= 1;
13122         }
13123         return ret_ref;
13124 }
13125
13126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13127         LDKCommitmentSigned orig_conv;
13128         orig_conv.inner = (void*)(orig & (~1));
13129         orig_conv.is_owned = false;
13130         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
13131         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13132         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13133         long ret_ref = (long)ret_var.inner;
13134         if (ret_var.is_owned) {
13135                 ret_ref |= 1;
13136         }
13137         return ret_ref;
13138 }
13139
13140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13141         LDKRevokeAndACK this_ptr_conv;
13142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13143         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13144         RevokeAndACK_free(this_ptr_conv);
13145 }
13146
13147 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13148         LDKRevokeAndACK this_ptr_conv;
13149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13150         this_ptr_conv.is_owned = false;
13151         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13152         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
13153         return ret_arr;
13154 }
13155
13156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13157         LDKRevokeAndACK this_ptr_conv;
13158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13159         this_ptr_conv.is_owned = false;
13160         LDKThirtyTwoBytes val_ref;
13161         CHECK((*env)->GetArrayLength(env, val) == 32);
13162         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13163         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
13164 }
13165
13166 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
13167         LDKRevokeAndACK this_ptr_conv;
13168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13169         this_ptr_conv.is_owned = false;
13170         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13171         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
13172         return ret_arr;
13173 }
13174
13175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13176         LDKRevokeAndACK this_ptr_conv;
13177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13178         this_ptr_conv.is_owned = false;
13179         LDKThirtyTwoBytes val_ref;
13180         CHECK((*env)->GetArrayLength(env, val) == 32);
13181         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13182         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
13183 }
13184
13185 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13186         LDKRevokeAndACK this_ptr_conv;
13187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13188         this_ptr_conv.is_owned = false;
13189         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
13190         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
13191         return arg_arr;
13192 }
13193
13194 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) {
13195         LDKRevokeAndACK this_ptr_conv;
13196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13197         this_ptr_conv.is_owned = false;
13198         LDKPublicKey val_ref;
13199         CHECK((*env)->GetArrayLength(env, val) == 33);
13200         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13201         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
13202 }
13203
13204 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) {
13205         LDKThirtyTwoBytes channel_id_arg_ref;
13206         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13207         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13208         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
13209         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
13210         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
13211         LDKPublicKey next_per_commitment_point_arg_ref;
13212         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
13213         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
13214         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
13215         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13216         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13217         long ret_ref = (long)ret_var.inner;
13218         if (ret_var.is_owned) {
13219                 ret_ref |= 1;
13220         }
13221         return ret_ref;
13222 }
13223
13224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13225         LDKRevokeAndACK orig_conv;
13226         orig_conv.inner = (void*)(orig & (~1));
13227         orig_conv.is_owned = false;
13228         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
13229         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13230         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13231         long ret_ref = (long)ret_var.inner;
13232         if (ret_var.is_owned) {
13233                 ret_ref |= 1;
13234         }
13235         return ret_ref;
13236 }
13237
13238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13239         LDKUpdateFee this_ptr_conv;
13240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13241         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13242         UpdateFee_free(this_ptr_conv);
13243 }
13244
13245 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13246         LDKUpdateFee this_ptr_conv;
13247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13248         this_ptr_conv.is_owned = false;
13249         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13250         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
13251         return ret_arr;
13252 }
13253
13254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13255         LDKUpdateFee this_ptr_conv;
13256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13257         this_ptr_conv.is_owned = false;
13258         LDKThirtyTwoBytes val_ref;
13259         CHECK((*env)->GetArrayLength(env, val) == 32);
13260         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13261         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
13262 }
13263
13264 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
13265         LDKUpdateFee this_ptr_conv;
13266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13267         this_ptr_conv.is_owned = false;
13268         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
13269         return ret_val;
13270 }
13271
13272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13273         LDKUpdateFee this_ptr_conv;
13274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13275         this_ptr_conv.is_owned = false;
13276         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
13277 }
13278
13279 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) {
13280         LDKThirtyTwoBytes channel_id_arg_ref;
13281         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13282         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13283         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
13284         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13285         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13286         long ret_ref = (long)ret_var.inner;
13287         if (ret_var.is_owned) {
13288                 ret_ref |= 1;
13289         }
13290         return ret_ref;
13291 }
13292
13293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13294         LDKUpdateFee orig_conv;
13295         orig_conv.inner = (void*)(orig & (~1));
13296         orig_conv.is_owned = false;
13297         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
13298         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13299         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13300         long ret_ref = (long)ret_var.inner;
13301         if (ret_var.is_owned) {
13302                 ret_ref |= 1;
13303         }
13304         return ret_ref;
13305 }
13306
13307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13308         LDKDataLossProtect this_ptr_conv;
13309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13310         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13311         DataLossProtect_free(this_ptr_conv);
13312 }
13313
13314 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
13315         LDKDataLossProtect this_ptr_conv;
13316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13317         this_ptr_conv.is_owned = false;
13318         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13319         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
13320         return ret_arr;
13321 }
13322
13323 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) {
13324         LDKDataLossProtect this_ptr_conv;
13325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13326         this_ptr_conv.is_owned = false;
13327         LDKThirtyTwoBytes val_ref;
13328         CHECK((*env)->GetArrayLength(env, val) == 32);
13329         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13330         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
13331 }
13332
13333 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13334         LDKDataLossProtect this_ptr_conv;
13335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13336         this_ptr_conv.is_owned = false;
13337         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
13338         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
13339         return arg_arr;
13340 }
13341
13342 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) {
13343         LDKDataLossProtect this_ptr_conv;
13344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13345         this_ptr_conv.is_owned = false;
13346         LDKPublicKey val_ref;
13347         CHECK((*env)->GetArrayLength(env, val) == 33);
13348         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13349         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
13350 }
13351
13352 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) {
13353         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
13354         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
13355         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
13356         LDKPublicKey my_current_per_commitment_point_arg_ref;
13357         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
13358         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
13359         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
13360         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13361         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13362         long ret_ref = (long)ret_var.inner;
13363         if (ret_var.is_owned) {
13364                 ret_ref |= 1;
13365         }
13366         return ret_ref;
13367 }
13368
13369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13370         LDKDataLossProtect orig_conv;
13371         orig_conv.inner = (void*)(orig & (~1));
13372         orig_conv.is_owned = false;
13373         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
13374         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13375         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13376         long ret_ref = (long)ret_var.inner;
13377         if (ret_var.is_owned) {
13378                 ret_ref |= 1;
13379         }
13380         return ret_ref;
13381 }
13382
13383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13384         LDKChannelReestablish this_ptr_conv;
13385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13386         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13387         ChannelReestablish_free(this_ptr_conv);
13388 }
13389
13390 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13391         LDKChannelReestablish this_ptr_conv;
13392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13393         this_ptr_conv.is_owned = false;
13394         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13395         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
13396         return ret_arr;
13397 }
13398
13399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13400         LDKChannelReestablish this_ptr_conv;
13401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13402         this_ptr_conv.is_owned = false;
13403         LDKThirtyTwoBytes val_ref;
13404         CHECK((*env)->GetArrayLength(env, val) == 32);
13405         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13406         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
13407 }
13408
13409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
13410         LDKChannelReestablish this_ptr_conv;
13411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13412         this_ptr_conv.is_owned = false;
13413         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
13414         return ret_val;
13415 }
13416
13417 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) {
13418         LDKChannelReestablish this_ptr_conv;
13419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13420         this_ptr_conv.is_owned = false;
13421         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
13422 }
13423
13424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
13425         LDKChannelReestablish this_ptr_conv;
13426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13427         this_ptr_conv.is_owned = false;
13428         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
13429         return ret_val;
13430 }
13431
13432 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) {
13433         LDKChannelReestablish this_ptr_conv;
13434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13435         this_ptr_conv.is_owned = false;
13436         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
13437 }
13438
13439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13440         LDKChannelReestablish orig_conv;
13441         orig_conv.inner = (void*)(orig & (~1));
13442         orig_conv.is_owned = false;
13443         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
13444         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13445         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13446         long ret_ref = (long)ret_var.inner;
13447         if (ret_var.is_owned) {
13448                 ret_ref |= 1;
13449         }
13450         return ret_ref;
13451 }
13452
13453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13454         LDKAnnouncementSignatures this_ptr_conv;
13455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13456         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13457         AnnouncementSignatures_free(this_ptr_conv);
13458 }
13459
13460 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13461         LDKAnnouncementSignatures this_ptr_conv;
13462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13463         this_ptr_conv.is_owned = false;
13464         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13465         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
13466         return ret_arr;
13467 }
13468
13469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13470         LDKAnnouncementSignatures this_ptr_conv;
13471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13472         this_ptr_conv.is_owned = false;
13473         LDKThirtyTwoBytes val_ref;
13474         CHECK((*env)->GetArrayLength(env, val) == 32);
13475         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13476         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
13477 }
13478
13479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13480         LDKAnnouncementSignatures this_ptr_conv;
13481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13482         this_ptr_conv.is_owned = false;
13483         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
13484         return ret_val;
13485 }
13486
13487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13488         LDKAnnouncementSignatures this_ptr_conv;
13489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13490         this_ptr_conv.is_owned = false;
13491         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
13492 }
13493
13494 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
13495         LDKAnnouncementSignatures this_ptr_conv;
13496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13497         this_ptr_conv.is_owned = false;
13498         int8_tArray arg_arr = (*env)->NewByteArray(env, 64);
13499         (*env)->SetByteArrayRegion(env, arg_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
13500         return arg_arr;
13501 }
13502
13503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13504         LDKAnnouncementSignatures this_ptr_conv;
13505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13506         this_ptr_conv.is_owned = false;
13507         LDKSignature val_ref;
13508         CHECK((*env)->GetArrayLength(env, val) == 64);
13509         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
13510         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
13511 }
13512
13513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
13514         LDKAnnouncementSignatures this_ptr_conv;
13515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13516         this_ptr_conv.is_owned = false;
13517         int8_tArray arg_arr = (*env)->NewByteArray(env, 64);
13518         (*env)->SetByteArrayRegion(env, arg_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
13519         return arg_arr;
13520 }
13521
13522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13523         LDKAnnouncementSignatures this_ptr_conv;
13524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13525         this_ptr_conv.is_owned = false;
13526         LDKSignature val_ref;
13527         CHECK((*env)->GetArrayLength(env, val) == 64);
13528         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
13529         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
13530 }
13531
13532 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) {
13533         LDKThirtyTwoBytes channel_id_arg_ref;
13534         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13535         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13536         LDKSignature node_signature_arg_ref;
13537         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
13538         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
13539         LDKSignature bitcoin_signature_arg_ref;
13540         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
13541         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
13542         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
13543         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13544         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13545         long ret_ref = (long)ret_var.inner;
13546         if (ret_var.is_owned) {
13547                 ret_ref |= 1;
13548         }
13549         return ret_ref;
13550 }
13551
13552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13553         LDKAnnouncementSignatures orig_conv;
13554         orig_conv.inner = (void*)(orig & (~1));
13555         orig_conv.is_owned = false;
13556         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
13557         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13558         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13559         long ret_ref = (long)ret_var.inner;
13560         if (ret_var.is_owned) {
13561                 ret_ref |= 1;
13562         }
13563         return ret_ref;
13564 }
13565
13566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13567         if ((this_ptr & 1) != 0) return;
13568         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
13569         FREE((void*)this_ptr);
13570         NetAddress_free(this_ptr_conv);
13571 }
13572
13573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13574         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
13575         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
13576         *ret_copy = NetAddress_clone(orig_conv);
13577         long ret_ref = (long)ret_copy;
13578         return ret_ref;
13579 }
13580
13581 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
13582         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
13583         LDKCVec_u8Z arg_var = NetAddress_write(obj_conv);
13584         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
13585         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
13586         CVec_u8Z_free(arg_var);
13587         return arg_arr;
13588 }
13589
13590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
13591         LDKu8slice ser_ref;
13592         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13593         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13594         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
13595         *ret_conv = Result_read(ser_ref);
13596         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
13597         return (long)ret_conv;
13598 }
13599
13600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13601         LDKUnsignedNodeAnnouncement this_ptr_conv;
13602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13603         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13604         UnsignedNodeAnnouncement_free(this_ptr_conv);
13605 }
13606
13607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
13608         LDKUnsignedNodeAnnouncement this_ptr_conv;
13609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13610         this_ptr_conv.is_owned = false;
13611         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
13612         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13613         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13614         long ret_ref = (long)ret_var.inner;
13615         if (ret_var.is_owned) {
13616                 ret_ref |= 1;
13617         }
13618         return ret_ref;
13619 }
13620
13621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13622         LDKUnsignedNodeAnnouncement this_ptr_conv;
13623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13624         this_ptr_conv.is_owned = false;
13625         LDKNodeFeatures val_conv;
13626         val_conv.inner = (void*)(val & (~1));
13627         val_conv.is_owned = (val & 1) || (val == 0);
13628         val_conv = NodeFeatures_clone(&val_conv);
13629         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
13630 }
13631
13632 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
13633         LDKUnsignedNodeAnnouncement this_ptr_conv;
13634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13635         this_ptr_conv.is_owned = false;
13636         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
13637         return ret_val;
13638 }
13639
13640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13641         LDKUnsignedNodeAnnouncement this_ptr_conv;
13642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13643         this_ptr_conv.is_owned = false;
13644         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
13645 }
13646
13647 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13648         LDKUnsignedNodeAnnouncement this_ptr_conv;
13649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13650         this_ptr_conv.is_owned = false;
13651         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
13652         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
13653         return arg_arr;
13654 }
13655
13656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13657         LDKUnsignedNodeAnnouncement this_ptr_conv;
13658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13659         this_ptr_conv.is_owned = false;
13660         LDKPublicKey val_ref;
13661         CHECK((*env)->GetArrayLength(env, val) == 33);
13662         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13663         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
13664 }
13665
13666 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
13667         LDKUnsignedNodeAnnouncement this_ptr_conv;
13668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13669         this_ptr_conv.is_owned = false;
13670         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
13671         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
13672         return ret_arr;
13673 }
13674
13675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13676         LDKUnsignedNodeAnnouncement this_ptr_conv;
13677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13678         this_ptr_conv.is_owned = false;
13679         LDKThreeBytes val_ref;
13680         CHECK((*env)->GetArrayLength(env, val) == 3);
13681         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
13682         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
13683 }
13684
13685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
13686         LDKUnsignedNodeAnnouncement this_ptr_conv;
13687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13688         this_ptr_conv.is_owned = false;
13689         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13690         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
13691         return ret_arr;
13692 }
13693
13694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13695         LDKUnsignedNodeAnnouncement this_ptr_conv;
13696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13697         this_ptr_conv.is_owned = false;
13698         LDKThirtyTwoBytes val_ref;
13699         CHECK((*env)->GetArrayLength(env, val) == 32);
13700         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13701         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
13702 }
13703
13704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
13705         LDKUnsignedNodeAnnouncement this_ptr_conv;
13706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13707         this_ptr_conv.is_owned = false;
13708         LDKCVec_NetAddressZ val_constr;
13709         val_constr.datalen = (*env)->GetArrayLength(env, val);
13710         if (val_constr.datalen > 0)
13711                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
13712         else
13713                 val_constr.data = NULL;
13714         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
13715         for (size_t m = 0; m < val_constr.datalen; m++) {
13716                 int64_t arr_conv_12 = val_vals[m];
13717                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)(((uint64_t)arr_conv_12) & ~1);
13718                 FREE((void*)arr_conv_12);
13719                 val_constr.data[m] = arr_conv_12_conv;
13720         }
13721         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
13722         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
13723 }
13724
13725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13726         LDKUnsignedNodeAnnouncement orig_conv;
13727         orig_conv.inner = (void*)(orig & (~1));
13728         orig_conv.is_owned = false;
13729         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
13730         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13731         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13732         long ret_ref = (long)ret_var.inner;
13733         if (ret_var.is_owned) {
13734                 ret_ref |= 1;
13735         }
13736         return ret_ref;
13737 }
13738
13739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13740         LDKNodeAnnouncement this_ptr_conv;
13741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13742         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13743         NodeAnnouncement_free(this_ptr_conv);
13744 }
13745
13746 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
13747         LDKNodeAnnouncement this_ptr_conv;
13748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13749         this_ptr_conv.is_owned = false;
13750         int8_tArray arg_arr = (*env)->NewByteArray(env, 64);
13751         (*env)->SetByteArrayRegion(env, arg_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
13752         return arg_arr;
13753 }
13754
13755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13756         LDKNodeAnnouncement this_ptr_conv;
13757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13758         this_ptr_conv.is_owned = false;
13759         LDKSignature val_ref;
13760         CHECK((*env)->GetArrayLength(env, val) == 64);
13761         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
13762         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
13763 }
13764
13765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
13766         LDKNodeAnnouncement this_ptr_conv;
13767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13768         this_ptr_conv.is_owned = false;
13769         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
13770         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13771         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13772         long ret_ref = (long)ret_var.inner;
13773         if (ret_var.is_owned) {
13774                 ret_ref |= 1;
13775         }
13776         return ret_ref;
13777 }
13778
13779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13780         LDKNodeAnnouncement this_ptr_conv;
13781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13782         this_ptr_conv.is_owned = false;
13783         LDKUnsignedNodeAnnouncement val_conv;
13784         val_conv.inner = (void*)(val & (~1));
13785         val_conv.is_owned = (val & 1) || (val == 0);
13786         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
13787         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
13788 }
13789
13790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
13791         LDKSignature signature_arg_ref;
13792         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
13793         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
13794         LDKUnsignedNodeAnnouncement contents_arg_conv;
13795         contents_arg_conv.inner = (void*)(contents_arg & (~1));
13796         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
13797         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
13798         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
13799         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13800         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13801         long ret_ref = (long)ret_var.inner;
13802         if (ret_var.is_owned) {
13803                 ret_ref |= 1;
13804         }
13805         return ret_ref;
13806 }
13807
13808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13809         LDKNodeAnnouncement orig_conv;
13810         orig_conv.inner = (void*)(orig & (~1));
13811         orig_conv.is_owned = false;
13812         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
13813         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13814         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13815         long ret_ref = (long)ret_var.inner;
13816         if (ret_var.is_owned) {
13817                 ret_ref |= 1;
13818         }
13819         return ret_ref;
13820 }
13821
13822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13823         LDKUnsignedChannelAnnouncement this_ptr_conv;
13824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13825         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13826         UnsignedChannelAnnouncement_free(this_ptr_conv);
13827 }
13828
13829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
13830         LDKUnsignedChannelAnnouncement this_ptr_conv;
13831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13832         this_ptr_conv.is_owned = false;
13833         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
13834         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13835         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13836         long ret_ref = (long)ret_var.inner;
13837         if (ret_var.is_owned) {
13838                 ret_ref |= 1;
13839         }
13840         return ret_ref;
13841 }
13842
13843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13844         LDKUnsignedChannelAnnouncement this_ptr_conv;
13845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13846         this_ptr_conv.is_owned = false;
13847         LDKChannelFeatures val_conv;
13848         val_conv.inner = (void*)(val & (~1));
13849         val_conv.is_owned = (val & 1) || (val == 0);
13850         val_conv = ChannelFeatures_clone(&val_conv);
13851         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
13852 }
13853
13854 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
13855         LDKUnsignedChannelAnnouncement this_ptr_conv;
13856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13857         this_ptr_conv.is_owned = false;
13858         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13859         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
13860         return ret_arr;
13861 }
13862
13863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13864         LDKUnsignedChannelAnnouncement this_ptr_conv;
13865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13866         this_ptr_conv.is_owned = false;
13867         LDKThirtyTwoBytes val_ref;
13868         CHECK((*env)->GetArrayLength(env, val) == 32);
13869         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13870         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
13871 }
13872
13873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13874         LDKUnsignedChannelAnnouncement this_ptr_conv;
13875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13876         this_ptr_conv.is_owned = false;
13877         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
13878         return ret_val;
13879 }
13880
13881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13882         LDKUnsignedChannelAnnouncement this_ptr_conv;
13883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13884         this_ptr_conv.is_owned = false;
13885         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
13886 }
13887
13888 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
13889         LDKUnsignedChannelAnnouncement this_ptr_conv;
13890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13891         this_ptr_conv.is_owned = false;
13892         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
13893         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
13894         return arg_arr;
13895 }
13896
13897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13898         LDKUnsignedChannelAnnouncement this_ptr_conv;
13899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13900         this_ptr_conv.is_owned = false;
13901         LDKPublicKey val_ref;
13902         CHECK((*env)->GetArrayLength(env, val) == 33);
13903         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13904         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
13905 }
13906
13907 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
13908         LDKUnsignedChannelAnnouncement this_ptr_conv;
13909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13910         this_ptr_conv.is_owned = false;
13911         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
13912         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
13913         return arg_arr;
13914 }
13915
13916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13917         LDKUnsignedChannelAnnouncement this_ptr_conv;
13918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13919         this_ptr_conv.is_owned = false;
13920         LDKPublicKey val_ref;
13921         CHECK((*env)->GetArrayLength(env, val) == 33);
13922         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13923         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
13924 }
13925
13926 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
13927         LDKUnsignedChannelAnnouncement this_ptr_conv;
13928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13929         this_ptr_conv.is_owned = false;
13930         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
13931         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
13932         return arg_arr;
13933 }
13934
13935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13936         LDKUnsignedChannelAnnouncement this_ptr_conv;
13937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13938         this_ptr_conv.is_owned = false;
13939         LDKPublicKey val_ref;
13940         CHECK((*env)->GetArrayLength(env, val) == 33);
13941         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13942         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
13943 }
13944
13945 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
13946         LDKUnsignedChannelAnnouncement this_ptr_conv;
13947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13948         this_ptr_conv.is_owned = false;
13949         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
13950         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
13951         return arg_arr;
13952 }
13953
13954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13955         LDKUnsignedChannelAnnouncement this_ptr_conv;
13956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13957         this_ptr_conv.is_owned = false;
13958         LDKPublicKey val_ref;
13959         CHECK((*env)->GetArrayLength(env, val) == 33);
13960         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13961         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
13962 }
13963
13964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13965         LDKUnsignedChannelAnnouncement orig_conv;
13966         orig_conv.inner = (void*)(orig & (~1));
13967         orig_conv.is_owned = false;
13968         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
13969         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13970         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13971         long ret_ref = (long)ret_var.inner;
13972         if (ret_var.is_owned) {
13973                 ret_ref |= 1;
13974         }
13975         return ret_ref;
13976 }
13977
13978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13979         LDKChannelAnnouncement this_ptr_conv;
13980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13981         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13982         ChannelAnnouncement_free(this_ptr_conv);
13983 }
13984
13985 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
13986         LDKChannelAnnouncement this_ptr_conv;
13987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13988         this_ptr_conv.is_owned = false;
13989         int8_tArray arg_arr = (*env)->NewByteArray(env, 64);
13990         (*env)->SetByteArrayRegion(env, arg_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
13991         return arg_arr;
13992 }
13993
13994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13995         LDKChannelAnnouncement this_ptr_conv;
13996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13997         this_ptr_conv.is_owned = false;
13998         LDKSignature val_ref;
13999         CHECK((*env)->GetArrayLength(env, val) == 64);
14000         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14001         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
14002 }
14003
14004 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
14005         LDKChannelAnnouncement this_ptr_conv;
14006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14007         this_ptr_conv.is_owned = false;
14008         int8_tArray arg_arr = (*env)->NewByteArray(env, 64);
14009         (*env)->SetByteArrayRegion(env, arg_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
14010         return arg_arr;
14011 }
14012
14013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14014         LDKChannelAnnouncement this_ptr_conv;
14015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14016         this_ptr_conv.is_owned = false;
14017         LDKSignature val_ref;
14018         CHECK((*env)->GetArrayLength(env, val) == 64);
14019         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14020         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
14021 }
14022
14023 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
14024         LDKChannelAnnouncement this_ptr_conv;
14025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14026         this_ptr_conv.is_owned = false;
14027         int8_tArray arg_arr = (*env)->NewByteArray(env, 64);
14028         (*env)->SetByteArrayRegion(env, arg_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
14029         return arg_arr;
14030 }
14031
14032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14033         LDKChannelAnnouncement this_ptr_conv;
14034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14035         this_ptr_conv.is_owned = false;
14036         LDKSignature val_ref;
14037         CHECK((*env)->GetArrayLength(env, val) == 64);
14038         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14039         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
14040 }
14041
14042 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
14043         LDKChannelAnnouncement this_ptr_conv;
14044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14045         this_ptr_conv.is_owned = false;
14046         int8_tArray arg_arr = (*env)->NewByteArray(env, 64);
14047         (*env)->SetByteArrayRegion(env, arg_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
14048         return arg_arr;
14049 }
14050
14051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14052         LDKChannelAnnouncement this_ptr_conv;
14053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14054         this_ptr_conv.is_owned = false;
14055         LDKSignature val_ref;
14056         CHECK((*env)->GetArrayLength(env, val) == 64);
14057         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14058         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
14059 }
14060
14061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
14062         LDKChannelAnnouncement this_ptr_conv;
14063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14064         this_ptr_conv.is_owned = false;
14065         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
14066         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14067         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14068         long ret_ref = (long)ret_var.inner;
14069         if (ret_var.is_owned) {
14070                 ret_ref |= 1;
14071         }
14072         return ret_ref;
14073 }
14074
14075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14076         LDKChannelAnnouncement this_ptr_conv;
14077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14078         this_ptr_conv.is_owned = false;
14079         LDKUnsignedChannelAnnouncement val_conv;
14080         val_conv.inner = (void*)(val & (~1));
14081         val_conv.is_owned = (val & 1) || (val == 0);
14082         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
14083         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
14084 }
14085
14086 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) {
14087         LDKSignature node_signature_1_arg_ref;
14088         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
14089         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
14090         LDKSignature node_signature_2_arg_ref;
14091         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
14092         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
14093         LDKSignature bitcoin_signature_1_arg_ref;
14094         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
14095         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
14096         LDKSignature bitcoin_signature_2_arg_ref;
14097         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
14098         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
14099         LDKUnsignedChannelAnnouncement contents_arg_conv;
14100         contents_arg_conv.inner = (void*)(contents_arg & (~1));
14101         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
14102         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
14103         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);
14104         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14105         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14106         long ret_ref = (long)ret_var.inner;
14107         if (ret_var.is_owned) {
14108                 ret_ref |= 1;
14109         }
14110         return ret_ref;
14111 }
14112
14113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14114         LDKChannelAnnouncement orig_conv;
14115         orig_conv.inner = (void*)(orig & (~1));
14116         orig_conv.is_owned = false;
14117         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
14118         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14119         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14120         long ret_ref = (long)ret_var.inner;
14121         if (ret_var.is_owned) {
14122                 ret_ref |= 1;
14123         }
14124         return ret_ref;
14125 }
14126
14127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14128         LDKUnsignedChannelUpdate this_ptr_conv;
14129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14130         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14131         UnsignedChannelUpdate_free(this_ptr_conv);
14132 }
14133
14134 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14135         LDKUnsignedChannelUpdate this_ptr_conv;
14136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14137         this_ptr_conv.is_owned = false;
14138         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14139         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
14140         return ret_arr;
14141 }
14142
14143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14144         LDKUnsignedChannelUpdate this_ptr_conv;
14145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14146         this_ptr_conv.is_owned = false;
14147         LDKThirtyTwoBytes val_ref;
14148         CHECK((*env)->GetArrayLength(env, val) == 32);
14149         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14150         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
14151 }
14152
14153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14154         LDKUnsignedChannelUpdate this_ptr_conv;
14155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14156         this_ptr_conv.is_owned = false;
14157         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
14158         return ret_val;
14159 }
14160
14161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14162         LDKUnsignedChannelUpdate this_ptr_conv;
14163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14164         this_ptr_conv.is_owned = false;
14165         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
14166 }
14167
14168 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
14169         LDKUnsignedChannelUpdate this_ptr_conv;
14170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14171         this_ptr_conv.is_owned = false;
14172         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
14173         return ret_val;
14174 }
14175
14176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14177         LDKUnsignedChannelUpdate this_ptr_conv;
14178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14179         this_ptr_conv.is_owned = false;
14180         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
14181 }
14182
14183 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
14184         LDKUnsignedChannelUpdate this_ptr_conv;
14185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14186         this_ptr_conv.is_owned = false;
14187         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
14188         return ret_val;
14189 }
14190
14191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
14192         LDKUnsignedChannelUpdate this_ptr_conv;
14193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14194         this_ptr_conv.is_owned = false;
14195         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
14196 }
14197
14198 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
14199         LDKUnsignedChannelUpdate this_ptr_conv;
14200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14201         this_ptr_conv.is_owned = false;
14202         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
14203         return ret_val;
14204 }
14205
14206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14207         LDKUnsignedChannelUpdate this_ptr_conv;
14208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14209         this_ptr_conv.is_owned = false;
14210         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
14211 }
14212
14213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14214         LDKUnsignedChannelUpdate this_ptr_conv;
14215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14216         this_ptr_conv.is_owned = false;
14217         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
14218         return ret_val;
14219 }
14220
14221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14222         LDKUnsignedChannelUpdate this_ptr_conv;
14223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14224         this_ptr_conv.is_owned = false;
14225         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
14226 }
14227
14228 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14229         LDKUnsignedChannelUpdate this_ptr_conv;
14230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14231         this_ptr_conv.is_owned = false;
14232         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
14233         return ret_val;
14234 }
14235
14236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14237         LDKUnsignedChannelUpdate this_ptr_conv;
14238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14239         this_ptr_conv.is_owned = false;
14240         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
14241 }
14242
14243 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
14244         LDKUnsignedChannelUpdate this_ptr_conv;
14245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14246         this_ptr_conv.is_owned = false;
14247         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
14248         return ret_val;
14249 }
14250
14251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14252         LDKUnsignedChannelUpdate this_ptr_conv;
14253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14254         this_ptr_conv.is_owned = false;
14255         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
14256 }
14257
14258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14259         LDKUnsignedChannelUpdate orig_conv;
14260         orig_conv.inner = (void*)(orig & (~1));
14261         orig_conv.is_owned = false;
14262         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
14263         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14264         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14265         long ret_ref = (long)ret_var.inner;
14266         if (ret_var.is_owned) {
14267                 ret_ref |= 1;
14268         }
14269         return ret_ref;
14270 }
14271
14272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14273         LDKChannelUpdate this_ptr_conv;
14274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14275         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14276         ChannelUpdate_free(this_ptr_conv);
14277 }
14278
14279 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14280         LDKChannelUpdate this_ptr_conv;
14281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14282         this_ptr_conv.is_owned = false;
14283         int8_tArray arg_arr = (*env)->NewByteArray(env, 64);
14284         (*env)->SetByteArrayRegion(env, arg_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
14285         return arg_arr;
14286 }
14287
14288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14289         LDKChannelUpdate this_ptr_conv;
14290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14291         this_ptr_conv.is_owned = false;
14292         LDKSignature val_ref;
14293         CHECK((*env)->GetArrayLength(env, val) == 64);
14294         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14295         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
14296 }
14297
14298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
14299         LDKChannelUpdate this_ptr_conv;
14300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14301         this_ptr_conv.is_owned = false;
14302         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
14303         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14304         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14305         long ret_ref = (long)ret_var.inner;
14306         if (ret_var.is_owned) {
14307                 ret_ref |= 1;
14308         }
14309         return ret_ref;
14310 }
14311
14312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14313         LDKChannelUpdate this_ptr_conv;
14314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14315         this_ptr_conv.is_owned = false;
14316         LDKUnsignedChannelUpdate val_conv;
14317         val_conv.inner = (void*)(val & (~1));
14318         val_conv.is_owned = (val & 1) || (val == 0);
14319         val_conv = UnsignedChannelUpdate_clone(&val_conv);
14320         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
14321 }
14322
14323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
14324         LDKSignature signature_arg_ref;
14325         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
14326         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
14327         LDKUnsignedChannelUpdate contents_arg_conv;
14328         contents_arg_conv.inner = (void*)(contents_arg & (~1));
14329         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
14330         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
14331         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
14332         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14333         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14334         long ret_ref = (long)ret_var.inner;
14335         if (ret_var.is_owned) {
14336                 ret_ref |= 1;
14337         }
14338         return ret_ref;
14339 }
14340
14341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14342         LDKChannelUpdate orig_conv;
14343         orig_conv.inner = (void*)(orig & (~1));
14344         orig_conv.is_owned = false;
14345         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
14346         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14347         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14348         long ret_ref = (long)ret_var.inner;
14349         if (ret_var.is_owned) {
14350                 ret_ref |= 1;
14351         }
14352         return ret_ref;
14353 }
14354
14355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14356         LDKQueryChannelRange this_ptr_conv;
14357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14358         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14359         QueryChannelRange_free(this_ptr_conv);
14360 }
14361
14362 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14363         LDKQueryChannelRange this_ptr_conv;
14364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14365         this_ptr_conv.is_owned = false;
14366         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14367         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
14368         return ret_arr;
14369 }
14370
14371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14372         LDKQueryChannelRange this_ptr_conv;
14373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14374         this_ptr_conv.is_owned = false;
14375         LDKThirtyTwoBytes val_ref;
14376         CHECK((*env)->GetArrayLength(env, val) == 32);
14377         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14378         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
14379 }
14380
14381 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
14382         LDKQueryChannelRange this_ptr_conv;
14383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14384         this_ptr_conv.is_owned = false;
14385         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
14386         return ret_val;
14387 }
14388
14389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14390         LDKQueryChannelRange this_ptr_conv;
14391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14392         this_ptr_conv.is_owned = false;
14393         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
14394 }
14395
14396 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
14397         LDKQueryChannelRange this_ptr_conv;
14398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14399         this_ptr_conv.is_owned = false;
14400         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
14401         return ret_val;
14402 }
14403
14404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14405         LDKQueryChannelRange this_ptr_conv;
14406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14407         this_ptr_conv.is_owned = false;
14408         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
14409 }
14410
14411 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) {
14412         LDKThirtyTwoBytes chain_hash_arg_ref;
14413         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
14414         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
14415         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
14416         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14417         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14418         long ret_ref = (long)ret_var.inner;
14419         if (ret_var.is_owned) {
14420                 ret_ref |= 1;
14421         }
14422         return ret_ref;
14423 }
14424
14425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14426         LDKQueryChannelRange orig_conv;
14427         orig_conv.inner = (void*)(orig & (~1));
14428         orig_conv.is_owned = false;
14429         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
14430         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14431         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14432         long ret_ref = (long)ret_var.inner;
14433         if (ret_var.is_owned) {
14434                 ret_ref |= 1;
14435         }
14436         return ret_ref;
14437 }
14438
14439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14440         LDKReplyChannelRange this_ptr_conv;
14441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14442         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14443         ReplyChannelRange_free(this_ptr_conv);
14444 }
14445
14446 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14447         LDKReplyChannelRange this_ptr_conv;
14448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14449         this_ptr_conv.is_owned = false;
14450         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14451         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
14452         return ret_arr;
14453 }
14454
14455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14456         LDKReplyChannelRange this_ptr_conv;
14457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14458         this_ptr_conv.is_owned = false;
14459         LDKThirtyTwoBytes val_ref;
14460         CHECK((*env)->GetArrayLength(env, val) == 32);
14461         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14462         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
14463 }
14464
14465 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
14466         LDKReplyChannelRange this_ptr_conv;
14467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14468         this_ptr_conv.is_owned = false;
14469         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
14470         return ret_val;
14471 }
14472
14473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14474         LDKReplyChannelRange this_ptr_conv;
14475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14476         this_ptr_conv.is_owned = false;
14477         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
14478 }
14479
14480 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
14481         LDKReplyChannelRange this_ptr_conv;
14482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14483         this_ptr_conv.is_owned = false;
14484         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
14485         return ret_val;
14486 }
14487
14488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14489         LDKReplyChannelRange this_ptr_conv;
14490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14491         this_ptr_conv.is_owned = false;
14492         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
14493 }
14494
14495 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
14496         LDKReplyChannelRange this_ptr_conv;
14497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14498         this_ptr_conv.is_owned = false;
14499         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
14500         return ret_val;
14501 }
14502
14503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
14504         LDKReplyChannelRange this_ptr_conv;
14505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14506         this_ptr_conv.is_owned = false;
14507         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
14508 }
14509
14510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
14511         LDKReplyChannelRange this_ptr_conv;
14512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14513         this_ptr_conv.is_owned = false;
14514         LDKCVec_u64Z val_constr;
14515         val_constr.datalen = (*env)->GetArrayLength(env, val);
14516         if (val_constr.datalen > 0)
14517                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14518         else
14519                 val_constr.data = NULL;
14520         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
14521         for (size_t g = 0; g < val_constr.datalen; g++) {
14522                 int64_t arr_conv_6 = val_vals[g];
14523                 val_constr.data[g] = arr_conv_6;
14524         }
14525         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
14526         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
14527 }
14528
14529 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) {
14530         LDKThirtyTwoBytes chain_hash_arg_ref;
14531         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
14532         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
14533         LDKCVec_u64Z short_channel_ids_arg_constr;
14534         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
14535         if (short_channel_ids_arg_constr.datalen > 0)
14536                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14537         else
14538                 short_channel_ids_arg_constr.data = NULL;
14539         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
14540         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
14541                 int64_t arr_conv_6 = short_channel_ids_arg_vals[g];
14542                 short_channel_ids_arg_constr.data[g] = arr_conv_6;
14543         }
14544         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
14545         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
14546         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14547         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14548         long ret_ref = (long)ret_var.inner;
14549         if (ret_var.is_owned) {
14550                 ret_ref |= 1;
14551         }
14552         return ret_ref;
14553 }
14554
14555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14556         LDKReplyChannelRange orig_conv;
14557         orig_conv.inner = (void*)(orig & (~1));
14558         orig_conv.is_owned = false;
14559         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
14560         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14561         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14562         long ret_ref = (long)ret_var.inner;
14563         if (ret_var.is_owned) {
14564                 ret_ref |= 1;
14565         }
14566         return ret_ref;
14567 }
14568
14569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14570         LDKQueryShortChannelIds this_ptr_conv;
14571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14572         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14573         QueryShortChannelIds_free(this_ptr_conv);
14574 }
14575
14576 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14577         LDKQueryShortChannelIds this_ptr_conv;
14578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14579         this_ptr_conv.is_owned = false;
14580         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14581         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
14582         return ret_arr;
14583 }
14584
14585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14586         LDKQueryShortChannelIds this_ptr_conv;
14587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14588         this_ptr_conv.is_owned = false;
14589         LDKThirtyTwoBytes val_ref;
14590         CHECK((*env)->GetArrayLength(env, val) == 32);
14591         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14592         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
14593 }
14594
14595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
14596         LDKQueryShortChannelIds this_ptr_conv;
14597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14598         this_ptr_conv.is_owned = false;
14599         LDKCVec_u64Z val_constr;
14600         val_constr.datalen = (*env)->GetArrayLength(env, val);
14601         if (val_constr.datalen > 0)
14602                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14603         else
14604                 val_constr.data = NULL;
14605         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
14606         for (size_t g = 0; g < val_constr.datalen; g++) {
14607                 int64_t arr_conv_6 = val_vals[g];
14608                 val_constr.data[g] = arr_conv_6;
14609         }
14610         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
14611         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
14612 }
14613
14614 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) {
14615         LDKThirtyTwoBytes chain_hash_arg_ref;
14616         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
14617         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
14618         LDKCVec_u64Z short_channel_ids_arg_constr;
14619         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
14620         if (short_channel_ids_arg_constr.datalen > 0)
14621                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14622         else
14623                 short_channel_ids_arg_constr.data = NULL;
14624         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
14625         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
14626                 int64_t arr_conv_6 = short_channel_ids_arg_vals[g];
14627                 short_channel_ids_arg_constr.data[g] = arr_conv_6;
14628         }
14629         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
14630         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
14631         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14632         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14633         long ret_ref = (long)ret_var.inner;
14634         if (ret_var.is_owned) {
14635                 ret_ref |= 1;
14636         }
14637         return ret_ref;
14638 }
14639
14640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14641         LDKQueryShortChannelIds orig_conv;
14642         orig_conv.inner = (void*)(orig & (~1));
14643         orig_conv.is_owned = false;
14644         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
14645         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14646         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14647         long ret_ref = (long)ret_var.inner;
14648         if (ret_var.is_owned) {
14649                 ret_ref |= 1;
14650         }
14651         return ret_ref;
14652 }
14653
14654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14655         LDKReplyShortChannelIdsEnd this_ptr_conv;
14656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14657         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14658         ReplyShortChannelIdsEnd_free(this_ptr_conv);
14659 }
14660
14661 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14662         LDKReplyShortChannelIdsEnd this_ptr_conv;
14663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14664         this_ptr_conv.is_owned = false;
14665         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14666         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
14667         return ret_arr;
14668 }
14669
14670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14671         LDKReplyShortChannelIdsEnd this_ptr_conv;
14672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14673         this_ptr_conv.is_owned = false;
14674         LDKThirtyTwoBytes val_ref;
14675         CHECK((*env)->GetArrayLength(env, val) == 32);
14676         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14677         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
14678 }
14679
14680 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
14681         LDKReplyShortChannelIdsEnd this_ptr_conv;
14682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14683         this_ptr_conv.is_owned = false;
14684         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
14685         return ret_val;
14686 }
14687
14688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
14689         LDKReplyShortChannelIdsEnd this_ptr_conv;
14690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14691         this_ptr_conv.is_owned = false;
14692         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
14693 }
14694
14695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
14696         LDKThirtyTwoBytes chain_hash_arg_ref;
14697         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
14698         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
14699         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
14700         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14701         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14702         long ret_ref = (long)ret_var.inner;
14703         if (ret_var.is_owned) {
14704                 ret_ref |= 1;
14705         }
14706         return ret_ref;
14707 }
14708
14709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14710         LDKReplyShortChannelIdsEnd orig_conv;
14711         orig_conv.inner = (void*)(orig & (~1));
14712         orig_conv.is_owned = false;
14713         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
14714         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14715         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14716         long ret_ref = (long)ret_var.inner;
14717         if (ret_var.is_owned) {
14718                 ret_ref |= 1;
14719         }
14720         return ret_ref;
14721 }
14722
14723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14724         LDKGossipTimestampFilter this_ptr_conv;
14725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14726         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14727         GossipTimestampFilter_free(this_ptr_conv);
14728 }
14729
14730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14731         LDKGossipTimestampFilter this_ptr_conv;
14732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14733         this_ptr_conv.is_owned = false;
14734         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14735         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
14736         return ret_arr;
14737 }
14738
14739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14740         LDKGossipTimestampFilter this_ptr_conv;
14741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14742         this_ptr_conv.is_owned = false;
14743         LDKThirtyTwoBytes val_ref;
14744         CHECK((*env)->GetArrayLength(env, val) == 32);
14745         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14746         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
14747 }
14748
14749 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
14750         LDKGossipTimestampFilter this_ptr_conv;
14751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14752         this_ptr_conv.is_owned = false;
14753         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
14754         return ret_val;
14755 }
14756
14757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14758         LDKGossipTimestampFilter this_ptr_conv;
14759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14760         this_ptr_conv.is_owned = false;
14761         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
14762 }
14763
14764 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
14765         LDKGossipTimestampFilter this_ptr_conv;
14766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14767         this_ptr_conv.is_owned = false;
14768         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
14769         return ret_val;
14770 }
14771
14772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14773         LDKGossipTimestampFilter this_ptr_conv;
14774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14775         this_ptr_conv.is_owned = false;
14776         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
14777 }
14778
14779 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) {
14780         LDKThirtyTwoBytes chain_hash_arg_ref;
14781         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
14782         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
14783         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
14784         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14785         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14786         long ret_ref = (long)ret_var.inner;
14787         if (ret_var.is_owned) {
14788                 ret_ref |= 1;
14789         }
14790         return ret_ref;
14791 }
14792
14793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14794         LDKGossipTimestampFilter orig_conv;
14795         orig_conv.inner = (void*)(orig & (~1));
14796         orig_conv.is_owned = false;
14797         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
14798         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14799         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14800         long ret_ref = (long)ret_var.inner;
14801         if (ret_var.is_owned) {
14802                 ret_ref |= 1;
14803         }
14804         return ret_ref;
14805 }
14806
14807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14808         if ((this_ptr & 1) != 0) return;
14809         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
14810         FREE((void*)this_ptr);
14811         ErrorAction_free(this_ptr_conv);
14812 }
14813
14814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14815         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
14816         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
14817         *ret_copy = ErrorAction_clone(orig_conv);
14818         long ret_ref = (long)ret_copy;
14819         return ret_ref;
14820 }
14821
14822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14823         LDKLightningError this_ptr_conv;
14824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14825         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14826         LightningError_free(this_ptr_conv);
14827 }
14828
14829 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
14830         LDKLightningError this_ptr_conv;
14831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14832         this_ptr_conv.is_owned = false;
14833         LDKStr _str = LightningError_get_err(&this_ptr_conv);
14834         jstring _conv = str_ref_to_java(env, _str.chars, _str.len);
14835         return _conv;
14836 }
14837
14838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14839         LDKLightningError this_ptr_conv;
14840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14841         this_ptr_conv.is_owned = false;
14842         LDKCVec_u8Z val_ref;
14843         val_ref.datalen = (*env)->GetArrayLength(env, val);
14844         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14845         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
14846         LightningError_set_err(&this_ptr_conv, val_ref);
14847 }
14848
14849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
14850         LDKLightningError this_ptr_conv;
14851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14852         this_ptr_conv.is_owned = false;
14853         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
14854         *ret_copy = LightningError_get_action(&this_ptr_conv);
14855         long ret_ref = (long)ret_copy;
14856         return ret_ref;
14857 }
14858
14859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14860         LDKLightningError this_ptr_conv;
14861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14862         this_ptr_conv.is_owned = false;
14863         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
14864         FREE((void*)val);
14865         LightningError_set_action(&this_ptr_conv, val_conv);
14866 }
14867
14868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, int8_tArray err_arg, int64_t action_arg) {
14869         LDKCVec_u8Z err_arg_ref;
14870         err_arg_ref.datalen = (*env)->GetArrayLength(env, err_arg);
14871         err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14872         (*env)->GetByteArrayRegion(env, err_arg, 0, err_arg_ref.datalen, err_arg_ref.data);
14873         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
14874         FREE((void*)action_arg);
14875         LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
14876         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14877         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14878         long ret_ref = (long)ret_var.inner;
14879         if (ret_var.is_owned) {
14880                 ret_ref |= 1;
14881         }
14882         return ret_ref;
14883 }
14884
14885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14886         LDKLightningError orig_conv;
14887         orig_conv.inner = (void*)(orig & (~1));
14888         orig_conv.is_owned = false;
14889         LDKLightningError ret_var = LightningError_clone(&orig_conv);
14890         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14891         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14892         long ret_ref = (long)ret_var.inner;
14893         if (ret_var.is_owned) {
14894                 ret_ref |= 1;
14895         }
14896         return ret_ref;
14897 }
14898
14899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14900         LDKCommitmentUpdate this_ptr_conv;
14901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14902         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14903         CommitmentUpdate_free(this_ptr_conv);
14904 }
14905
14906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
14907         LDKCommitmentUpdate this_ptr_conv;
14908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14909         this_ptr_conv.is_owned = false;
14910         LDKCVec_UpdateAddHTLCZ val_constr;
14911         val_constr.datalen = (*env)->GetArrayLength(env, val);
14912         if (val_constr.datalen > 0)
14913                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
14914         else
14915                 val_constr.data = NULL;
14916         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
14917         for (size_t p = 0; p < val_constr.datalen; p++) {
14918                 int64_t arr_conv_15 = val_vals[p];
14919                 LDKUpdateAddHTLC arr_conv_15_conv;
14920                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
14921                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
14922                 arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
14923                 val_constr.data[p] = arr_conv_15_conv;
14924         }
14925         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
14926         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
14927 }
14928
14929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
14930         LDKCommitmentUpdate this_ptr_conv;
14931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14932         this_ptr_conv.is_owned = false;
14933         LDKCVec_UpdateFulfillHTLCZ val_constr;
14934         val_constr.datalen = (*env)->GetArrayLength(env, val);
14935         if (val_constr.datalen > 0)
14936                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
14937         else
14938                 val_constr.data = NULL;
14939         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
14940         for (size_t t = 0; t < val_constr.datalen; t++) {
14941                 int64_t arr_conv_19 = val_vals[t];
14942                 LDKUpdateFulfillHTLC arr_conv_19_conv;
14943                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
14944                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
14945                 arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
14946                 val_constr.data[t] = arr_conv_19_conv;
14947         }
14948         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
14949         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
14950 }
14951
14952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
14953         LDKCommitmentUpdate this_ptr_conv;
14954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14955         this_ptr_conv.is_owned = false;
14956         LDKCVec_UpdateFailHTLCZ val_constr;
14957         val_constr.datalen = (*env)->GetArrayLength(env, val);
14958         if (val_constr.datalen > 0)
14959                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
14960         else
14961                 val_constr.data = NULL;
14962         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
14963         for (size_t q = 0; q < val_constr.datalen; q++) {
14964                 int64_t arr_conv_16 = val_vals[q];
14965                 LDKUpdateFailHTLC arr_conv_16_conv;
14966                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
14967                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
14968                 arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
14969                 val_constr.data[q] = arr_conv_16_conv;
14970         }
14971         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
14972         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
14973 }
14974
14975 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) {
14976         LDKCommitmentUpdate this_ptr_conv;
14977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14978         this_ptr_conv.is_owned = false;
14979         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
14980         val_constr.datalen = (*env)->GetArrayLength(env, val);
14981         if (val_constr.datalen > 0)
14982                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
14983         else
14984                 val_constr.data = NULL;
14985         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
14986         for (size_t z = 0; z < val_constr.datalen; z++) {
14987                 int64_t arr_conv_25 = val_vals[z];
14988                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
14989                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
14990                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
14991                 arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
14992                 val_constr.data[z] = arr_conv_25_conv;
14993         }
14994         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
14995         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
14996 }
14997
14998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
14999         LDKCommitmentUpdate this_ptr_conv;
15000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15001         this_ptr_conv.is_owned = false;
15002         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
15003         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15004         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15005         long ret_ref = (long)ret_var.inner;
15006         if (ret_var.is_owned) {
15007                 ret_ref |= 1;
15008         }
15009         return ret_ref;
15010 }
15011
15012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15013         LDKCommitmentUpdate this_ptr_conv;
15014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15015         this_ptr_conv.is_owned = false;
15016         LDKUpdateFee val_conv;
15017         val_conv.inner = (void*)(val & (~1));
15018         val_conv.is_owned = (val & 1) || (val == 0);
15019         val_conv = UpdateFee_clone(&val_conv);
15020         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
15021 }
15022
15023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
15024         LDKCommitmentUpdate this_ptr_conv;
15025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15026         this_ptr_conv.is_owned = false;
15027         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
15028         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15029         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15030         long ret_ref = (long)ret_var.inner;
15031         if (ret_var.is_owned) {
15032                 ret_ref |= 1;
15033         }
15034         return ret_ref;
15035 }
15036
15037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15038         LDKCommitmentUpdate this_ptr_conv;
15039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15040         this_ptr_conv.is_owned = false;
15041         LDKCommitmentSigned val_conv;
15042         val_conv.inner = (void*)(val & (~1));
15043         val_conv.is_owned = (val & 1) || (val == 0);
15044         val_conv = CommitmentSigned_clone(&val_conv);
15045         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
15046 }
15047
15048 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) {
15049         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
15050         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
15051         if (update_add_htlcs_arg_constr.datalen > 0)
15052                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
15053         else
15054                 update_add_htlcs_arg_constr.data = NULL;
15055         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
15056         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
15057                 int64_t arr_conv_15 = update_add_htlcs_arg_vals[p];
15058                 LDKUpdateAddHTLC arr_conv_15_conv;
15059                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
15060                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
15061                 arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
15062                 update_add_htlcs_arg_constr.data[p] = arr_conv_15_conv;
15063         }
15064         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
15065         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
15066         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
15067         if (update_fulfill_htlcs_arg_constr.datalen > 0)
15068                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
15069         else
15070                 update_fulfill_htlcs_arg_constr.data = NULL;
15071         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
15072         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
15073                 int64_t arr_conv_19 = update_fulfill_htlcs_arg_vals[t];
15074                 LDKUpdateFulfillHTLC arr_conv_19_conv;
15075                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
15076                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
15077                 arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
15078                 update_fulfill_htlcs_arg_constr.data[t] = arr_conv_19_conv;
15079         }
15080         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
15081         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
15082         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
15083         if (update_fail_htlcs_arg_constr.datalen > 0)
15084                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
15085         else
15086                 update_fail_htlcs_arg_constr.data = NULL;
15087         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
15088         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
15089                 int64_t arr_conv_16 = update_fail_htlcs_arg_vals[q];
15090                 LDKUpdateFailHTLC arr_conv_16_conv;
15091                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
15092                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
15093                 arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
15094                 update_fail_htlcs_arg_constr.data[q] = arr_conv_16_conv;
15095         }
15096         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
15097         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
15098         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
15099         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
15100                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
15101         else
15102                 update_fail_malformed_htlcs_arg_constr.data = NULL;
15103         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
15104         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
15105                 int64_t arr_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
15106                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
15107                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
15108                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
15109                 arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
15110                 update_fail_malformed_htlcs_arg_constr.data[z] = arr_conv_25_conv;
15111         }
15112         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
15113         LDKUpdateFee update_fee_arg_conv;
15114         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
15115         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
15116         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
15117         LDKCommitmentSigned commitment_signed_arg_conv;
15118         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
15119         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
15120         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
15121         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);
15122         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15123         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15124         long ret_ref = (long)ret_var.inner;
15125         if (ret_var.is_owned) {
15126                 ret_ref |= 1;
15127         }
15128         return ret_ref;
15129 }
15130
15131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15132         LDKCommitmentUpdate orig_conv;
15133         orig_conv.inner = (void*)(orig & (~1));
15134         orig_conv.is_owned = false;
15135         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
15136         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15137         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15138         long ret_ref = (long)ret_var.inner;
15139         if (ret_var.is_owned) {
15140                 ret_ref |= 1;
15141         }
15142         return ret_ref;
15143 }
15144
15145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15146         if ((this_ptr & 1) != 0) return;
15147         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
15148         FREE((void*)this_ptr);
15149         HTLCFailChannelUpdate_free(this_ptr_conv);
15150 }
15151
15152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15153         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
15154         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
15155         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
15156         long ret_ref = (long)ret_copy;
15157         return ret_ref;
15158 }
15159
15160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15161         if ((this_ptr & 1) != 0) return;
15162         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
15163         FREE((void*)this_ptr);
15164         ChannelMessageHandler_free(this_ptr_conv);
15165 }
15166
15167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15168         if ((this_ptr & 1) != 0) return;
15169         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
15170         FREE((void*)this_ptr);
15171         RoutingMessageHandler_free(this_ptr_conv);
15172 }
15173
15174 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
15175         LDKAcceptChannel obj_conv;
15176         obj_conv.inner = (void*)(obj & (~1));
15177         obj_conv.is_owned = false;
15178         LDKCVec_u8Z arg_var = AcceptChannel_write(&obj_conv);
15179         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15180         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15181         CVec_u8Z_free(arg_var);
15182         return arg_arr;
15183 }
15184
15185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15186         LDKu8slice ser_ref;
15187         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15188         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15189         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
15190         *ret_conv = AcceptChannel_read(ser_ref);
15191         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15192         return (long)ret_conv;
15193 }
15194
15195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
15196         LDKAnnouncementSignatures obj_conv;
15197         obj_conv.inner = (void*)(obj & (~1));
15198         obj_conv.is_owned = false;
15199         LDKCVec_u8Z arg_var = AnnouncementSignatures_write(&obj_conv);
15200         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15201         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15202         CVec_u8Z_free(arg_var);
15203         return arg_arr;
15204 }
15205
15206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15207         LDKu8slice ser_ref;
15208         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15209         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15210         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
15211         *ret_conv = AnnouncementSignatures_read(ser_ref);
15212         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15213         return (long)ret_conv;
15214 }
15215
15216 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
15217         LDKChannelReestablish obj_conv;
15218         obj_conv.inner = (void*)(obj & (~1));
15219         obj_conv.is_owned = false;
15220         LDKCVec_u8Z arg_var = ChannelReestablish_write(&obj_conv);
15221         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15222         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15223         CVec_u8Z_free(arg_var);
15224         return arg_arr;
15225 }
15226
15227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15228         LDKu8slice ser_ref;
15229         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15230         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15231         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
15232         *ret_conv = ChannelReestablish_read(ser_ref);
15233         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15234         return (long)ret_conv;
15235 }
15236
15237 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
15238         LDKClosingSigned obj_conv;
15239         obj_conv.inner = (void*)(obj & (~1));
15240         obj_conv.is_owned = false;
15241         LDKCVec_u8Z arg_var = ClosingSigned_write(&obj_conv);
15242         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15243         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15244         CVec_u8Z_free(arg_var);
15245         return arg_arr;
15246 }
15247
15248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15249         LDKu8slice ser_ref;
15250         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15251         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15252         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
15253         *ret_conv = ClosingSigned_read(ser_ref);
15254         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15255         return (long)ret_conv;
15256 }
15257
15258 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
15259         LDKCommitmentSigned obj_conv;
15260         obj_conv.inner = (void*)(obj & (~1));
15261         obj_conv.is_owned = false;
15262         LDKCVec_u8Z arg_var = CommitmentSigned_write(&obj_conv);
15263         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15264         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15265         CVec_u8Z_free(arg_var);
15266         return arg_arr;
15267 }
15268
15269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15270         LDKu8slice ser_ref;
15271         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15272         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15273         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
15274         *ret_conv = CommitmentSigned_read(ser_ref);
15275         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15276         return (long)ret_conv;
15277 }
15278
15279 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
15280         LDKFundingCreated obj_conv;
15281         obj_conv.inner = (void*)(obj & (~1));
15282         obj_conv.is_owned = false;
15283         LDKCVec_u8Z arg_var = FundingCreated_write(&obj_conv);
15284         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15285         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15286         CVec_u8Z_free(arg_var);
15287         return arg_arr;
15288 }
15289
15290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15291         LDKu8slice ser_ref;
15292         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15293         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15294         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
15295         *ret_conv = FundingCreated_read(ser_ref);
15296         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15297         return (long)ret_conv;
15298 }
15299
15300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
15301         LDKFundingSigned obj_conv;
15302         obj_conv.inner = (void*)(obj & (~1));
15303         obj_conv.is_owned = false;
15304         LDKCVec_u8Z arg_var = FundingSigned_write(&obj_conv);
15305         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15306         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15307         CVec_u8Z_free(arg_var);
15308         return arg_arr;
15309 }
15310
15311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15312         LDKu8slice ser_ref;
15313         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15314         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15315         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
15316         *ret_conv = FundingSigned_read(ser_ref);
15317         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15318         return (long)ret_conv;
15319 }
15320
15321 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
15322         LDKFundingLocked obj_conv;
15323         obj_conv.inner = (void*)(obj & (~1));
15324         obj_conv.is_owned = false;
15325         LDKCVec_u8Z arg_var = FundingLocked_write(&obj_conv);
15326         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15327         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15328         CVec_u8Z_free(arg_var);
15329         return arg_arr;
15330 }
15331
15332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15333         LDKu8slice ser_ref;
15334         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15335         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15336         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
15337         *ret_conv = FundingLocked_read(ser_ref);
15338         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15339         return (long)ret_conv;
15340 }
15341
15342 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
15343         LDKInit obj_conv;
15344         obj_conv.inner = (void*)(obj & (~1));
15345         obj_conv.is_owned = false;
15346         LDKCVec_u8Z arg_var = Init_write(&obj_conv);
15347         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15348         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15349         CVec_u8Z_free(arg_var);
15350         return arg_arr;
15351 }
15352
15353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15354         LDKu8slice ser_ref;
15355         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15356         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15357         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
15358         *ret_conv = Init_read(ser_ref);
15359         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15360         return (long)ret_conv;
15361 }
15362
15363 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
15364         LDKOpenChannel obj_conv;
15365         obj_conv.inner = (void*)(obj & (~1));
15366         obj_conv.is_owned = false;
15367         LDKCVec_u8Z arg_var = OpenChannel_write(&obj_conv);
15368         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15369         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15370         CVec_u8Z_free(arg_var);
15371         return arg_arr;
15372 }
15373
15374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15375         LDKu8slice ser_ref;
15376         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15377         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15378         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
15379         *ret_conv = OpenChannel_read(ser_ref);
15380         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15381         return (long)ret_conv;
15382 }
15383
15384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
15385         LDKRevokeAndACK obj_conv;
15386         obj_conv.inner = (void*)(obj & (~1));
15387         obj_conv.is_owned = false;
15388         LDKCVec_u8Z arg_var = RevokeAndACK_write(&obj_conv);
15389         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15390         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15391         CVec_u8Z_free(arg_var);
15392         return arg_arr;
15393 }
15394
15395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15396         LDKu8slice ser_ref;
15397         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15398         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15399         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
15400         *ret_conv = RevokeAndACK_read(ser_ref);
15401         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15402         return (long)ret_conv;
15403 }
15404
15405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
15406         LDKShutdown obj_conv;
15407         obj_conv.inner = (void*)(obj & (~1));
15408         obj_conv.is_owned = false;
15409         LDKCVec_u8Z arg_var = Shutdown_write(&obj_conv);
15410         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15411         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15412         CVec_u8Z_free(arg_var);
15413         return arg_arr;
15414 }
15415
15416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15417         LDKu8slice ser_ref;
15418         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15419         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15420         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
15421         *ret_conv = Shutdown_read(ser_ref);
15422         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15423         return (long)ret_conv;
15424 }
15425
15426 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
15427         LDKUpdateFailHTLC obj_conv;
15428         obj_conv.inner = (void*)(obj & (~1));
15429         obj_conv.is_owned = false;
15430         LDKCVec_u8Z arg_var = UpdateFailHTLC_write(&obj_conv);
15431         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15432         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15433         CVec_u8Z_free(arg_var);
15434         return arg_arr;
15435 }
15436
15437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15438         LDKu8slice ser_ref;
15439         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15440         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15441         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
15442         *ret_conv = UpdateFailHTLC_read(ser_ref);
15443         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15444         return (long)ret_conv;
15445 }
15446
15447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
15448         LDKUpdateFailMalformedHTLC obj_conv;
15449         obj_conv.inner = (void*)(obj & (~1));
15450         obj_conv.is_owned = false;
15451         LDKCVec_u8Z arg_var = UpdateFailMalformedHTLC_write(&obj_conv);
15452         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15453         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15454         CVec_u8Z_free(arg_var);
15455         return arg_arr;
15456 }
15457
15458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15459         LDKu8slice ser_ref;
15460         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15461         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15462         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
15463         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
15464         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15465         return (long)ret_conv;
15466 }
15467
15468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
15469         LDKUpdateFee obj_conv;
15470         obj_conv.inner = (void*)(obj & (~1));
15471         obj_conv.is_owned = false;
15472         LDKCVec_u8Z arg_var = UpdateFee_write(&obj_conv);
15473         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15474         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15475         CVec_u8Z_free(arg_var);
15476         return arg_arr;
15477 }
15478
15479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15480         LDKu8slice ser_ref;
15481         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15482         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15483         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
15484         *ret_conv = UpdateFee_read(ser_ref);
15485         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15486         return (long)ret_conv;
15487 }
15488
15489 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
15490         LDKUpdateFulfillHTLC obj_conv;
15491         obj_conv.inner = (void*)(obj & (~1));
15492         obj_conv.is_owned = false;
15493         LDKCVec_u8Z arg_var = UpdateFulfillHTLC_write(&obj_conv);
15494         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15495         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15496         CVec_u8Z_free(arg_var);
15497         return arg_arr;
15498 }
15499
15500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15501         LDKu8slice ser_ref;
15502         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15503         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15504         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
15505         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
15506         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15507         return (long)ret_conv;
15508 }
15509
15510 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
15511         LDKUpdateAddHTLC obj_conv;
15512         obj_conv.inner = (void*)(obj & (~1));
15513         obj_conv.is_owned = false;
15514         LDKCVec_u8Z arg_var = UpdateAddHTLC_write(&obj_conv);
15515         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15516         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15517         CVec_u8Z_free(arg_var);
15518         return arg_arr;
15519 }
15520
15521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15522         LDKu8slice ser_ref;
15523         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15524         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15525         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
15526         *ret_conv = UpdateAddHTLC_read(ser_ref);
15527         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15528         return (long)ret_conv;
15529 }
15530
15531 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
15532         LDKPing obj_conv;
15533         obj_conv.inner = (void*)(obj & (~1));
15534         obj_conv.is_owned = false;
15535         LDKCVec_u8Z arg_var = Ping_write(&obj_conv);
15536         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15537         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15538         CVec_u8Z_free(arg_var);
15539         return arg_arr;
15540 }
15541
15542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15543         LDKu8slice ser_ref;
15544         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15545         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15546         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
15547         *ret_conv = Ping_read(ser_ref);
15548         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15549         return (long)ret_conv;
15550 }
15551
15552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
15553         LDKPong obj_conv;
15554         obj_conv.inner = (void*)(obj & (~1));
15555         obj_conv.is_owned = false;
15556         LDKCVec_u8Z arg_var = Pong_write(&obj_conv);
15557         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15558         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15559         CVec_u8Z_free(arg_var);
15560         return arg_arr;
15561 }
15562
15563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15564         LDKu8slice ser_ref;
15565         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15566         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15567         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
15568         *ret_conv = Pong_read(ser_ref);
15569         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15570         return (long)ret_conv;
15571 }
15572
15573 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
15574         LDKUnsignedChannelAnnouncement obj_conv;
15575         obj_conv.inner = (void*)(obj & (~1));
15576         obj_conv.is_owned = false;
15577         LDKCVec_u8Z arg_var = UnsignedChannelAnnouncement_write(&obj_conv);
15578         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15579         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15580         CVec_u8Z_free(arg_var);
15581         return arg_arr;
15582 }
15583
15584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15585         LDKu8slice ser_ref;
15586         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15587         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15588         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
15589         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
15590         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15591         return (long)ret_conv;
15592 }
15593
15594 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
15595         LDKChannelAnnouncement obj_conv;
15596         obj_conv.inner = (void*)(obj & (~1));
15597         obj_conv.is_owned = false;
15598         LDKCVec_u8Z arg_var = ChannelAnnouncement_write(&obj_conv);
15599         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15600         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15601         CVec_u8Z_free(arg_var);
15602         return arg_arr;
15603 }
15604
15605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15606         LDKu8slice ser_ref;
15607         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15608         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15609         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
15610         *ret_conv = ChannelAnnouncement_read(ser_ref);
15611         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15612         return (long)ret_conv;
15613 }
15614
15615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
15616         LDKUnsignedChannelUpdate obj_conv;
15617         obj_conv.inner = (void*)(obj & (~1));
15618         obj_conv.is_owned = false;
15619         LDKCVec_u8Z arg_var = UnsignedChannelUpdate_write(&obj_conv);
15620         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15621         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15622         CVec_u8Z_free(arg_var);
15623         return arg_arr;
15624 }
15625
15626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15627         LDKu8slice ser_ref;
15628         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15629         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15630         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
15631         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
15632         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15633         return (long)ret_conv;
15634 }
15635
15636 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
15637         LDKChannelUpdate obj_conv;
15638         obj_conv.inner = (void*)(obj & (~1));
15639         obj_conv.is_owned = false;
15640         LDKCVec_u8Z arg_var = ChannelUpdate_write(&obj_conv);
15641         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15642         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15643         CVec_u8Z_free(arg_var);
15644         return arg_arr;
15645 }
15646
15647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15648         LDKu8slice ser_ref;
15649         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15650         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15651         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15652         *ret_conv = ChannelUpdate_read(ser_ref);
15653         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15654         return (long)ret_conv;
15655 }
15656
15657 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
15658         LDKErrorMessage obj_conv;
15659         obj_conv.inner = (void*)(obj & (~1));
15660         obj_conv.is_owned = false;
15661         LDKCVec_u8Z arg_var = ErrorMessage_write(&obj_conv);
15662         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15663         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15664         CVec_u8Z_free(arg_var);
15665         return arg_arr;
15666 }
15667
15668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15669         LDKu8slice ser_ref;
15670         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15671         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15672         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15673         *ret_conv = ErrorMessage_read(ser_ref);
15674         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15675         return (long)ret_conv;
15676 }
15677
15678 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
15679         LDKUnsignedNodeAnnouncement obj_conv;
15680         obj_conv.inner = (void*)(obj & (~1));
15681         obj_conv.is_owned = false;
15682         LDKCVec_u8Z arg_var = UnsignedNodeAnnouncement_write(&obj_conv);
15683         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15684         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15685         CVec_u8Z_free(arg_var);
15686         return arg_arr;
15687 }
15688
15689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15690         LDKu8slice ser_ref;
15691         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15692         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15693         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15694         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
15695         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15696         return (long)ret_conv;
15697 }
15698
15699 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
15700         LDKNodeAnnouncement obj_conv;
15701         obj_conv.inner = (void*)(obj & (~1));
15702         obj_conv.is_owned = false;
15703         LDKCVec_u8Z arg_var = NodeAnnouncement_write(&obj_conv);
15704         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15705         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15706         CVec_u8Z_free(arg_var);
15707         return arg_arr;
15708 }
15709
15710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15711         LDKu8slice ser_ref;
15712         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15713         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15714         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
15715         *ret_conv = NodeAnnouncement_read(ser_ref);
15716         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15717         return (long)ret_conv;
15718 }
15719
15720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15721         LDKu8slice ser_ref;
15722         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15723         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15724         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
15725         *ret_conv = QueryShortChannelIds_read(ser_ref);
15726         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15727         return (long)ret_conv;
15728 }
15729
15730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
15731         LDKQueryShortChannelIds obj_conv;
15732         obj_conv.inner = (void*)(obj & (~1));
15733         obj_conv.is_owned = false;
15734         LDKCVec_u8Z arg_var = QueryShortChannelIds_write(&obj_conv);
15735         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15736         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15737         CVec_u8Z_free(arg_var);
15738         return arg_arr;
15739 }
15740
15741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15742         LDKu8slice ser_ref;
15743         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15744         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15745         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
15746         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
15747         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15748         return (long)ret_conv;
15749 }
15750
15751 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
15752         LDKReplyShortChannelIdsEnd obj_conv;
15753         obj_conv.inner = (void*)(obj & (~1));
15754         obj_conv.is_owned = false;
15755         LDKCVec_u8Z arg_var = ReplyShortChannelIdsEnd_write(&obj_conv);
15756         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15757         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15758         CVec_u8Z_free(arg_var);
15759         return arg_arr;
15760 }
15761
15762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15763         LDKu8slice ser_ref;
15764         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15765         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15766         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
15767         *ret_conv = QueryChannelRange_read(ser_ref);
15768         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15769         return (long)ret_conv;
15770 }
15771
15772 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
15773         LDKQueryChannelRange obj_conv;
15774         obj_conv.inner = (void*)(obj & (~1));
15775         obj_conv.is_owned = false;
15776         LDKCVec_u8Z arg_var = QueryChannelRange_write(&obj_conv);
15777         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15778         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15779         CVec_u8Z_free(arg_var);
15780         return arg_arr;
15781 }
15782
15783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15784         LDKu8slice ser_ref;
15785         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15786         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15787         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
15788         *ret_conv = ReplyChannelRange_read(ser_ref);
15789         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15790         return (long)ret_conv;
15791 }
15792
15793 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
15794         LDKReplyChannelRange obj_conv;
15795         obj_conv.inner = (void*)(obj & (~1));
15796         obj_conv.is_owned = false;
15797         LDKCVec_u8Z arg_var = ReplyChannelRange_write(&obj_conv);
15798         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15799         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15800         CVec_u8Z_free(arg_var);
15801         return arg_arr;
15802 }
15803
15804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15805         LDKu8slice ser_ref;
15806         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15807         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15808         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
15809         *ret_conv = GossipTimestampFilter_read(ser_ref);
15810         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15811         return (long)ret_conv;
15812 }
15813
15814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
15815         LDKGossipTimestampFilter obj_conv;
15816         obj_conv.inner = (void*)(obj & (~1));
15817         obj_conv.is_owned = false;
15818         LDKCVec_u8Z arg_var = GossipTimestampFilter_write(&obj_conv);
15819         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
15820         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
15821         CVec_u8Z_free(arg_var);
15822         return arg_arr;
15823 }
15824
15825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15826         LDKMessageHandler this_ptr_conv;
15827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15828         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15829         MessageHandler_free(this_ptr_conv);
15830 }
15831
15832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
15833         LDKMessageHandler this_ptr_conv;
15834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15835         this_ptr_conv.is_owned = false;
15836         long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
15837         return ret_ret;
15838 }
15839
15840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15841         LDKMessageHandler this_ptr_conv;
15842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15843         this_ptr_conv.is_owned = false;
15844         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
15845         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
15846                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15847                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
15848         }
15849         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
15850 }
15851
15852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
15853         LDKMessageHandler this_ptr_conv;
15854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15855         this_ptr_conv.is_owned = false;
15856         long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
15857         return ret_ret;
15858 }
15859
15860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15861         LDKMessageHandler this_ptr_conv;
15862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15863         this_ptr_conv.is_owned = false;
15864         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
15865         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
15866                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15867                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
15868         }
15869         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
15870 }
15871
15872 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) {
15873         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
15874         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
15875                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15876                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
15877         }
15878         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
15879         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
15880                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15881                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
15882         }
15883         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
15884         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15885         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15886         long ret_ref = (long)ret_var.inner;
15887         if (ret_var.is_owned) {
15888                 ret_ref |= 1;
15889         }
15890         return ret_ref;
15891 }
15892
15893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15894         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig;
15895         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
15896         *ret = SocketDescriptor_clone(orig_conv);
15897         return (long)ret;
15898 }
15899
15900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15901         if ((this_ptr & 1) != 0) return;
15902         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
15903         FREE((void*)this_ptr);
15904         SocketDescriptor_free(this_ptr_conv);
15905 }
15906
15907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15908         LDKPeerHandleError this_ptr_conv;
15909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15910         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15911         PeerHandleError_free(this_ptr_conv);
15912 }
15913
15914 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
15915         LDKPeerHandleError this_ptr_conv;
15916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15917         this_ptr_conv.is_owned = false;
15918         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
15919         return ret_val;
15920 }
15921
15922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15923         LDKPeerHandleError this_ptr_conv;
15924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15925         this_ptr_conv.is_owned = false;
15926         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
15927 }
15928
15929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
15930         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
15931         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15932         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15933         long ret_ref = (long)ret_var.inner;
15934         if (ret_var.is_owned) {
15935                 ret_ref |= 1;
15936         }
15937         return ret_ref;
15938 }
15939
15940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15941         LDKPeerHandleError orig_conv;
15942         orig_conv.inner = (void*)(orig & (~1));
15943         orig_conv.is_owned = false;
15944         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
15945         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15946         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15947         long ret_ref = (long)ret_var.inner;
15948         if (ret_var.is_owned) {
15949                 ret_ref |= 1;
15950         }
15951         return ret_ref;
15952 }
15953
15954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15955         LDKPeerManager this_ptr_conv;
15956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15957         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15958         PeerManager_free(this_ptr_conv);
15959 }
15960
15961 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) {
15962         LDKMessageHandler message_handler_conv;
15963         message_handler_conv.inner = (void*)(message_handler & (~1));
15964         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
15965         // Warning: we need a move here but no clone is available for LDKMessageHandler
15966         LDKSecretKey our_node_secret_ref;
15967         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
15968         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
15969         unsigned char ephemeral_random_data_arr[32];
15970         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
15971         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
15972         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
15973         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15974         if (logger_conv.free == LDKLogger_JCalls_free) {
15975                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15976                 LDKLogger_JCalls_clone(logger_conv.this_arg);
15977         }
15978         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
15979         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15980         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15981         long ret_ref = (long)ret_var.inner;
15982         if (ret_var.is_owned) {
15983                 ret_ref |= 1;
15984         }
15985         return ret_ref;
15986 }
15987
15988 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
15989         LDKPeerManager this_arg_conv;
15990         this_arg_conv.inner = (void*)(this_arg & (~1));
15991         this_arg_conv.is_owned = false;
15992         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
15993         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
15994         ;
15995         for (size_t i = 0; i < ret_var.datalen; i++) {
15996                 int8_tArray arr_conv_8_arr = (*env)->NewByteArray(env, 33);
15997                 (*env)->SetByteArrayRegion(env, arr_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
15998                 (*env)->SetObjectArrayElement(env, ret_arr, i, arr_conv_8_arr);
15999         }
16000         FREE(ret_var.data);
16001         return ret_arr;
16002 }
16003
16004 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) {
16005         LDKPeerManager this_arg_conv;
16006         this_arg_conv.inner = (void*)(this_arg & (~1));
16007         this_arg_conv.is_owned = false;
16008         LDKPublicKey their_node_id_ref;
16009         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
16010         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
16011         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
16012         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
16013                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16014                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
16015         }
16016         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16017         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
16018         return (long)ret_conv;
16019 }
16020
16021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
16022         LDKPeerManager this_arg_conv;
16023         this_arg_conv.inner = (void*)(this_arg & (~1));
16024         this_arg_conv.is_owned = false;
16025         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
16026         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
16027                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16028                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
16029         }
16030         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16031         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
16032         return (long)ret_conv;
16033 }
16034
16035 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) {
16036         LDKPeerManager this_arg_conv;
16037         this_arg_conv.inner = (void*)(this_arg & (~1));
16038         this_arg_conv.is_owned = false;
16039         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
16040         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16041         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
16042         return (long)ret_conv;
16043 }
16044
16045 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) {
16046         LDKPeerManager this_arg_conv;
16047         this_arg_conv.inner = (void*)(this_arg & (~1));
16048         this_arg_conv.is_owned = false;
16049         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor;
16050         LDKu8slice data_ref;
16051         data_ref.datalen = (*env)->GetArrayLength(env, data);
16052         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
16053         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16054         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
16055         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
16056         return (long)ret_conv;
16057 }
16058
16059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
16060         LDKPeerManager this_arg_conv;
16061         this_arg_conv.inner = (void*)(this_arg & (~1));
16062         this_arg_conv.is_owned = false;
16063         PeerManager_process_events(&this_arg_conv);
16064 }
16065
16066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
16067         LDKPeerManager this_arg_conv;
16068         this_arg_conv.inner = (void*)(this_arg & (~1));
16069         this_arg_conv.is_owned = false;
16070         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
16071         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
16072 }
16073
16074 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) {
16075         LDKPeerManager this_arg_conv;
16076         this_arg_conv.inner = (void*)(this_arg & (~1));
16077         this_arg_conv.is_owned = false;
16078         LDKPublicKey node_id_ref;
16079         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16080         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16081         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
16082 }
16083
16084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occured(JNIEnv *env, jclass clz, int64_t this_arg) {
16085         LDKPeerManager this_arg_conv;
16086         this_arg_conv.inner = (void*)(this_arg & (~1));
16087         this_arg_conv.is_owned = false;
16088         PeerManager_timer_tick_occured(&this_arg_conv);
16089 }
16090
16091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
16092         unsigned char commitment_seed_arr[32];
16093         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
16094         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
16095         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
16096         int8_tArray arg_arr = (*env)->NewByteArray(env, 32);
16097         (*env)->SetByteArrayRegion(env, arg_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
16098         return arg_arr;
16099 }
16100
16101 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) {
16102         LDKPublicKey per_commitment_point_ref;
16103         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
16104         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
16105         unsigned char base_secret_arr[32];
16106         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
16107         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
16108         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
16109         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
16110         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
16111         return (long)ret_conv;
16112 }
16113
16114 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) {
16115         LDKPublicKey per_commitment_point_ref;
16116         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
16117         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
16118         LDKPublicKey base_point_ref;
16119         CHECK((*env)->GetArrayLength(env, base_point) == 33);
16120         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
16121         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
16122         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
16123         return (long)ret_conv;
16124 }
16125
16126 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) {
16127         unsigned char per_commitment_secret_arr[32];
16128         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
16129         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
16130         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
16131         unsigned char countersignatory_revocation_base_secret_arr[32];
16132         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
16133         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
16134         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
16135         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
16136         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
16137         return (long)ret_conv;
16138 }
16139
16140 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) {
16141         LDKPublicKey per_commitment_point_ref;
16142         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
16143         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
16144         LDKPublicKey countersignatory_revocation_base_point_ref;
16145         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
16146         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
16147         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
16148         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
16149         return (long)ret_conv;
16150 }
16151
16152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16153         LDKTxCreationKeys this_ptr_conv;
16154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16155         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
16156         TxCreationKeys_free(this_ptr_conv);
16157 }
16158
16159 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
16160         LDKTxCreationKeys this_ptr_conv;
16161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16162         this_ptr_conv.is_owned = false;
16163         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
16164         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
16165         return arg_arr;
16166 }
16167
16168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16169         LDKTxCreationKeys this_ptr_conv;
16170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16171         this_ptr_conv.is_owned = false;
16172         LDKPublicKey val_ref;
16173         CHECK((*env)->GetArrayLength(env, val) == 33);
16174         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16175         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
16176 }
16177
16178 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
16179         LDKTxCreationKeys this_ptr_conv;
16180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16181         this_ptr_conv.is_owned = false;
16182         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
16183         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
16184         return arg_arr;
16185 }
16186
16187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16188         LDKTxCreationKeys this_ptr_conv;
16189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16190         this_ptr_conv.is_owned = false;
16191         LDKPublicKey val_ref;
16192         CHECK((*env)->GetArrayLength(env, val) == 33);
16193         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16194         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
16195 }
16196
16197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
16198         LDKTxCreationKeys this_ptr_conv;
16199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16200         this_ptr_conv.is_owned = false;
16201         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
16202         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
16203         return arg_arr;
16204 }
16205
16206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16207         LDKTxCreationKeys this_ptr_conv;
16208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16209         this_ptr_conv.is_owned = false;
16210         LDKPublicKey val_ref;
16211         CHECK((*env)->GetArrayLength(env, val) == 33);
16212         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16213         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
16214 }
16215
16216 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
16217         LDKTxCreationKeys this_ptr_conv;
16218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16219         this_ptr_conv.is_owned = false;
16220         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
16221         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
16222         return arg_arr;
16223 }
16224
16225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16226         LDKTxCreationKeys this_ptr_conv;
16227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16228         this_ptr_conv.is_owned = false;
16229         LDKPublicKey val_ref;
16230         CHECK((*env)->GetArrayLength(env, val) == 33);
16231         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16232         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
16233 }
16234
16235 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
16236         LDKTxCreationKeys this_ptr_conv;
16237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16238         this_ptr_conv.is_owned = false;
16239         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
16240         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
16241         return arg_arr;
16242 }
16243
16244 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) {
16245         LDKTxCreationKeys this_ptr_conv;
16246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16247         this_ptr_conv.is_owned = false;
16248         LDKPublicKey val_ref;
16249         CHECK((*env)->GetArrayLength(env, val) == 33);
16250         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16251         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
16252 }
16253
16254 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) {
16255         LDKPublicKey per_commitment_point_arg_ref;
16256         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
16257         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
16258         LDKPublicKey revocation_key_arg_ref;
16259         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
16260         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
16261         LDKPublicKey broadcaster_htlc_key_arg_ref;
16262         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
16263         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
16264         LDKPublicKey countersignatory_htlc_key_arg_ref;
16265         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
16266         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
16267         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
16268         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
16269         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
16270         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);
16271         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16272         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16273         long ret_ref = (long)ret_var.inner;
16274         if (ret_var.is_owned) {
16275                 ret_ref |= 1;
16276         }
16277         return ret_ref;
16278 }
16279
16280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16281         LDKTxCreationKeys orig_conv;
16282         orig_conv.inner = (void*)(orig & (~1));
16283         orig_conv.is_owned = false;
16284         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
16285         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16286         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16287         long ret_ref = (long)ret_var.inner;
16288         if (ret_var.is_owned) {
16289                 ret_ref |= 1;
16290         }
16291         return ret_ref;
16292 }
16293
16294 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
16295         LDKTxCreationKeys obj_conv;
16296         obj_conv.inner = (void*)(obj & (~1));
16297         obj_conv.is_owned = false;
16298         LDKCVec_u8Z arg_var = TxCreationKeys_write(&obj_conv);
16299         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
16300         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
16301         CVec_u8Z_free(arg_var);
16302         return arg_arr;
16303 }
16304
16305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16306         LDKu8slice ser_ref;
16307         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16308         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16309         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16310         *ret_conv = TxCreationKeys_read(ser_ref);
16311         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16312         return (long)ret_conv;
16313 }
16314
16315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16316         LDKChannelPublicKeys this_ptr_conv;
16317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16318         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
16319         ChannelPublicKeys_free(this_ptr_conv);
16320 }
16321
16322 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
16323         LDKChannelPublicKeys this_ptr_conv;
16324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16325         this_ptr_conv.is_owned = false;
16326         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
16327         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
16328         return arg_arr;
16329 }
16330
16331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16332         LDKChannelPublicKeys this_ptr_conv;
16333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16334         this_ptr_conv.is_owned = false;
16335         LDKPublicKey val_ref;
16336         CHECK((*env)->GetArrayLength(env, val) == 33);
16337         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16338         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
16339 }
16340
16341 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16342         LDKChannelPublicKeys this_ptr_conv;
16343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16344         this_ptr_conv.is_owned = false;
16345         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
16346         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
16347         return arg_arr;
16348 }
16349
16350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16351         LDKChannelPublicKeys this_ptr_conv;
16352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16353         this_ptr_conv.is_owned = false;
16354         LDKPublicKey val_ref;
16355         CHECK((*env)->GetArrayLength(env, val) == 33);
16356         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16357         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
16358 }
16359
16360 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
16361         LDKChannelPublicKeys this_ptr_conv;
16362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16363         this_ptr_conv.is_owned = false;
16364         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
16365         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
16366         return arg_arr;
16367 }
16368
16369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16370         LDKChannelPublicKeys this_ptr_conv;
16371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16372         this_ptr_conv.is_owned = false;
16373         LDKPublicKey val_ref;
16374         CHECK((*env)->GetArrayLength(env, val) == 33);
16375         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16376         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
16377 }
16378
16379 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16380         LDKChannelPublicKeys this_ptr_conv;
16381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16382         this_ptr_conv.is_owned = false;
16383         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
16384         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
16385         return arg_arr;
16386 }
16387
16388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16389         LDKChannelPublicKeys this_ptr_conv;
16390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16391         this_ptr_conv.is_owned = false;
16392         LDKPublicKey val_ref;
16393         CHECK((*env)->GetArrayLength(env, val) == 33);
16394         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16395         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
16396 }
16397
16398 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16399         LDKChannelPublicKeys this_ptr_conv;
16400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16401         this_ptr_conv.is_owned = false;
16402         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
16403         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
16404         return arg_arr;
16405 }
16406
16407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16408         LDKChannelPublicKeys this_ptr_conv;
16409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16410         this_ptr_conv.is_owned = false;
16411         LDKPublicKey val_ref;
16412         CHECK((*env)->GetArrayLength(env, val) == 33);
16413         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16414         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
16415 }
16416
16417 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) {
16418         LDKPublicKey funding_pubkey_arg_ref;
16419         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
16420         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
16421         LDKPublicKey revocation_basepoint_arg_ref;
16422         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
16423         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
16424         LDKPublicKey payment_point_arg_ref;
16425         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
16426         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
16427         LDKPublicKey delayed_payment_basepoint_arg_ref;
16428         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
16429         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
16430         LDKPublicKey htlc_basepoint_arg_ref;
16431         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
16432         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
16433         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);
16434         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16435         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16436         long ret_ref = (long)ret_var.inner;
16437         if (ret_var.is_owned) {
16438                 ret_ref |= 1;
16439         }
16440         return ret_ref;
16441 }
16442
16443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16444         LDKChannelPublicKeys orig_conv;
16445         orig_conv.inner = (void*)(orig & (~1));
16446         orig_conv.is_owned = false;
16447         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
16448         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16449         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16450         long ret_ref = (long)ret_var.inner;
16451         if (ret_var.is_owned) {
16452                 ret_ref |= 1;
16453         }
16454         return ret_ref;
16455 }
16456
16457 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
16458         LDKChannelPublicKeys obj_conv;
16459         obj_conv.inner = (void*)(obj & (~1));
16460         obj_conv.is_owned = false;
16461         LDKCVec_u8Z arg_var = ChannelPublicKeys_write(&obj_conv);
16462         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
16463         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
16464         CVec_u8Z_free(arg_var);
16465         return arg_arr;
16466 }
16467
16468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16469         LDKu8slice ser_ref;
16470         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16471         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16472         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16473         *ret_conv = ChannelPublicKeys_read(ser_ref);
16474         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16475         return (long)ret_conv;
16476 }
16477
16478 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) {
16479         LDKPublicKey per_commitment_point_ref;
16480         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
16481         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
16482         LDKPublicKey broadcaster_delayed_payment_base_ref;
16483         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
16484         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
16485         LDKPublicKey broadcaster_htlc_base_ref;
16486         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
16487         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
16488         LDKPublicKey countersignatory_revocation_base_ref;
16489         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
16490         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
16491         LDKPublicKey countersignatory_htlc_base_ref;
16492         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
16493         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
16494         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
16495         *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);
16496         return (long)ret_conv;
16497 }
16498
16499 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) {
16500         LDKPublicKey per_commitment_point_ref;
16501         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
16502         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
16503         LDKChannelPublicKeys broadcaster_keys_conv;
16504         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
16505         broadcaster_keys_conv.is_owned = false;
16506         LDKChannelPublicKeys countersignatory_keys_conv;
16507         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
16508         countersignatory_keys_conv.is_owned = false;
16509         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
16510         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
16511         return (long)ret_conv;
16512 }
16513
16514 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) {
16515         LDKPublicKey revocation_key_ref;
16516         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
16517         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
16518         LDKPublicKey broadcaster_delayed_payment_key_ref;
16519         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
16520         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
16521         LDKCVec_u8Z arg_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
16522         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
16523         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
16524         CVec_u8Z_free(arg_var);
16525         return arg_arr;
16526 }
16527
16528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16529         LDKHTLCOutputInCommitment this_ptr_conv;
16530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16531         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
16532         HTLCOutputInCommitment_free(this_ptr_conv);
16533 }
16534
16535 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
16536         LDKHTLCOutputInCommitment this_ptr_conv;
16537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16538         this_ptr_conv.is_owned = false;
16539         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
16540         return ret_val;
16541 }
16542
16543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16544         LDKHTLCOutputInCommitment this_ptr_conv;
16545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16546         this_ptr_conv.is_owned = false;
16547         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
16548 }
16549
16550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16551         LDKHTLCOutputInCommitment this_ptr_conv;
16552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16553         this_ptr_conv.is_owned = false;
16554         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
16555         return ret_val;
16556 }
16557
16558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16559         LDKHTLCOutputInCommitment this_ptr_conv;
16560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16561         this_ptr_conv.is_owned = false;
16562         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
16563 }
16564
16565 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
16566         LDKHTLCOutputInCommitment this_ptr_conv;
16567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16568         this_ptr_conv.is_owned = false;
16569         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
16570         return ret_val;
16571 }
16572
16573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16574         LDKHTLCOutputInCommitment this_ptr_conv;
16575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16576         this_ptr_conv.is_owned = false;
16577         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
16578 }
16579
16580 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16581         LDKHTLCOutputInCommitment this_ptr_conv;
16582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16583         this_ptr_conv.is_owned = false;
16584         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16585         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
16586         return ret_arr;
16587 }
16588
16589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16590         LDKHTLCOutputInCommitment this_ptr_conv;
16591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16592         this_ptr_conv.is_owned = false;
16593         LDKThirtyTwoBytes val_ref;
16594         CHECK((*env)->GetArrayLength(env, val) == 32);
16595         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16596         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
16597 }
16598
16599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16600         LDKHTLCOutputInCommitment orig_conv;
16601         orig_conv.inner = (void*)(orig & (~1));
16602         orig_conv.is_owned = false;
16603         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
16604         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16605         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16606         long ret_ref = (long)ret_var.inner;
16607         if (ret_var.is_owned) {
16608                 ret_ref |= 1;
16609         }
16610         return ret_ref;
16611 }
16612
16613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
16614         LDKHTLCOutputInCommitment obj_conv;
16615         obj_conv.inner = (void*)(obj & (~1));
16616         obj_conv.is_owned = false;
16617         LDKCVec_u8Z arg_var = HTLCOutputInCommitment_write(&obj_conv);
16618         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
16619         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
16620         CVec_u8Z_free(arg_var);
16621         return arg_arr;
16622 }
16623
16624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16625         LDKu8slice ser_ref;
16626         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16627         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16628         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16629         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
16630         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16631         return (long)ret_conv;
16632 }
16633
16634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
16635         LDKHTLCOutputInCommitment htlc_conv;
16636         htlc_conv.inner = (void*)(htlc & (~1));
16637         htlc_conv.is_owned = false;
16638         LDKTxCreationKeys keys_conv;
16639         keys_conv.inner = (void*)(keys & (~1));
16640         keys_conv.is_owned = false;
16641         LDKCVec_u8Z arg_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
16642         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
16643         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
16644         CVec_u8Z_free(arg_var);
16645         return arg_arr;
16646 }
16647
16648 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
16649         LDKPublicKey broadcaster_ref;
16650         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
16651         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
16652         LDKPublicKey countersignatory_ref;
16653         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
16654         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
16655         LDKCVec_u8Z arg_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
16656         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
16657         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
16658         CVec_u8Z_free(arg_var);
16659         return arg_arr;
16660 }
16661
16662 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1htlc_1transaction(JNIEnv *env, jclass clz, int8_tArray prev_hash, int32_t feerate_per_kw, int16_t contest_delay, int64_t htlc, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
16663         unsigned char prev_hash_arr[32];
16664         CHECK((*env)->GetArrayLength(env, prev_hash) == 32);
16665         (*env)->GetByteArrayRegion(env, prev_hash, 0, 32, prev_hash_arr);
16666         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
16667         LDKHTLCOutputInCommitment htlc_conv;
16668         htlc_conv.inner = (void*)(htlc & (~1));
16669         htlc_conv.is_owned = false;
16670         LDKPublicKey broadcaster_delayed_payment_key_ref;
16671         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
16672         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
16673         LDKPublicKey revocation_key_ref;
16674         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
16675         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
16676         LDKTransaction arg_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
16677         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
16678         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
16679         Transaction_free(arg_var);
16680         return arg_arr;
16681 }
16682
16683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16684         LDKChannelTransactionParameters this_ptr_conv;
16685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16686         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
16687         ChannelTransactionParameters_free(this_ptr_conv);
16688 }
16689
16690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
16691         LDKChannelTransactionParameters this_ptr_conv;
16692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16693         this_ptr_conv.is_owned = false;
16694         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
16695         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16696         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16697         long ret_ref = (long)ret_var.inner;
16698         if (ret_var.is_owned) {
16699                 ret_ref |= 1;
16700         }
16701         return ret_ref;
16702 }
16703
16704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16705         LDKChannelTransactionParameters this_ptr_conv;
16706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16707         this_ptr_conv.is_owned = false;
16708         LDKChannelPublicKeys val_conv;
16709         val_conv.inner = (void*)(val & (~1));
16710         val_conv.is_owned = (val & 1) || (val == 0);
16711         val_conv = ChannelPublicKeys_clone(&val_conv);
16712         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
16713 }
16714
16715 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16716         LDKChannelTransactionParameters this_ptr_conv;
16717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16718         this_ptr_conv.is_owned = false;
16719         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
16720         return ret_val;
16721 }
16722
16723 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) {
16724         LDKChannelTransactionParameters this_ptr_conv;
16725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16726         this_ptr_conv.is_owned = false;
16727         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
16728 }
16729
16730 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
16731         LDKChannelTransactionParameters this_ptr_conv;
16732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16733         this_ptr_conv.is_owned = false;
16734         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
16735         return ret_val;
16736 }
16737
16738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16739         LDKChannelTransactionParameters this_ptr_conv;
16740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16741         this_ptr_conv.is_owned = false;
16742         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
16743 }
16744
16745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
16746         LDKChannelTransactionParameters this_ptr_conv;
16747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16748         this_ptr_conv.is_owned = false;
16749         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
16750         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16751         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16752         long ret_ref = (long)ret_var.inner;
16753         if (ret_var.is_owned) {
16754                 ret_ref |= 1;
16755         }
16756         return ret_ref;
16757 }
16758
16759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16760         LDKChannelTransactionParameters this_ptr_conv;
16761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16762         this_ptr_conv.is_owned = false;
16763         LDKCounterpartyChannelTransactionParameters val_conv;
16764         val_conv.inner = (void*)(val & (~1));
16765         val_conv.is_owned = (val & 1) || (val == 0);
16766         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
16767         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
16768 }
16769
16770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16771         LDKChannelTransactionParameters this_ptr_conv;
16772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16773         this_ptr_conv.is_owned = false;
16774         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
16775         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16776         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16777         long ret_ref = (long)ret_var.inner;
16778         if (ret_var.is_owned) {
16779                 ret_ref |= 1;
16780         }
16781         return ret_ref;
16782 }
16783
16784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16785         LDKChannelTransactionParameters this_ptr_conv;
16786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16787         this_ptr_conv.is_owned = false;
16788         LDKOutPoint val_conv;
16789         val_conv.inner = (void*)(val & (~1));
16790         val_conv.is_owned = (val & 1) || (val == 0);
16791         val_conv = OutPoint_clone(&val_conv);
16792         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
16793 }
16794
16795 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) {
16796         LDKChannelPublicKeys holder_pubkeys_arg_conv;
16797         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
16798         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
16799         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
16800         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
16801         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
16802         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
16803         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
16804         LDKOutPoint funding_outpoint_arg_conv;
16805         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
16806         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
16807         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
16808         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);
16809         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16810         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16811         long ret_ref = (long)ret_var.inner;
16812         if (ret_var.is_owned) {
16813                 ret_ref |= 1;
16814         }
16815         return ret_ref;
16816 }
16817
16818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16819         LDKChannelTransactionParameters orig_conv;
16820         orig_conv.inner = (void*)(orig & (~1));
16821         orig_conv.is_owned = false;
16822         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
16823         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16824         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16825         long ret_ref = (long)ret_var.inner;
16826         if (ret_var.is_owned) {
16827                 ret_ref |= 1;
16828         }
16829         return ret_ref;
16830 }
16831
16832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16833         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
16834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16835         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
16836         CounterpartyChannelTransactionParameters_free(this_ptr_conv);
16837 }
16838
16839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
16840         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
16841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16842         this_ptr_conv.is_owned = false;
16843         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
16844         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16845         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16846         long ret_ref = (long)ret_var.inner;
16847         if (ret_var.is_owned) {
16848                 ret_ref |= 1;
16849         }
16850         return ret_ref;
16851 }
16852
16853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16854         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
16855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16856         this_ptr_conv.is_owned = false;
16857         LDKChannelPublicKeys val_conv;
16858         val_conv.inner = (void*)(val & (~1));
16859         val_conv.is_owned = (val & 1) || (val == 0);
16860         val_conv = ChannelPublicKeys_clone(&val_conv);
16861         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
16862 }
16863
16864 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16865         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
16866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16867         this_ptr_conv.is_owned = false;
16868         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
16869         return ret_val;
16870 }
16871
16872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16873         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
16874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16875         this_ptr_conv.is_owned = false;
16876         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
16877 }
16878
16879 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) {
16880         LDKChannelPublicKeys pubkeys_arg_conv;
16881         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
16882         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
16883         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
16884         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
16885         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16886         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16887         long ret_ref = (long)ret_var.inner;
16888         if (ret_var.is_owned) {
16889                 ret_ref |= 1;
16890         }
16891         return ret_ref;
16892 }
16893
16894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16895         LDKCounterpartyChannelTransactionParameters orig_conv;
16896         orig_conv.inner = (void*)(orig & (~1));
16897         orig_conv.is_owned = false;
16898         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
16899         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16900         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16901         long ret_ref = (long)ret_var.inner;
16902         if (ret_var.is_owned) {
16903                 ret_ref |= 1;
16904         }
16905         return ret_ref;
16906 }
16907
16908 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
16909         LDKChannelTransactionParameters this_arg_conv;
16910         this_arg_conv.inner = (void*)(this_arg & (~1));
16911         this_arg_conv.is_owned = false;
16912         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
16913         return ret_val;
16914 }
16915
16916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
16917         LDKChannelTransactionParameters this_arg_conv;
16918         this_arg_conv.inner = (void*)(this_arg & (~1));
16919         this_arg_conv.is_owned = false;
16920         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
16921         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16922         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16923         long ret_ref = (long)ret_var.inner;
16924         if (ret_var.is_owned) {
16925                 ret_ref |= 1;
16926         }
16927         return ret_ref;
16928 }
16929
16930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
16931         LDKChannelTransactionParameters this_arg_conv;
16932         this_arg_conv.inner = (void*)(this_arg & (~1));
16933         this_arg_conv.is_owned = false;
16934         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
16935         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16936         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16937         long ret_ref = (long)ret_var.inner;
16938         if (ret_var.is_owned) {
16939                 ret_ref |= 1;
16940         }
16941         return ret_ref;
16942 }
16943
16944 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
16945         LDKCounterpartyChannelTransactionParameters obj_conv;
16946         obj_conv.inner = (void*)(obj & (~1));
16947         obj_conv.is_owned = false;
16948         LDKCVec_u8Z arg_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
16949         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
16950         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
16951         CVec_u8Z_free(arg_var);
16952         return arg_arr;
16953 }
16954
16955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16956         LDKu8slice ser_ref;
16957         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16958         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16959         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16960         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
16961         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16962         return (long)ret_conv;
16963 }
16964
16965 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
16966         LDKChannelTransactionParameters obj_conv;
16967         obj_conv.inner = (void*)(obj & (~1));
16968         obj_conv.is_owned = false;
16969         LDKCVec_u8Z arg_var = ChannelTransactionParameters_write(&obj_conv);
16970         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
16971         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
16972         CVec_u8Z_free(arg_var);
16973         return arg_arr;
16974 }
16975
16976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16977         LDKu8slice ser_ref;
16978         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16979         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16980         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16981         *ret_conv = ChannelTransactionParameters_read(ser_ref);
16982         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16983         return (long)ret_conv;
16984 }
16985
16986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16987         LDKDirectedChannelTransactionParameters this_ptr_conv;
16988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16989         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
16990         DirectedChannelTransactionParameters_free(this_ptr_conv);
16991 }
16992
16993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
16994         LDKDirectedChannelTransactionParameters this_arg_conv;
16995         this_arg_conv.inner = (void*)(this_arg & (~1));
16996         this_arg_conv.is_owned = false;
16997         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
16998         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16999         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17000         long ret_ref = (long)ret_var.inner;
17001         if (ret_var.is_owned) {
17002                 ret_ref |= 1;
17003         }
17004         return ret_ref;
17005 }
17006
17007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
17008         LDKDirectedChannelTransactionParameters this_arg_conv;
17009         this_arg_conv.inner = (void*)(this_arg & (~1));
17010         this_arg_conv.is_owned = false;
17011         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
17012         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17013         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17014         long ret_ref = (long)ret_var.inner;
17015         if (ret_var.is_owned) {
17016                 ret_ref |= 1;
17017         }
17018         return ret_ref;
17019 }
17020
17021 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
17022         LDKDirectedChannelTransactionParameters this_arg_conv;
17023         this_arg_conv.inner = (void*)(this_arg & (~1));
17024         this_arg_conv.is_owned = false;
17025         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
17026         return ret_val;
17027 }
17028
17029 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
17030         LDKDirectedChannelTransactionParameters this_arg_conv;
17031         this_arg_conv.inner = (void*)(this_arg & (~1));
17032         this_arg_conv.is_owned = false;
17033         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
17034         return ret_val;
17035 }
17036
17037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
17038         LDKDirectedChannelTransactionParameters this_arg_conv;
17039         this_arg_conv.inner = (void*)(this_arg & (~1));
17040         this_arg_conv.is_owned = false;
17041         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
17042         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17043         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17044         long ret_ref = (long)ret_var.inner;
17045         if (ret_var.is_owned) {
17046                 ret_ref |= 1;
17047         }
17048         return ret_ref;
17049 }
17050
17051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17052         LDKHolderCommitmentTransaction this_ptr_conv;
17053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17054         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17055         HolderCommitmentTransaction_free(this_ptr_conv);
17056 }
17057
17058 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
17059         LDKHolderCommitmentTransaction this_ptr_conv;
17060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17061         this_ptr_conv.is_owned = false;
17062         int8_tArray arg_arr = (*env)->NewByteArray(env, 64);
17063         (*env)->SetByteArrayRegion(env, arg_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
17064         return arg_arr;
17065 }
17066
17067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17068         LDKHolderCommitmentTransaction this_ptr_conv;
17069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17070         this_ptr_conv.is_owned = false;
17071         LDKSignature val_ref;
17072         CHECK((*env)->GetArrayLength(env, val) == 64);
17073         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17074         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
17075 }
17076
17077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
17078         LDKHolderCommitmentTransaction this_ptr_conv;
17079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17080         this_ptr_conv.is_owned = false;
17081         LDKCVec_SignatureZ val_constr;
17082         val_constr.datalen = (*env)->GetArrayLength(env, val);
17083         if (val_constr.datalen > 0)
17084                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17085         else
17086                 val_constr.data = NULL;
17087         for (size_t i = 0; i < val_constr.datalen; i++) {
17088                 int8_tArray arr_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
17089                 LDKSignature arr_conv_8_ref;
17090                 CHECK((*env)->GetArrayLength(env, arr_conv_8) == 64);
17091                 (*env)->GetByteArrayRegion(env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
17092                 val_constr.data[i] = arr_conv_8_ref;
17093         }
17094         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
17095 }
17096
17097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17098         LDKHolderCommitmentTransaction orig_conv;
17099         orig_conv.inner = (void*)(orig & (~1));
17100         orig_conv.is_owned = false;
17101         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
17102         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17103         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17104         long ret_ref = (long)ret_var.inner;
17105         if (ret_var.is_owned) {
17106                 ret_ref |= 1;
17107         }
17108         return ret_ref;
17109 }
17110
17111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
17112         LDKHolderCommitmentTransaction obj_conv;
17113         obj_conv.inner = (void*)(obj & (~1));
17114         obj_conv.is_owned = false;
17115         LDKCVec_u8Z arg_var = HolderCommitmentTransaction_write(&obj_conv);
17116         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
17117         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
17118         CVec_u8Z_free(arg_var);
17119         return arg_arr;
17120 }
17121
17122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17123         LDKu8slice ser_ref;
17124         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17125         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17126         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
17127         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
17128         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17129         return (long)ret_conv;
17130 }
17131
17132 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) {
17133         LDKCommitmentTransaction commitment_tx_conv;
17134         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
17135         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
17136         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
17137         LDKSignature counterparty_sig_ref;
17138         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
17139         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
17140         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
17141         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
17142         if (counterparty_htlc_sigs_constr.datalen > 0)
17143                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17144         else
17145                 counterparty_htlc_sigs_constr.data = NULL;
17146         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
17147                 int8_tArray arr_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
17148                 LDKSignature arr_conv_8_ref;
17149                 CHECK((*env)->GetArrayLength(env, arr_conv_8) == 64);
17150                 (*env)->GetByteArrayRegion(env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
17151                 counterparty_htlc_sigs_constr.data[i] = arr_conv_8_ref;
17152         }
17153         LDKPublicKey holder_funding_key_ref;
17154         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
17155         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
17156         LDKPublicKey counterparty_funding_key_ref;
17157         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
17158         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
17159         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
17160         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17161         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17162         long ret_ref = (long)ret_var.inner;
17163         if (ret_var.is_owned) {
17164                 ret_ref |= 1;
17165         }
17166         return ret_ref;
17167 }
17168
17169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17170         LDKBuiltCommitmentTransaction this_ptr_conv;
17171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17172         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17173         BuiltCommitmentTransaction_free(this_ptr_conv);
17174 }
17175
17176 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
17177         LDKBuiltCommitmentTransaction this_ptr_conv;
17178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17179         this_ptr_conv.is_owned = false;
17180         LDKTransaction arg_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
17181         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
17182         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
17183         Transaction_free(arg_var);
17184         return arg_arr;
17185 }
17186
17187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17188         LDKBuiltCommitmentTransaction this_ptr_conv;
17189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17190         this_ptr_conv.is_owned = false;
17191         LDKTransaction val_ref;
17192         val_ref.datalen = (*env)->GetArrayLength(env, val);
17193         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
17194         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
17195         val_ref.data_is_owned = true;
17196         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
17197 }
17198
17199 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
17200         LDKBuiltCommitmentTransaction this_ptr_conv;
17201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17202         this_ptr_conv.is_owned = false;
17203         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17204         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
17205         return ret_arr;
17206 }
17207
17208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17209         LDKBuiltCommitmentTransaction this_ptr_conv;
17210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17211         this_ptr_conv.is_owned = false;
17212         LDKThirtyTwoBytes val_ref;
17213         CHECK((*env)->GetArrayLength(env, val) == 32);
17214         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17215         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
17216 }
17217
17218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
17219         LDKTransaction transaction_arg_ref;
17220         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
17221         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
17222         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
17223         transaction_arg_ref.data_is_owned = true;
17224         LDKThirtyTwoBytes txid_arg_ref;
17225         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
17226         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
17227         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
17228         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17229         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17230         long ret_ref = (long)ret_var.inner;
17231         if (ret_var.is_owned) {
17232                 ret_ref |= 1;
17233         }
17234         return ret_ref;
17235 }
17236
17237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17238         LDKBuiltCommitmentTransaction orig_conv;
17239         orig_conv.inner = (void*)(orig & (~1));
17240         orig_conv.is_owned = false;
17241         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
17242         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17243         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17244         long ret_ref = (long)ret_var.inner;
17245         if (ret_var.is_owned) {
17246                 ret_ref |= 1;
17247         }
17248         return ret_ref;
17249 }
17250
17251 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
17252         LDKBuiltCommitmentTransaction obj_conv;
17253         obj_conv.inner = (void*)(obj & (~1));
17254         obj_conv.is_owned = false;
17255         LDKCVec_u8Z arg_var = BuiltCommitmentTransaction_write(&obj_conv);
17256         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
17257         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
17258         CVec_u8Z_free(arg_var);
17259         return arg_arr;
17260 }
17261
17262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17263         LDKu8slice ser_ref;
17264         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17265         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17266         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
17267         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
17268         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17269         return (long)ret_conv;
17270 }
17271
17272 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) {
17273         LDKBuiltCommitmentTransaction this_arg_conv;
17274         this_arg_conv.inner = (void*)(this_arg & (~1));
17275         this_arg_conv.is_owned = false;
17276         LDKu8slice funding_redeemscript_ref;
17277         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
17278         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
17279         int8_tArray arg_arr = (*env)->NewByteArray(env, 32);
17280         (*env)->SetByteArrayRegion(env, arg_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
17281         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
17282         return arg_arr;
17283 }
17284
17285 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) {
17286         LDKBuiltCommitmentTransaction this_arg_conv;
17287         this_arg_conv.inner = (void*)(this_arg & (~1));
17288         this_arg_conv.is_owned = false;
17289         unsigned char funding_key_arr[32];
17290         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
17291         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
17292         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
17293         LDKu8slice funding_redeemscript_ref;
17294         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
17295         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
17296         int8_tArray arg_arr = (*env)->NewByteArray(env, 64);
17297         (*env)->SetByteArrayRegion(env, arg_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
17298         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
17299         return arg_arr;
17300 }
17301
17302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17303         LDKCommitmentTransaction this_ptr_conv;
17304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17305         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17306         CommitmentTransaction_free(this_ptr_conv);
17307 }
17308
17309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17310         LDKCommitmentTransaction orig_conv;
17311         orig_conv.inner = (void*)(orig & (~1));
17312         orig_conv.is_owned = false;
17313         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
17314         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17315         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17316         long ret_ref = (long)ret_var.inner;
17317         if (ret_var.is_owned) {
17318                 ret_ref |= 1;
17319         }
17320         return ret_ref;
17321 }
17322
17323 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
17324         LDKCommitmentTransaction obj_conv;
17325         obj_conv.inner = (void*)(obj & (~1));
17326         obj_conv.is_owned = false;
17327         LDKCVec_u8Z arg_var = CommitmentTransaction_write(&obj_conv);
17328         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
17329         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
17330         CVec_u8Z_free(arg_var);
17331         return arg_arr;
17332 }
17333
17334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17335         LDKu8slice ser_ref;
17336         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17337         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17338         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
17339         *ret_conv = CommitmentTransaction_read(ser_ref);
17340         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17341         return (long)ret_conv;
17342 }
17343
17344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
17345         LDKCommitmentTransaction this_arg_conv;
17346         this_arg_conv.inner = (void*)(this_arg & (~1));
17347         this_arg_conv.is_owned = false;
17348         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
17349         return ret_val;
17350 }
17351
17352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
17353         LDKCommitmentTransaction this_arg_conv;
17354         this_arg_conv.inner = (void*)(this_arg & (~1));
17355         this_arg_conv.is_owned = false;
17356         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
17357         return ret_val;
17358 }
17359
17360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
17361         LDKCommitmentTransaction this_arg_conv;
17362         this_arg_conv.inner = (void*)(this_arg & (~1));
17363         this_arg_conv.is_owned = false;
17364         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
17365         return ret_val;
17366 }
17367
17368 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
17369         LDKCommitmentTransaction this_arg_conv;
17370         this_arg_conv.inner = (void*)(this_arg & (~1));
17371         this_arg_conv.is_owned = false;
17372         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
17373         return ret_val;
17374 }
17375
17376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
17377         LDKCommitmentTransaction this_arg_conv;
17378         this_arg_conv.inner = (void*)(this_arg & (~1));
17379         this_arg_conv.is_owned = false;
17380         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
17381         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17382         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17383         long ret_ref = (long)ret_var.inner;
17384         if (ret_var.is_owned) {
17385                 ret_ref |= 1;
17386         }
17387         return ret_ref;
17388 }
17389
17390 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) {
17391         LDKCommitmentTransaction this_arg_conv;
17392         this_arg_conv.inner = (void*)(this_arg & (~1));
17393         this_arg_conv.is_owned = false;
17394         LDKDirectedChannelTransactionParameters channel_parameters_conv;
17395         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
17396         channel_parameters_conv.is_owned = false;
17397         LDKChannelPublicKeys broadcaster_keys_conv;
17398         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
17399         broadcaster_keys_conv.is_owned = false;
17400         LDKChannelPublicKeys countersignatory_keys_conv;
17401         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
17402         countersignatory_keys_conv.is_owned = false;
17403         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
17404         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
17405         return (long)ret_conv;
17406 }
17407
17408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17409         LDKTrustedCommitmentTransaction this_ptr_conv;
17410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17411         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17412         TrustedCommitmentTransaction_free(this_ptr_conv);
17413 }
17414
17415 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
17416         LDKTrustedCommitmentTransaction this_arg_conv;
17417         this_arg_conv.inner = (void*)(this_arg & (~1));
17418         this_arg_conv.is_owned = false;
17419         int8_tArray arg_arr = (*env)->NewByteArray(env, 32);
17420         (*env)->SetByteArrayRegion(env, arg_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
17421         return arg_arr;
17422 }
17423
17424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
17425         LDKTrustedCommitmentTransaction this_arg_conv;
17426         this_arg_conv.inner = (void*)(this_arg & (~1));
17427         this_arg_conv.is_owned = false;
17428         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
17429         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17430         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17431         long ret_ref = (long)ret_var.inner;
17432         if (ret_var.is_owned) {
17433                 ret_ref |= 1;
17434         }
17435         return ret_ref;
17436 }
17437
17438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
17439         LDKTrustedCommitmentTransaction this_arg_conv;
17440         this_arg_conv.inner = (void*)(this_arg & (~1));
17441         this_arg_conv.is_owned = false;
17442         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
17443         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17444         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17445         long ret_ref = (long)ret_var.inner;
17446         if (ret_var.is_owned) {
17447                 ret_ref |= 1;
17448         }
17449         return ret_ref;
17450 }
17451
17452 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) {
17453         LDKTrustedCommitmentTransaction this_arg_conv;
17454         this_arg_conv.inner = (void*)(this_arg & (~1));
17455         this_arg_conv.is_owned = false;
17456         unsigned char htlc_base_key_arr[32];
17457         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
17458         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
17459         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
17460         LDKDirectedChannelTransactionParameters channel_parameters_conv;
17461         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
17462         channel_parameters_conv.is_owned = false;
17463         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
17464         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
17465         return (long)ret_conv;
17466 }
17467
17468 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) {
17469         LDKPublicKey broadcaster_payment_basepoint_ref;
17470         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
17471         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
17472         LDKPublicKey countersignatory_payment_basepoint_ref;
17473         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
17474         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
17475         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
17476         return ret_val;
17477 }
17478
17479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17480         LDKInitFeatures orig_conv;
17481         orig_conv.inner = (void*)(orig & (~1));
17482         orig_conv.is_owned = false;
17483         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
17484         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17485         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17486         long ret_ref = (long)ret_var.inner;
17487         if (ret_var.is_owned) {
17488                 ret_ref |= 1;
17489         }
17490         return ret_ref;
17491 }
17492
17493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17494         LDKNodeFeatures orig_conv;
17495         orig_conv.inner = (void*)(orig & (~1));
17496         orig_conv.is_owned = false;
17497         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
17498         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17499         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17500         long ret_ref = (long)ret_var.inner;
17501         if (ret_var.is_owned) {
17502                 ret_ref |= 1;
17503         }
17504         return ret_ref;
17505 }
17506
17507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17508         LDKChannelFeatures orig_conv;
17509         orig_conv.inner = (void*)(orig & (~1));
17510         orig_conv.is_owned = false;
17511         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
17512         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17513         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17514         long ret_ref = (long)ret_var.inner;
17515         if (ret_var.is_owned) {
17516                 ret_ref |= 1;
17517         }
17518         return ret_ref;
17519 }
17520
17521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17522         LDKInitFeatures this_ptr_conv;
17523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17524         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17525         InitFeatures_free(this_ptr_conv);
17526 }
17527
17528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17529         LDKNodeFeatures this_ptr_conv;
17530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17531         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17532         NodeFeatures_free(this_ptr_conv);
17533 }
17534
17535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17536         LDKChannelFeatures this_ptr_conv;
17537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17538         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17539         ChannelFeatures_free(this_ptr_conv);
17540 }
17541
17542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
17543         LDKInitFeatures ret_var = InitFeatures_empty();
17544         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17545         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17546         long ret_ref = (long)ret_var.inner;
17547         if (ret_var.is_owned) {
17548                 ret_ref |= 1;
17549         }
17550         return ret_ref;
17551 }
17552
17553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
17554         LDKInitFeatures ret_var = InitFeatures_known();
17555         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17556         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17557         long ret_ref = (long)ret_var.inner;
17558         if (ret_var.is_owned) {
17559                 ret_ref |= 1;
17560         }
17561         return ret_ref;
17562 }
17563
17564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
17565         LDKNodeFeatures ret_var = NodeFeatures_empty();
17566         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17567         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17568         long ret_ref = (long)ret_var.inner;
17569         if (ret_var.is_owned) {
17570                 ret_ref |= 1;
17571         }
17572         return ret_ref;
17573 }
17574
17575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
17576         LDKNodeFeatures ret_var = NodeFeatures_known();
17577         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17578         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17579         long ret_ref = (long)ret_var.inner;
17580         if (ret_var.is_owned) {
17581                 ret_ref |= 1;
17582         }
17583         return ret_ref;
17584 }
17585
17586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
17587         LDKChannelFeatures ret_var = ChannelFeatures_empty();
17588         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17589         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17590         long ret_ref = (long)ret_var.inner;
17591         if (ret_var.is_owned) {
17592                 ret_ref |= 1;
17593         }
17594         return ret_ref;
17595 }
17596
17597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
17598         LDKChannelFeatures ret_var = ChannelFeatures_known();
17599         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17600         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17601         long ret_ref = (long)ret_var.inner;
17602         if (ret_var.is_owned) {
17603                 ret_ref |= 1;
17604         }
17605         return ret_ref;
17606 }
17607
17608 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
17609         LDKInitFeatures obj_conv;
17610         obj_conv.inner = (void*)(obj & (~1));
17611         obj_conv.is_owned = false;
17612         LDKCVec_u8Z arg_var = InitFeatures_write(&obj_conv);
17613         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
17614         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
17615         CVec_u8Z_free(arg_var);
17616         return arg_arr;
17617 }
17618
17619 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
17620         LDKNodeFeatures obj_conv;
17621         obj_conv.inner = (void*)(obj & (~1));
17622         obj_conv.is_owned = false;
17623         LDKCVec_u8Z arg_var = NodeFeatures_write(&obj_conv);
17624         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
17625         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
17626         CVec_u8Z_free(arg_var);
17627         return arg_arr;
17628 }
17629
17630 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
17631         LDKChannelFeatures obj_conv;
17632         obj_conv.inner = (void*)(obj & (~1));
17633         obj_conv.is_owned = false;
17634         LDKCVec_u8Z arg_var = ChannelFeatures_write(&obj_conv);
17635         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
17636         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
17637         CVec_u8Z_free(arg_var);
17638         return arg_arr;
17639 }
17640
17641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17642         LDKu8slice ser_ref;
17643         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17644         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17645         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17646         *ret_conv = InitFeatures_read(ser_ref);
17647         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17648         return (long)ret_conv;
17649 }
17650
17651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17652         LDKu8slice ser_ref;
17653         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17654         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17655         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17656         *ret_conv = NodeFeatures_read(ser_ref);
17657         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17658         return (long)ret_conv;
17659 }
17660
17661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17662         LDKu8slice ser_ref;
17663         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17664         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17665         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17666         *ret_conv = ChannelFeatures_read(ser_ref);
17667         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17668         return (long)ret_conv;
17669 }
17670
17671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17672         LDKRouteHop this_ptr_conv;
17673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17674         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17675         RouteHop_free(this_ptr_conv);
17676 }
17677
17678 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17679         LDKRouteHop this_ptr_conv;
17680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17681         this_ptr_conv.is_owned = false;
17682         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
17683         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
17684         return arg_arr;
17685 }
17686
17687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17688         LDKRouteHop this_ptr_conv;
17689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17690         this_ptr_conv.is_owned = false;
17691         LDKPublicKey val_ref;
17692         CHECK((*env)->GetArrayLength(env, val) == 33);
17693         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17694         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
17695 }
17696
17697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
17698         LDKRouteHop this_ptr_conv;
17699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17700         this_ptr_conv.is_owned = false;
17701         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
17702         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17703         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17704         long ret_ref = (long)ret_var.inner;
17705         if (ret_var.is_owned) {
17706                 ret_ref |= 1;
17707         }
17708         return ret_ref;
17709 }
17710
17711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17712         LDKRouteHop this_ptr_conv;
17713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17714         this_ptr_conv.is_owned = false;
17715         LDKNodeFeatures val_conv;
17716         val_conv.inner = (void*)(val & (~1));
17717         val_conv.is_owned = (val & 1) || (val == 0);
17718         val_conv = NodeFeatures_clone(&val_conv);
17719         RouteHop_set_node_features(&this_ptr_conv, val_conv);
17720 }
17721
17722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17723         LDKRouteHop this_ptr_conv;
17724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17725         this_ptr_conv.is_owned = false;
17726         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
17727         return ret_val;
17728 }
17729
17730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17731         LDKRouteHop this_ptr_conv;
17732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17733         this_ptr_conv.is_owned = false;
17734         RouteHop_set_short_channel_id(&this_ptr_conv, val);
17735 }
17736
17737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
17738         LDKRouteHop this_ptr_conv;
17739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17740         this_ptr_conv.is_owned = false;
17741         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
17742         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17743         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17744         long ret_ref = (long)ret_var.inner;
17745         if (ret_var.is_owned) {
17746                 ret_ref |= 1;
17747         }
17748         return ret_ref;
17749 }
17750
17751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17752         LDKRouteHop this_ptr_conv;
17753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17754         this_ptr_conv.is_owned = false;
17755         LDKChannelFeatures val_conv;
17756         val_conv.inner = (void*)(val & (~1));
17757         val_conv.is_owned = (val & 1) || (val == 0);
17758         val_conv = ChannelFeatures_clone(&val_conv);
17759         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
17760 }
17761
17762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17763         LDKRouteHop this_ptr_conv;
17764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17765         this_ptr_conv.is_owned = false;
17766         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
17767         return ret_val;
17768 }
17769
17770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17771         LDKRouteHop this_ptr_conv;
17772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17773         this_ptr_conv.is_owned = false;
17774         RouteHop_set_fee_msat(&this_ptr_conv, val);
17775 }
17776
17777 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
17778         LDKRouteHop this_ptr_conv;
17779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17780         this_ptr_conv.is_owned = false;
17781         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
17782         return ret_val;
17783 }
17784
17785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17786         LDKRouteHop this_ptr_conv;
17787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17788         this_ptr_conv.is_owned = false;
17789         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
17790 }
17791
17792 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) {
17793         LDKPublicKey pubkey_arg_ref;
17794         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
17795         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
17796         LDKNodeFeatures node_features_arg_conv;
17797         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
17798         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
17799         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
17800         LDKChannelFeatures channel_features_arg_conv;
17801         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
17802         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
17803         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
17804         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);
17805         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17806         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17807         long ret_ref = (long)ret_var.inner;
17808         if (ret_var.is_owned) {
17809                 ret_ref |= 1;
17810         }
17811         return ret_ref;
17812 }
17813
17814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17815         LDKRouteHop orig_conv;
17816         orig_conv.inner = (void*)(orig & (~1));
17817         orig_conv.is_owned = false;
17818         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
17819         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17820         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17821         long ret_ref = (long)ret_var.inner;
17822         if (ret_var.is_owned) {
17823                 ret_ref |= 1;
17824         }
17825         return ret_ref;
17826 }
17827
17828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17829         LDKRoute this_ptr_conv;
17830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17831         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17832         Route_free(this_ptr_conv);
17833 }
17834
17835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
17836         LDKRoute this_ptr_conv;
17837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17838         this_ptr_conv.is_owned = false;
17839         LDKCVec_CVec_RouteHopZZ val_constr;
17840         val_constr.datalen = (*env)->GetArrayLength(env, val);
17841         if (val_constr.datalen > 0)
17842                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
17843         else
17844                 val_constr.data = NULL;
17845         for (size_t m = 0; m < val_constr.datalen; m++) {
17846                 int64_tArray arr_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
17847                 LDKCVec_RouteHopZ arr_conv_12_constr;
17848                 arr_conv_12_constr.datalen = (*env)->GetArrayLength(env, arr_conv_12);
17849                 if (arr_conv_12_constr.datalen > 0)
17850                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17851                 else
17852                         arr_conv_12_constr.data = NULL;
17853                 int64_t* arr_conv_12_vals = (*env)->GetLongArrayElements (env, arr_conv_12, NULL);
17854                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
17855                         int64_t arr_conv_10 = arr_conv_12_vals[k];
17856                         LDKRouteHop arr_conv_10_conv;
17857                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
17858                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
17859                         arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
17860                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
17861                 }
17862                 (*env)->ReleaseLongArrayElements(env, arr_conv_12, arr_conv_12_vals, 0);
17863                 val_constr.data[m] = arr_conv_12_constr;
17864         }
17865         Route_set_paths(&this_ptr_conv, val_constr);
17866 }
17867
17868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
17869         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
17870         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
17871         if (paths_arg_constr.datalen > 0)
17872                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
17873         else
17874                 paths_arg_constr.data = NULL;
17875         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
17876                 int64_tArray arr_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
17877                 LDKCVec_RouteHopZ arr_conv_12_constr;
17878                 arr_conv_12_constr.datalen = (*env)->GetArrayLength(env, arr_conv_12);
17879                 if (arr_conv_12_constr.datalen > 0)
17880                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17881                 else
17882                         arr_conv_12_constr.data = NULL;
17883                 int64_t* arr_conv_12_vals = (*env)->GetLongArrayElements (env, arr_conv_12, NULL);
17884                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
17885                         int64_t arr_conv_10 = arr_conv_12_vals[k];
17886                         LDKRouteHop arr_conv_10_conv;
17887                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
17888                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
17889                         arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
17890                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
17891                 }
17892                 (*env)->ReleaseLongArrayElements(env, arr_conv_12, arr_conv_12_vals, 0);
17893                 paths_arg_constr.data[m] = arr_conv_12_constr;
17894         }
17895         LDKRoute ret_var = Route_new(paths_arg_constr);
17896         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17897         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17898         long ret_ref = (long)ret_var.inner;
17899         if (ret_var.is_owned) {
17900                 ret_ref |= 1;
17901         }
17902         return ret_ref;
17903 }
17904
17905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17906         LDKRoute orig_conv;
17907         orig_conv.inner = (void*)(orig & (~1));
17908         orig_conv.is_owned = false;
17909         LDKRoute ret_var = Route_clone(&orig_conv);
17910         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17911         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17912         long ret_ref = (long)ret_var.inner;
17913         if (ret_var.is_owned) {
17914                 ret_ref |= 1;
17915         }
17916         return ret_ref;
17917 }
17918
17919 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
17920         LDKRoute obj_conv;
17921         obj_conv.inner = (void*)(obj & (~1));
17922         obj_conv.is_owned = false;
17923         LDKCVec_u8Z arg_var = Route_write(&obj_conv);
17924         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
17925         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
17926         CVec_u8Z_free(arg_var);
17927         return arg_arr;
17928 }
17929
17930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17931         LDKu8slice ser_ref;
17932         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17933         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17934         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17935         *ret_conv = Route_read(ser_ref);
17936         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17937         return (long)ret_conv;
17938 }
17939
17940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17941         LDKRouteHint this_ptr_conv;
17942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17943         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17944         RouteHint_free(this_ptr_conv);
17945 }
17946
17947 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17948         LDKRouteHint this_ptr_conv;
17949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17950         this_ptr_conv.is_owned = false;
17951         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
17952         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, RouteHint_get_src_node_id(&this_ptr_conv).compressed_form);
17953         return arg_arr;
17954 }
17955
17956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17957         LDKRouteHint this_ptr_conv;
17958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17959         this_ptr_conv.is_owned = false;
17960         LDKPublicKey val_ref;
17961         CHECK((*env)->GetArrayLength(env, val) == 33);
17962         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17963         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
17964 }
17965
17966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17967         LDKRouteHint this_ptr_conv;
17968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17969         this_ptr_conv.is_owned = false;
17970         int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
17971         return ret_val;
17972 }
17973
17974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17975         LDKRouteHint this_ptr_conv;
17976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17977         this_ptr_conv.is_owned = false;
17978         RouteHint_set_short_channel_id(&this_ptr_conv, val);
17979 }
17980
17981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
17982         LDKRouteHint this_ptr_conv;
17983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17984         this_ptr_conv.is_owned = false;
17985         LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
17986         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17987         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17988         long ret_ref = (long)ret_var.inner;
17989         if (ret_var.is_owned) {
17990                 ret_ref |= 1;
17991         }
17992         return ret_ref;
17993 }
17994
17995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17996         LDKRouteHint this_ptr_conv;
17997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17998         this_ptr_conv.is_owned = false;
17999         LDKRoutingFees val_conv;
18000         val_conv.inner = (void*)(val & (~1));
18001         val_conv.is_owned = (val & 1) || (val == 0);
18002         val_conv = RoutingFees_clone(&val_conv);
18003         RouteHint_set_fees(&this_ptr_conv, val_conv);
18004 }
18005
18006 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
18007         LDKRouteHint this_ptr_conv;
18008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18009         this_ptr_conv.is_owned = false;
18010         int16_t ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
18011         return ret_val;
18012 }
18013
18014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18015         LDKRouteHint this_ptr_conv;
18016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18017         this_ptr_conv.is_owned = false;
18018         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
18019 }
18020
18021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18022         LDKRouteHint this_ptr_conv;
18023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18024         this_ptr_conv.is_owned = false;
18025         int64_t ret_val = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
18026         return ret_val;
18027 }
18028
18029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18030         LDKRouteHint this_ptr_conv;
18031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18032         this_ptr_conv.is_owned = false;
18033         RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val);
18034 }
18035
18036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_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) {
18037         LDKPublicKey src_node_id_arg_ref;
18038         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
18039         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
18040         LDKRoutingFees fees_arg_conv;
18041         fees_arg_conv.inner = (void*)(fees_arg & (~1));
18042         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
18043         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
18044         LDKRouteHint ret_var = RouteHint_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg);
18045         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18046         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18047         long ret_ref = (long)ret_var.inner;
18048         if (ret_var.is_owned) {
18049                 ret_ref |= 1;
18050         }
18051         return ret_ref;
18052 }
18053
18054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18055         LDKRouteHint orig_conv;
18056         orig_conv.inner = (void*)(orig & (~1));
18057         orig_conv.is_owned = false;
18058         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
18059         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18060         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18061         long ret_ref = (long)ret_var.inner;
18062         if (ret_var.is_owned) {
18063                 ret_ref |= 1;
18064         }
18065         return ret_ref;
18066 }
18067
18068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv *env, jclass clz, int8_tArray our_node_id, int64_t network, int8_tArray target, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) {
18069         LDKPublicKey our_node_id_ref;
18070         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
18071         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
18072         LDKNetworkGraph network_conv;
18073         network_conv.inner = (void*)(network & (~1));
18074         network_conv.is_owned = false;
18075         LDKPublicKey target_ref;
18076         CHECK((*env)->GetArrayLength(env, target) == 33);
18077         (*env)->GetByteArrayRegion(env, target, 0, 33, target_ref.compressed_form);
18078         LDKCVec_ChannelDetailsZ first_hops_constr;
18079         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
18080         if (first_hops_constr.datalen > 0)
18081                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
18082         else
18083                 first_hops_constr.data = NULL;
18084         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
18085         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
18086                 int64_t arr_conv_16 = first_hops_vals[q];
18087                 LDKChannelDetails arr_conv_16_conv;
18088                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
18089                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
18090                 first_hops_constr.data[q] = arr_conv_16_conv;
18091         }
18092         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
18093         LDKCVec_RouteHintZ last_hops_constr;
18094         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
18095         if (last_hops_constr.datalen > 0)
18096                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
18097         else
18098                 last_hops_constr.data = NULL;
18099         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
18100         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
18101                 int64_t arr_conv_11 = last_hops_vals[l];
18102                 LDKRouteHint arr_conv_11_conv;
18103                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
18104                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
18105                 arr_conv_11_conv = RouteHint_clone(&arr_conv_11_conv);
18106                 last_hops_constr.data[l] = arr_conv_11_conv;
18107         }
18108         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
18109         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18110         if (logger_conv.free == LDKLogger_JCalls_free) {
18111                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18112                 LDKLogger_JCalls_clone(logger_conv.this_arg);
18113         }
18114         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
18115         *ret_conv = get_route(our_node_id_ref, &network_conv, target_ref, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
18116         FREE(first_hops_constr.data);
18117         return (long)ret_conv;
18118 }
18119
18120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18121         LDKNetworkGraph this_ptr_conv;
18122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18123         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18124         NetworkGraph_free(this_ptr_conv);
18125 }
18126
18127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18128         LDKLockedNetworkGraph this_ptr_conv;
18129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18130         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18131         LockedNetworkGraph_free(this_ptr_conv);
18132 }
18133
18134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18135         LDKNetGraphMsgHandler this_ptr_conv;
18136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18137         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18138         NetGraphMsgHandler_free(this_ptr_conv);
18139 }
18140
18141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t chain_access, int64_t logger) {
18142         LDKThirtyTwoBytes genesis_hash_ref;
18143         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
18144         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
18145         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
18146         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18147         if (logger_conv.free == LDKLogger_JCalls_free) {
18148                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18149                 LDKLogger_JCalls_clone(logger_conv.this_arg);
18150         }
18151         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv, logger_conv);
18152         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18153         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18154         long ret_ref = (long)ret_var.inner;
18155         if (ret_var.is_owned) {
18156                 ret_ref |= 1;
18157         }
18158         return ret_ref;
18159 }
18160
18161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net_1graph(JNIEnv *env, jclass clz, int64_t chain_access, int64_t logger, int64_t network_graph) {
18162         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
18163         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18164         if (logger_conv.free == LDKLogger_JCalls_free) {
18165                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18166                 LDKLogger_JCalls_clone(logger_conv.this_arg);
18167         }
18168         LDKNetworkGraph network_graph_conv;
18169         network_graph_conv.inner = (void*)(network_graph & (~1));
18170         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
18171         // Warning: we need a move here but no clone is available for LDKNetworkGraph
18172         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv, logger_conv, network_graph_conv);
18173         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18174         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18175         long ret_ref = (long)ret_var.inner;
18176         if (ret_var.is_owned) {
18177                 ret_ref |= 1;
18178         }
18179         return ret_ref;
18180 }
18181
18182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
18183         LDKNetGraphMsgHandler this_arg_conv;
18184         this_arg_conv.inner = (void*)(this_arg & (~1));
18185         this_arg_conv.is_owned = false;
18186         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
18187         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18188         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18189         long ret_ref = (long)ret_var.inner;
18190         if (ret_var.is_owned) {
18191                 ret_ref |= 1;
18192         }
18193         return ret_ref;
18194 }
18195
18196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
18197         LDKLockedNetworkGraph this_arg_conv;
18198         this_arg_conv.inner = (void*)(this_arg & (~1));
18199         this_arg_conv.is_owned = false;
18200         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
18201         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18202         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18203         long ret_ref = (long)ret_var.inner;
18204         if (ret_var.is_owned) {
18205                 ret_ref |= 1;
18206         }
18207         return ret_ref;
18208 }
18209
18210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
18211         LDKNetGraphMsgHandler this_arg_conv;
18212         this_arg_conv.inner = (void*)(this_arg & (~1));
18213         this_arg_conv.is_owned = false;
18214         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
18215         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
18216         return (long)ret;
18217 }
18218
18219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
18220         LDKNetGraphMsgHandler this_arg_conv;
18221         this_arg_conv.inner = (void*)(this_arg & (~1));
18222         this_arg_conv.is_owned = false;
18223         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
18224         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
18225         return (long)ret;
18226 }
18227
18228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18229         LDKDirectionalChannelInfo this_ptr_conv;
18230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18231         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18232         DirectionalChannelInfo_free(this_ptr_conv);
18233 }
18234
18235 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
18236         LDKDirectionalChannelInfo this_ptr_conv;
18237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18238         this_ptr_conv.is_owned = false;
18239         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
18240         return ret_val;
18241 }
18242
18243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18244         LDKDirectionalChannelInfo this_ptr_conv;
18245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18246         this_ptr_conv.is_owned = false;
18247         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
18248 }
18249
18250 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
18251         LDKDirectionalChannelInfo this_ptr_conv;
18252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18253         this_ptr_conv.is_owned = false;
18254         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
18255         return ret_val;
18256 }
18257
18258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18259         LDKDirectionalChannelInfo this_ptr_conv;
18260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18261         this_ptr_conv.is_owned = false;
18262         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
18263 }
18264
18265 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
18266         LDKDirectionalChannelInfo this_ptr_conv;
18267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18268         this_ptr_conv.is_owned = false;
18269         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
18270         return ret_val;
18271 }
18272
18273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18274         LDKDirectionalChannelInfo this_ptr_conv;
18275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18276         this_ptr_conv.is_owned = false;
18277         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
18278 }
18279
18280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18281         LDKDirectionalChannelInfo this_ptr_conv;
18282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18283         this_ptr_conv.is_owned = false;
18284         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
18285         return ret_val;
18286 }
18287
18288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18289         LDKDirectionalChannelInfo this_ptr_conv;
18290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18291         this_ptr_conv.is_owned = false;
18292         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
18293 }
18294
18295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
18296         LDKDirectionalChannelInfo this_ptr_conv;
18297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18298         this_ptr_conv.is_owned = false;
18299         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
18300         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18301         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18302         long ret_ref = (long)ret_var.inner;
18303         if (ret_var.is_owned) {
18304                 ret_ref |= 1;
18305         }
18306         return ret_ref;
18307 }
18308
18309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18310         LDKDirectionalChannelInfo this_ptr_conv;
18311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18312         this_ptr_conv.is_owned = false;
18313         LDKRoutingFees val_conv;
18314         val_conv.inner = (void*)(val & (~1));
18315         val_conv.is_owned = (val & 1) || (val == 0);
18316         val_conv = RoutingFees_clone(&val_conv);
18317         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
18318 }
18319
18320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
18321         LDKDirectionalChannelInfo this_ptr_conv;
18322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18323         this_ptr_conv.is_owned = false;
18324         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
18325         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18326         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18327         long ret_ref = (long)ret_var.inner;
18328         if (ret_var.is_owned) {
18329                 ret_ref |= 1;
18330         }
18331         return ret_ref;
18332 }
18333
18334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18335         LDKDirectionalChannelInfo this_ptr_conv;
18336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18337         this_ptr_conv.is_owned = false;
18338         LDKChannelUpdate val_conv;
18339         val_conv.inner = (void*)(val & (~1));
18340         val_conv.is_owned = (val & 1) || (val == 0);
18341         val_conv = ChannelUpdate_clone(&val_conv);
18342         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
18343 }
18344
18345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18346         LDKDirectionalChannelInfo orig_conv;
18347         orig_conv.inner = (void*)(orig & (~1));
18348         orig_conv.is_owned = false;
18349         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
18350         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18351         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18352         long ret_ref = (long)ret_var.inner;
18353         if (ret_var.is_owned) {
18354                 ret_ref |= 1;
18355         }
18356         return ret_ref;
18357 }
18358
18359 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
18360         LDKDirectionalChannelInfo obj_conv;
18361         obj_conv.inner = (void*)(obj & (~1));
18362         obj_conv.is_owned = false;
18363         LDKCVec_u8Z arg_var = DirectionalChannelInfo_write(&obj_conv);
18364         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
18365         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
18366         CVec_u8Z_free(arg_var);
18367         return arg_arr;
18368 }
18369
18370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18371         LDKu8slice ser_ref;
18372         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18373         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18374         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
18375         *ret_conv = DirectionalChannelInfo_read(ser_ref);
18376         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18377         return (long)ret_conv;
18378 }
18379
18380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18381         LDKChannelInfo this_ptr_conv;
18382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18383         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18384         ChannelInfo_free(this_ptr_conv);
18385 }
18386
18387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18388         LDKChannelInfo this_ptr_conv;
18389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18390         this_ptr_conv.is_owned = false;
18391         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
18392         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18393         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18394         long ret_ref = (long)ret_var.inner;
18395         if (ret_var.is_owned) {
18396                 ret_ref |= 1;
18397         }
18398         return ret_ref;
18399 }
18400
18401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18402         LDKChannelInfo this_ptr_conv;
18403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18404         this_ptr_conv.is_owned = false;
18405         LDKChannelFeatures val_conv;
18406         val_conv.inner = (void*)(val & (~1));
18407         val_conv.is_owned = (val & 1) || (val == 0);
18408         val_conv = ChannelFeatures_clone(&val_conv);
18409         ChannelInfo_set_features(&this_ptr_conv, val_conv);
18410 }
18411
18412 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
18413         LDKChannelInfo this_ptr_conv;
18414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18415         this_ptr_conv.is_owned = false;
18416         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
18417         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
18418         return arg_arr;
18419 }
18420
18421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18422         LDKChannelInfo this_ptr_conv;
18423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18424         this_ptr_conv.is_owned = false;
18425         LDKPublicKey val_ref;
18426         CHECK((*env)->GetArrayLength(env, val) == 33);
18427         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18428         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
18429 }
18430
18431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
18432         LDKChannelInfo this_ptr_conv;
18433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18434         this_ptr_conv.is_owned = false;
18435         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
18436         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18437         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18438         long ret_ref = (long)ret_var.inner;
18439         if (ret_var.is_owned) {
18440                 ret_ref |= 1;
18441         }
18442         return ret_ref;
18443 }
18444
18445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18446         LDKChannelInfo this_ptr_conv;
18447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18448         this_ptr_conv.is_owned = false;
18449         LDKDirectionalChannelInfo val_conv;
18450         val_conv.inner = (void*)(val & (~1));
18451         val_conv.is_owned = (val & 1) || (val == 0);
18452         val_conv = DirectionalChannelInfo_clone(&val_conv);
18453         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
18454 }
18455
18456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
18457         LDKChannelInfo this_ptr_conv;
18458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18459         this_ptr_conv.is_owned = false;
18460         int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
18461         (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
18462         return arg_arr;
18463 }
18464
18465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18466         LDKChannelInfo this_ptr_conv;
18467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18468         this_ptr_conv.is_owned = false;
18469         LDKPublicKey val_ref;
18470         CHECK((*env)->GetArrayLength(env, val) == 33);
18471         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18472         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
18473 }
18474
18475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
18476         LDKChannelInfo this_ptr_conv;
18477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18478         this_ptr_conv.is_owned = false;
18479         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
18480         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18481         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18482         long ret_ref = (long)ret_var.inner;
18483         if (ret_var.is_owned) {
18484                 ret_ref |= 1;
18485         }
18486         return ret_ref;
18487 }
18488
18489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18490         LDKChannelInfo this_ptr_conv;
18491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18492         this_ptr_conv.is_owned = false;
18493         LDKDirectionalChannelInfo val_conv;
18494         val_conv.inner = (void*)(val & (~1));
18495         val_conv.is_owned = (val & 1) || (val == 0);
18496         val_conv = DirectionalChannelInfo_clone(&val_conv);
18497         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
18498 }
18499
18500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
18501         LDKChannelInfo this_ptr_conv;
18502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18503         this_ptr_conv.is_owned = false;
18504         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
18505         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18506         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18507         long ret_ref = (long)ret_var.inner;
18508         if (ret_var.is_owned) {
18509                 ret_ref |= 1;
18510         }
18511         return ret_ref;
18512 }
18513
18514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18515         LDKChannelInfo this_ptr_conv;
18516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18517         this_ptr_conv.is_owned = false;
18518         LDKChannelAnnouncement val_conv;
18519         val_conv.inner = (void*)(val & (~1));
18520         val_conv.is_owned = (val & 1) || (val == 0);
18521         val_conv = ChannelAnnouncement_clone(&val_conv);
18522         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
18523 }
18524
18525 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
18526         LDKChannelInfo obj_conv;
18527         obj_conv.inner = (void*)(obj & (~1));
18528         obj_conv.is_owned = false;
18529         LDKCVec_u8Z arg_var = ChannelInfo_write(&obj_conv);
18530         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
18531         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
18532         CVec_u8Z_free(arg_var);
18533         return arg_arr;
18534 }
18535
18536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18537         LDKu8slice ser_ref;
18538         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18539         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18540         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18541         *ret_conv = ChannelInfo_read(ser_ref);
18542         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18543         return (long)ret_conv;
18544 }
18545
18546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18547         LDKRoutingFees this_ptr_conv;
18548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18549         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18550         RoutingFees_free(this_ptr_conv);
18551 }
18552
18553 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18554         LDKRoutingFees this_ptr_conv;
18555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18556         this_ptr_conv.is_owned = false;
18557         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
18558         return ret_val;
18559 }
18560
18561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18562         LDKRoutingFees this_ptr_conv;
18563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18564         this_ptr_conv.is_owned = false;
18565         RoutingFees_set_base_msat(&this_ptr_conv, val);
18566 }
18567
18568 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
18569         LDKRoutingFees this_ptr_conv;
18570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18571         this_ptr_conv.is_owned = false;
18572         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
18573         return ret_val;
18574 }
18575
18576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18577         LDKRoutingFees this_ptr_conv;
18578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18579         this_ptr_conv.is_owned = false;
18580         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
18581 }
18582
18583 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) {
18584         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
18585         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18586         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18587         long ret_ref = (long)ret_var.inner;
18588         if (ret_var.is_owned) {
18589                 ret_ref |= 1;
18590         }
18591         return ret_ref;
18592 }
18593
18594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18595         LDKRoutingFees orig_conv;
18596         orig_conv.inner = (void*)(orig & (~1));
18597         orig_conv.is_owned = false;
18598         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
18599         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18600         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18601         long ret_ref = (long)ret_var.inner;
18602         if (ret_var.is_owned) {
18603                 ret_ref |= 1;
18604         }
18605         return ret_ref;
18606 }
18607
18608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18609         LDKu8slice ser_ref;
18610         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18611         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18612         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18613         *ret_conv = RoutingFees_read(ser_ref);
18614         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18615         return (long)ret_conv;
18616 }
18617
18618 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
18619         LDKRoutingFees obj_conv;
18620         obj_conv.inner = (void*)(obj & (~1));
18621         obj_conv.is_owned = false;
18622         LDKCVec_u8Z arg_var = RoutingFees_write(&obj_conv);
18623         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
18624         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
18625         CVec_u8Z_free(arg_var);
18626         return arg_arr;
18627 }
18628
18629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18630         LDKNodeAnnouncementInfo this_ptr_conv;
18631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18632         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18633         NodeAnnouncementInfo_free(this_ptr_conv);
18634 }
18635
18636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18637         LDKNodeAnnouncementInfo this_ptr_conv;
18638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18639         this_ptr_conv.is_owned = false;
18640         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
18641         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18642         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18643         long ret_ref = (long)ret_var.inner;
18644         if (ret_var.is_owned) {
18645                 ret_ref |= 1;
18646         }
18647         return ret_ref;
18648 }
18649
18650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18651         LDKNodeAnnouncementInfo this_ptr_conv;
18652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18653         this_ptr_conv.is_owned = false;
18654         LDKNodeFeatures val_conv;
18655         val_conv.inner = (void*)(val & (~1));
18656         val_conv.is_owned = (val & 1) || (val == 0);
18657         val_conv = NodeFeatures_clone(&val_conv);
18658         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
18659 }
18660
18661 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
18662         LDKNodeAnnouncementInfo this_ptr_conv;
18663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18664         this_ptr_conv.is_owned = false;
18665         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
18666         return ret_val;
18667 }
18668
18669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18670         LDKNodeAnnouncementInfo this_ptr_conv;
18671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18672         this_ptr_conv.is_owned = false;
18673         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
18674 }
18675
18676 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
18677         LDKNodeAnnouncementInfo this_ptr_conv;
18678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18679         this_ptr_conv.is_owned = false;
18680         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
18681         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
18682         return ret_arr;
18683 }
18684
18685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18686         LDKNodeAnnouncementInfo this_ptr_conv;
18687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18688         this_ptr_conv.is_owned = false;
18689         LDKThreeBytes val_ref;
18690         CHECK((*env)->GetArrayLength(env, val) == 3);
18691         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
18692         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
18693 }
18694
18695 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
18696         LDKNodeAnnouncementInfo this_ptr_conv;
18697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18698         this_ptr_conv.is_owned = false;
18699         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18700         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
18701         return ret_arr;
18702 }
18703
18704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18705         LDKNodeAnnouncementInfo this_ptr_conv;
18706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18707         this_ptr_conv.is_owned = false;
18708         LDKThirtyTwoBytes val_ref;
18709         CHECK((*env)->GetArrayLength(env, val) == 32);
18710         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18711         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
18712 }
18713
18714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
18715         LDKNodeAnnouncementInfo this_ptr_conv;
18716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18717         this_ptr_conv.is_owned = false;
18718         LDKCVec_NetAddressZ val_constr;
18719         val_constr.datalen = (*env)->GetArrayLength(env, val);
18720         if (val_constr.datalen > 0)
18721                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18722         else
18723                 val_constr.data = NULL;
18724         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
18725         for (size_t m = 0; m < val_constr.datalen; m++) {
18726                 int64_t arr_conv_12 = val_vals[m];
18727                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)(((uint64_t)arr_conv_12) & ~1);
18728                 FREE((void*)arr_conv_12);
18729                 val_constr.data[m] = arr_conv_12_conv;
18730         }
18731         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
18732         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
18733 }
18734
18735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
18736         LDKNodeAnnouncementInfo this_ptr_conv;
18737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18738         this_ptr_conv.is_owned = false;
18739         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
18740         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18741         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18742         long ret_ref = (long)ret_var.inner;
18743         if (ret_var.is_owned) {
18744                 ret_ref |= 1;
18745         }
18746         return ret_ref;
18747 }
18748
18749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18750         LDKNodeAnnouncementInfo this_ptr_conv;
18751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18752         this_ptr_conv.is_owned = false;
18753         LDKNodeAnnouncement val_conv;
18754         val_conv.inner = (void*)(val & (~1));
18755         val_conv.is_owned = (val & 1) || (val == 0);
18756         val_conv = NodeAnnouncement_clone(&val_conv);
18757         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
18758 }
18759
18760 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) {
18761         LDKNodeFeatures features_arg_conv;
18762         features_arg_conv.inner = (void*)(features_arg & (~1));
18763         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
18764         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
18765         LDKThreeBytes rgb_arg_ref;
18766         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
18767         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
18768         LDKThirtyTwoBytes alias_arg_ref;
18769         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
18770         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
18771         LDKCVec_NetAddressZ addresses_arg_constr;
18772         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
18773         if (addresses_arg_constr.datalen > 0)
18774                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18775         else
18776                 addresses_arg_constr.data = NULL;
18777         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
18778         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
18779                 int64_t arr_conv_12 = addresses_arg_vals[m];
18780                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)(((uint64_t)arr_conv_12) & ~1);
18781                 FREE((void*)arr_conv_12);
18782                 addresses_arg_constr.data[m] = arr_conv_12_conv;
18783         }
18784         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
18785         LDKNodeAnnouncement announcement_message_arg_conv;
18786         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
18787         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
18788         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
18789         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
18790         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18791         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18792         long ret_ref = (long)ret_var.inner;
18793         if (ret_var.is_owned) {
18794                 ret_ref |= 1;
18795         }
18796         return ret_ref;
18797 }
18798
18799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18800         LDKNodeAnnouncementInfo orig_conv;
18801         orig_conv.inner = (void*)(orig & (~1));
18802         orig_conv.is_owned = false;
18803         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
18804         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18805         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18806         long ret_ref = (long)ret_var.inner;
18807         if (ret_var.is_owned) {
18808                 ret_ref |= 1;
18809         }
18810         return ret_ref;
18811 }
18812
18813 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
18814         LDKNodeAnnouncementInfo obj_conv;
18815         obj_conv.inner = (void*)(obj & (~1));
18816         obj_conv.is_owned = false;
18817         LDKCVec_u8Z arg_var = NodeAnnouncementInfo_write(&obj_conv);
18818         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
18819         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
18820         CVec_u8Z_free(arg_var);
18821         return arg_arr;
18822 }
18823
18824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18825         LDKu8slice ser_ref;
18826         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18827         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18828         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18829         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
18830         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18831         return (long)ret_conv;
18832 }
18833
18834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18835         LDKNodeInfo this_ptr_conv;
18836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18837         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18838         NodeInfo_free(this_ptr_conv);
18839 }
18840
18841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
18842         LDKNodeInfo this_ptr_conv;
18843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18844         this_ptr_conv.is_owned = false;
18845         LDKCVec_u64Z val_constr;
18846         val_constr.datalen = (*env)->GetArrayLength(env, val);
18847         if (val_constr.datalen > 0)
18848                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
18849         else
18850                 val_constr.data = NULL;
18851         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
18852         for (size_t g = 0; g < val_constr.datalen; g++) {
18853                 int64_t arr_conv_6 = val_vals[g];
18854                 val_constr.data[g] = arr_conv_6;
18855         }
18856         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
18857         NodeInfo_set_channels(&this_ptr_conv, val_constr);
18858 }
18859
18860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
18861         LDKNodeInfo this_ptr_conv;
18862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18863         this_ptr_conv.is_owned = false;
18864         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
18865         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18866         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18867         long ret_ref = (long)ret_var.inner;
18868         if (ret_var.is_owned) {
18869                 ret_ref |= 1;
18870         }
18871         return ret_ref;
18872 }
18873
18874 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) {
18875         LDKNodeInfo this_ptr_conv;
18876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18877         this_ptr_conv.is_owned = false;
18878         LDKRoutingFees val_conv;
18879         val_conv.inner = (void*)(val & (~1));
18880         val_conv.is_owned = (val & 1) || (val == 0);
18881         val_conv = RoutingFees_clone(&val_conv);
18882         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
18883 }
18884
18885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
18886         LDKNodeInfo this_ptr_conv;
18887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18888         this_ptr_conv.is_owned = false;
18889         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
18890         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18891         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18892         long ret_ref = (long)ret_var.inner;
18893         if (ret_var.is_owned) {
18894                 ret_ref |= 1;
18895         }
18896         return ret_ref;
18897 }
18898
18899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18900         LDKNodeInfo this_ptr_conv;
18901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18902         this_ptr_conv.is_owned = false;
18903         LDKNodeAnnouncementInfo val_conv;
18904         val_conv.inner = (void*)(val & (~1));
18905         val_conv.is_owned = (val & 1) || (val == 0);
18906         val_conv = NodeAnnouncementInfo_clone(&val_conv);
18907         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
18908 }
18909
18910 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) {
18911         LDKCVec_u64Z channels_arg_constr;
18912         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
18913         if (channels_arg_constr.datalen > 0)
18914                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
18915         else
18916                 channels_arg_constr.data = NULL;
18917         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
18918         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
18919                 int64_t arr_conv_6 = channels_arg_vals[g];
18920                 channels_arg_constr.data[g] = arr_conv_6;
18921         }
18922         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
18923         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
18924         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
18925         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
18926         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
18927         LDKNodeAnnouncementInfo announcement_info_arg_conv;
18928         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
18929         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
18930         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
18931         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
18932         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18933         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18934         long ret_ref = (long)ret_var.inner;
18935         if (ret_var.is_owned) {
18936                 ret_ref |= 1;
18937         }
18938         return ret_ref;
18939 }
18940
18941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18942         LDKNodeInfo orig_conv;
18943         orig_conv.inner = (void*)(orig & (~1));
18944         orig_conv.is_owned = false;
18945         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
18946         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18947         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18948         long ret_ref = (long)ret_var.inner;
18949         if (ret_var.is_owned) {
18950                 ret_ref |= 1;
18951         }
18952         return ret_ref;
18953 }
18954
18955 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
18956         LDKNodeInfo obj_conv;
18957         obj_conv.inner = (void*)(obj & (~1));
18958         obj_conv.is_owned = false;
18959         LDKCVec_u8Z arg_var = NodeInfo_write(&obj_conv);
18960         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
18961         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
18962         CVec_u8Z_free(arg_var);
18963         return arg_arr;
18964 }
18965
18966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18967         LDKu8slice ser_ref;
18968         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18969         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18970         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18971         *ret_conv = NodeInfo_read(ser_ref);
18972         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18973         return (long)ret_conv;
18974 }
18975
18976 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
18977         LDKNetworkGraph obj_conv;
18978         obj_conv.inner = (void*)(obj & (~1));
18979         obj_conv.is_owned = false;
18980         LDKCVec_u8Z arg_var = NetworkGraph_write(&obj_conv);
18981         int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
18982         (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
18983         CVec_u8Z_free(arg_var);
18984         return arg_arr;
18985 }
18986
18987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18988         LDKu8slice ser_ref;
18989         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18990         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18991         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18992         *ret_conv = NetworkGraph_read(ser_ref);
18993         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18994         return (long)ret_conv;
18995 }
18996
18997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
18998         LDKThirtyTwoBytes genesis_hash_ref;
18999         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
19000         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
19001         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
19002         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19003         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19004         long ret_ref = (long)ret_var.inner;
19005         if (ret_var.is_owned) {
19006                 ret_ref |= 1;
19007         }
19008         return ret_ref;
19009 }
19010
19011 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) {
19012         LDKNetworkGraph this_arg_conv;
19013         this_arg_conv.inner = (void*)(this_arg & (~1));
19014         this_arg_conv.is_owned = false;
19015         LDKNodeAnnouncement msg_conv;
19016         msg_conv.inner = (void*)(msg & (~1));
19017         msg_conv.is_owned = false;
19018         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19019         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
19020         return (long)ret_conv;
19021 }
19022
19023 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) {
19024         LDKNetworkGraph this_arg_conv;
19025         this_arg_conv.inner = (void*)(this_arg & (~1));
19026         this_arg_conv.is_owned = false;
19027         LDKUnsignedNodeAnnouncement msg_conv;
19028         msg_conv.inner = (void*)(msg & (~1));
19029         msg_conv.is_owned = false;
19030         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19031         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
19032         return (long)ret_conv;
19033 }
19034
19035 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) {
19036         LDKNetworkGraph this_arg_conv;
19037         this_arg_conv.inner = (void*)(this_arg & (~1));
19038         this_arg_conv.is_owned = false;
19039         LDKChannelAnnouncement msg_conv;
19040         msg_conv.inner = (void*)(msg & (~1));
19041         msg_conv.is_owned = false;
19042         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
19043         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19044         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
19045         return (long)ret_conv;
19046 }
19047
19048 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) {
19049         LDKNetworkGraph this_arg_conv;
19050         this_arg_conv.inner = (void*)(this_arg & (~1));
19051         this_arg_conv.is_owned = false;
19052         LDKUnsignedChannelAnnouncement msg_conv;
19053         msg_conv.inner = (void*)(msg & (~1));
19054         msg_conv.is_owned = false;
19055         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
19056         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19057         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
19058         return (long)ret_conv;
19059 }
19060
19061 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) {
19062         LDKNetworkGraph this_arg_conv;
19063         this_arg_conv.inner = (void*)(this_arg & (~1));
19064         this_arg_conv.is_owned = false;
19065         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
19066 }
19067
19068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
19069         LDKNetworkGraph this_arg_conv;
19070         this_arg_conv.inner = (void*)(this_arg & (~1));
19071         this_arg_conv.is_owned = false;
19072         LDKChannelUpdate msg_conv;
19073         msg_conv.inner = (void*)(msg & (~1));
19074         msg_conv.is_owned = false;
19075         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19076         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
19077         return (long)ret_conv;
19078 }
19079
19080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
19081         LDKNetworkGraph this_arg_conv;
19082         this_arg_conv.inner = (void*)(this_arg & (~1));
19083         this_arg_conv.is_owned = false;
19084         LDKUnsignedChannelUpdate msg_conv;
19085         msg_conv.inner = (void*)(msg & (~1));
19086         msg_conv.is_owned = false;
19087         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19088         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
19089         return (long)ret_conv;
19090 }
19091