5c05a42260f83dc1405d74f95cc6983375761c3f
[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                 case 3: return LDKNetwork_Signet;
274         }
275         abort();
276 }
277 static jclass LDKNetwork_class = NULL;
278 static jfieldID LDKNetwork_LDKNetwork_Bitcoin = NULL;
279 static jfieldID LDKNetwork_LDKNetwork_Testnet = NULL;
280 static jfieldID LDKNetwork_LDKNetwork_Regtest = NULL;
281 static jfieldID LDKNetwork_LDKNetwork_Signet = NULL;
282 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKNetwork_init (JNIEnv *env, jclass clz) {
283         LDKNetwork_class = (*env)->NewGlobalRef(env, clz);
284         CHECK(LDKNetwork_class != NULL);
285         LDKNetwork_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/LDKNetwork;");
286         CHECK(LDKNetwork_LDKNetwork_Bitcoin != NULL);
287         LDKNetwork_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/LDKNetwork;");
288         CHECK(LDKNetwork_LDKNetwork_Testnet != NULL);
289         LDKNetwork_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/LDKNetwork;");
290         CHECK(LDKNetwork_LDKNetwork_Regtest != NULL);
291         LDKNetwork_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Signet", "Lorg/ldk/enums/LDKNetwork;");
292         CHECK(LDKNetwork_LDKNetwork_Signet != NULL);
293 }
294 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
295         switch (val) {
296                 case LDKNetwork_Bitcoin:
297                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Bitcoin);
298                 case LDKNetwork_Testnet:
299                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Testnet);
300                 case LDKNetwork_Regtest:
301                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Regtest);
302                 case LDKNetwork_Signet:
303                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Signet);
304                 default: abort();
305         }
306 }
307
308 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
309         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
310                 case 0: return LDKSecp256k1Error_IncorrectSignature;
311                 case 1: return LDKSecp256k1Error_InvalidMessage;
312                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
313                 case 3: return LDKSecp256k1Error_InvalidSignature;
314                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
315                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
316                 case 6: return LDKSecp256k1Error_InvalidTweak;
317                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
318                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
319         }
320         abort();
321 }
322 static jclass LDKSecp256k1Error_class = NULL;
323 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
324 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
325 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
326 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
327 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
328 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
329 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
330 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
331 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
332 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKSecp256k1Error_init (JNIEnv *env, jclass clz) {
333         LDKSecp256k1Error_class = (*env)->NewGlobalRef(env, clz);
334         CHECK(LDKSecp256k1Error_class != NULL);
335         LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
336         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
337         LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/LDKSecp256k1Error;");
338         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
339         LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
340         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
341         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
342         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
343         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
344         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
345         LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/LDKSecp256k1Error;");
346         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
347         LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/LDKSecp256k1Error;");
348         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
349         LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/LDKSecp256k1Error;");
350         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
351         LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/LDKSecp256k1Error;");
352         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
353 }
354 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
355         switch (val) {
356                 case LDKSecp256k1Error_IncorrectSignature:
357                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature);
358                 case LDKSecp256k1Error_InvalidMessage:
359                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage);
360                 case LDKSecp256k1Error_InvalidPublicKey:
361                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
362                 case LDKSecp256k1Error_InvalidSignature:
363                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature);
364                 case LDKSecp256k1Error_InvalidSecretKey:
365                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
366                 case LDKSecp256k1Error_InvalidRecoveryId:
367                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
368                 case LDKSecp256k1Error_InvalidTweak:
369                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak);
370                 case LDKSecp256k1Error_TweakCheckFailed:
371                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
372                 case LDKSecp256k1Error_NotEnoughMemory:
373                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
374                 default: abort();
375         }
376 }
377
378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
379         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
380         ret->datalen = (*env)->GetArrayLength(env, elems);
381         if (ret->datalen == 0) {
382                 ret->data = NULL;
383         } else {
384                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
385                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
386                 for (size_t i = 0; i < ret->datalen; i++) {
387                         ret->data[i] = java_elems[i];
388                 }
389                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
390         }
391         return (long)ret;
392 }
393 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
394         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
395         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
396         return ret;
397 }
398 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
399         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
400 }
401 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
402         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
403         CHECK(val->result_ok);
404         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
405         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
406         return res_arr;
407 }
408 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
409         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
410         CHECK(!val->result_ok);
411         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
412         return err_conv;
413 }
414 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
415         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
416 }
417 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
418         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
419         CHECK(val->result_ok);
420         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
421         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
422         return res_arr;
423 }
424 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
425         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
426         CHECK(!val->result_ok);
427         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
428         return err_conv;
429 }
430 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
431         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
432 }
433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
434         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
435         CHECK(val->result_ok);
436         LDKTxCreationKeys res_var = (*val->contents.result);
437         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
438         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
439         long res_ref = (long)res_var.inner & ~1;
440         return res_ref;
441 }
442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
443         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
444         CHECK(!val->result_ok);
445         LDKDecodeError err_var = (*val->contents.err);
446         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
447         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
448         long err_ref = (long)err_var.inner & ~1;
449         return err_ref;
450 }
451 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
452         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
453 }
454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
455         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
456         CHECK(val->result_ok);
457         LDKChannelPublicKeys res_var = (*val->contents.result);
458         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
459         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
460         long res_ref = (long)res_var.inner & ~1;
461         return res_ref;
462 }
463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
464         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
465         CHECK(!val->result_ok);
466         LDKDecodeError err_var = (*val->contents.err);
467         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
468         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
469         long err_ref = (long)err_var.inner & ~1;
470         return err_ref;
471 }
472 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
473         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
474 }
475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
476         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
477         CHECK(val->result_ok);
478         LDKTxCreationKeys res_var = (*val->contents.result);
479         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
480         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
481         long res_ref = (long)res_var.inner & ~1;
482         return res_ref;
483 }
484 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
485         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
486         CHECK(!val->result_ok);
487         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
488         return err_conv;
489 }
490 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
491         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
492 }
493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
494         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
495         CHECK(val->result_ok);
496         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
497         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
498         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
499         long res_ref = (long)res_var.inner & ~1;
500         return res_ref;
501 }
502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
503         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
504         CHECK(!val->result_ok);
505         LDKDecodeError err_var = (*val->contents.err);
506         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
507         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
508         long err_ref = (long)err_var.inner & ~1;
509         return err_ref;
510 }
511 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
512         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
513 }
514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
515         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
516         CHECK(val->result_ok);
517         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
518         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
519         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
520         long res_ref = (long)res_var.inner & ~1;
521         return res_ref;
522 }
523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
524         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
525         CHECK(!val->result_ok);
526         LDKDecodeError err_var = (*val->contents.err);
527         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
528         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
529         long err_ref = (long)err_var.inner & ~1;
530         return err_ref;
531 }
532 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
533         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
534 }
535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
536         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
537         CHECK(val->result_ok);
538         LDKChannelTransactionParameters res_var = (*val->contents.result);
539         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
540         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
541         long res_ref = (long)res_var.inner & ~1;
542         return res_ref;
543 }
544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
545         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
546         CHECK(!val->result_ok);
547         LDKDecodeError err_var = (*val->contents.err);
548         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
549         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
550         long err_ref = (long)err_var.inner & ~1;
551         return err_ref;
552 }
553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
554         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
555 }
556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
557         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
558         CHECK(val->result_ok);
559         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
560         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
561         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
562         long res_ref = (long)res_var.inner & ~1;
563         return res_ref;
564 }
565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
566         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
567         CHECK(!val->result_ok);
568         LDKDecodeError err_var = (*val->contents.err);
569         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
570         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
571         long err_ref = (long)err_var.inner & ~1;
572         return err_ref;
573 }
574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
575         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
576 }
577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
578         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
579         CHECK(val->result_ok);
580         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
581         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
582         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
583         long res_ref = (long)res_var.inner & ~1;
584         return res_ref;
585 }
586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
587         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
588         CHECK(!val->result_ok);
589         LDKDecodeError err_var = (*val->contents.err);
590         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
591         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
592         long err_ref = (long)err_var.inner & ~1;
593         return err_ref;
594 }
595 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
596         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
597 }
598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
599         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
600         CHECK(val->result_ok);
601         LDKCommitmentTransaction res_var = (*val->contents.result);
602         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
603         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
604         long res_ref = (long)res_var.inner & ~1;
605         return res_ref;
606 }
607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
608         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
609         CHECK(!val->result_ok);
610         LDKDecodeError err_var = (*val->contents.err);
611         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
612         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
613         long err_ref = (long)err_var.inner & ~1;
614         return err_ref;
615 }
616 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
617         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
618 }
619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
620         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
621         CHECK(val->result_ok);
622         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
623         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
624         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
625         long res_ref = (long)res_var.inner & ~1;
626         return res_ref;
627 }
628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
629         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
630         CHECK(!val->result_ok);
631         return *val->contents.err;
632 }
633 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
634         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
635 }
636 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
637         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
638         CHECK(val->result_ok);
639         LDKCVec_SignatureZ res_var = (*val->contents.result);
640         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
641         ;
642         for (size_t i = 0; i < res_var.datalen; i++) {
643                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
644                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
645                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
646         }
647         return res_arr;
648 }
649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
650         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
651         CHECK(!val->result_ok);
652         return *val->contents.err;
653 }
654 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
655 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
656 static jclass LDKErrorAction_IgnoreError_class = NULL;
657 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
658 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
659 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
661         LDKErrorAction_DisconnectPeer_class =
662                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
663         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
664         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
665         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
666         LDKErrorAction_IgnoreError_class =
667                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
668         CHECK(LDKErrorAction_IgnoreError_class != NULL);
669         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
670         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
671         LDKErrorAction_SendErrorMessage_class =
672                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
673         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
674         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
675         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
676 }
677 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
678         LDKErrorAction *obj = (LDKErrorAction*)ptr;
679         switch(obj->tag) {
680                 case LDKErrorAction_DisconnectPeer: {
681                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
682                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
683                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
684                         long msg_ref = (long)msg_var.inner & ~1;
685                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
686                 }
687                 case LDKErrorAction_IgnoreError: {
688                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
689                 }
690                 case LDKErrorAction_SendErrorMessage: {
691                         LDKErrorMessage msg_var = obj->send_error_message.msg;
692                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
693                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
694                         long msg_ref = (long)msg_var.inner & ~1;
695                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
696                 }
697                 default: abort();
698         }
699 }
700 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
701 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
702 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
703 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
704 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
705 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
707         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
708                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
709         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
710         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
711         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
712         LDKHTLCFailChannelUpdate_ChannelClosed_class =
713                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
714         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
715         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
716         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
717         LDKHTLCFailChannelUpdate_NodeFailure_class =
718                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
719         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
720         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
721         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
722 }
723 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
724         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
725         switch(obj->tag) {
726                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
727                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
728                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
729                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
730                         long msg_ref = (long)msg_var.inner & ~1;
731                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
732                 }
733                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
734                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
735                 }
736                 case LDKHTLCFailChannelUpdate_NodeFailure: {
737                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
738                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
739                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
740                 }
741                 default: abort();
742         }
743 }
744 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
745 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
746 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
747 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
748 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
749 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
750 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
751 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
752 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
753 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
754 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
755 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
756 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
757 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
758 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
759 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
760 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
761 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
762 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
763 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
764 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
765 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
766 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
767 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
768 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
769 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
770 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
771 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
772 static jclass LDKMessageSendEvent_HandleError_class = NULL;
773 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
774 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
775 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
776 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
777 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
778 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
779 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
781         LDKMessageSendEvent_SendAcceptChannel_class =
782                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
783         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
784         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
785         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
786         LDKMessageSendEvent_SendOpenChannel_class =
787                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
788         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
789         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
790         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
791         LDKMessageSendEvent_SendFundingCreated_class =
792                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
793         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
794         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
795         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
796         LDKMessageSendEvent_SendFundingSigned_class =
797                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
798         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
799         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
800         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
801         LDKMessageSendEvent_SendFundingLocked_class =
802                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
803         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
804         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
805         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
806         LDKMessageSendEvent_SendAnnouncementSignatures_class =
807                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
808         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
809         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
810         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
811         LDKMessageSendEvent_UpdateHTLCs_class =
812                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
813         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
814         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
815         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
816         LDKMessageSendEvent_SendRevokeAndACK_class =
817                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
818         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
819         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
820         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
821         LDKMessageSendEvent_SendClosingSigned_class =
822                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
823         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
824         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
825         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
826         LDKMessageSendEvent_SendShutdown_class =
827                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
828         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
829         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
830         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
831         LDKMessageSendEvent_SendChannelReestablish_class =
832                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
833         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
834         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
835         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
836         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
837                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
838         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
839         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
840         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
841         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
842                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
843         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
844         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
845         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
846         LDKMessageSendEvent_BroadcastChannelUpdate_class =
847                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
848         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
849         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
850         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
851         LDKMessageSendEvent_HandleError_class =
852                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
853         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
854         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
855         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
856         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
857                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
858         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
859         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
860         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
861         LDKMessageSendEvent_SendChannelRangeQuery_class =
862                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
863         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
864         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
865         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
866         LDKMessageSendEvent_SendShortIdsQuery_class =
867                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
868         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
869         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
870         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
871 }
872 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
873         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
874         switch(obj->tag) {
875                 case LDKMessageSendEvent_SendAcceptChannel: {
876                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
877                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
878                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
879                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
880                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
881                         long msg_ref = (long)msg_var.inner & ~1;
882                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
883                 }
884                 case LDKMessageSendEvent_SendOpenChannel: {
885                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
886                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
887                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
888                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
889                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
890                         long msg_ref = (long)msg_var.inner & ~1;
891                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
892                 }
893                 case LDKMessageSendEvent_SendFundingCreated: {
894                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
895                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
896                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
897                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
898                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
899                         long msg_ref = (long)msg_var.inner & ~1;
900                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
901                 }
902                 case LDKMessageSendEvent_SendFundingSigned: {
903                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
904                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
905                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
906                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
907                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
908                         long msg_ref = (long)msg_var.inner & ~1;
909                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
910                 }
911                 case LDKMessageSendEvent_SendFundingLocked: {
912                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
913                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
914                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
915                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
916                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
917                         long msg_ref = (long)msg_var.inner & ~1;
918                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
919                 }
920                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
921                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
922                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
923                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
924                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
925                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
926                         long msg_ref = (long)msg_var.inner & ~1;
927                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
928                 }
929                 case LDKMessageSendEvent_UpdateHTLCs: {
930                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
931                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
932                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
933                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
934                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
935                         long updates_ref = (long)updates_var.inner & ~1;
936                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
937                 }
938                 case LDKMessageSendEvent_SendRevokeAndACK: {
939                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
940                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
941                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
942                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
943                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
944                         long msg_ref = (long)msg_var.inner & ~1;
945                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
946                 }
947                 case LDKMessageSendEvent_SendClosingSigned: {
948                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
949                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
950                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
951                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
952                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
953                         long msg_ref = (long)msg_var.inner & ~1;
954                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
955                 }
956                 case LDKMessageSendEvent_SendShutdown: {
957                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
958                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
959                         LDKShutdown msg_var = obj->send_shutdown.msg;
960                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
961                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
962                         long msg_ref = (long)msg_var.inner & ~1;
963                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
964                 }
965                 case LDKMessageSendEvent_SendChannelReestablish: {
966                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
967                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
968                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
969                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
970                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
971                         long msg_ref = (long)msg_var.inner & ~1;
972                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
973                 }
974                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
975                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
976                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
977                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
978                         long msg_ref = (long)msg_var.inner & ~1;
979                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
980                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
981                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
982                         long update_msg_ref = (long)update_msg_var.inner & ~1;
983                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
984                 }
985                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
986                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
987                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
988                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
989                         long msg_ref = (long)msg_var.inner & ~1;
990                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
991                 }
992                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
993                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
994                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
995                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
996                         long msg_ref = (long)msg_var.inner & ~1;
997                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
998                 }
999                 case LDKMessageSendEvent_HandleError: {
1000                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1001                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1002                         long action_ref = ((long)&obj->handle_error.action) | 1;
1003                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1004                 }
1005                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1006                         long update_ref = ((long)&obj->payment_failure_network_update.update) | 1;
1007                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1008                 }
1009                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1010                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1011                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1012                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1013                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1014                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1015                         long msg_ref = (long)msg_var.inner & ~1;
1016                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1017                 }
1018                 case LDKMessageSendEvent_SendShortIdsQuery: {
1019                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1020                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1021                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1022                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1023                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1024                         long msg_ref = (long)msg_var.inner & ~1;
1025                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1026                 }
1027                 default: abort();
1028         }
1029 }
1030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1031         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1032         ret->datalen = (*env)->GetArrayLength(env, elems);
1033         if (ret->datalen == 0) {
1034                 ret->data = NULL;
1035         } else {
1036                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1037                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1038                 for (size_t i = 0; i < ret->datalen; i++) {
1039                         int64_t arr_elem = java_elems[i];
1040                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1041                         FREE((void*)arr_elem);
1042                         ret->data[i] = arr_elem_conv;
1043                 }
1044                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1045         }
1046         return (long)ret;
1047 }
1048 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1049         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1050         for (size_t i = 0; i < ret.datalen; i++) {
1051                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1052         }
1053         return ret;
1054 }
1055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1056         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
1057 }
1058 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1059         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
1060         CHECK(val->result_ok);
1061         return *val->contents.result;
1062 }
1063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1064         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
1065         CHECK(!val->result_ok);
1066         LDKLightningError err_var = (*val->contents.err);
1067         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1068         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1069         long err_ref = (long)err_var.inner & ~1;
1070         return err_ref;
1071 }
1072 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) {
1073         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
1074         LDKChannelAnnouncement a_conv;
1075         a_conv.inner = (void*)(a & (~1));
1076         a_conv.is_owned = (a & 1) || (a == 0);
1077         a_conv = ChannelAnnouncement_clone(&a_conv);
1078         ret->a = a_conv;
1079         LDKChannelUpdate b_conv;
1080         b_conv.inner = (void*)(b & (~1));
1081         b_conv.is_owned = (b & 1) || (b == 0);
1082         b_conv = ChannelUpdate_clone(&b_conv);
1083         ret->b = b_conv;
1084         LDKChannelUpdate c_conv;
1085         c_conv.inner = (void*)(c & (~1));
1086         c_conv.is_owned = (c & 1) || (c == 0);
1087         c_conv = ChannelUpdate_clone(&c_conv);
1088         ret->c = c_conv;
1089         return (long)ret;
1090 }
1091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1092         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
1093         LDKChannelAnnouncement a_var = tuple->a;
1094         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1095         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1096         long a_ref = (long)a_var.inner & ~1;
1097         return a_ref;
1098 }
1099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1100         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
1101         LDKChannelUpdate b_var = tuple->b;
1102         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1103         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1104         long b_ref = (long)b_var.inner & ~1;
1105         return b_ref;
1106 }
1107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
1108         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
1109         LDKChannelUpdate c_var = tuple->c;
1110         CHECK((((long)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1111         CHECK((((long)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1112         long c_ref = (long)c_var.inner & ~1;
1113         return c_ref;
1114 }
1115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1116         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
1117         ret->datalen = (*env)->GetArrayLength(env, elems);
1118         if (ret->datalen == 0) {
1119                 ret->data = NULL;
1120         } else {
1121                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
1122                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1123                 for (size_t i = 0; i < ret->datalen; i++) {
1124                         int64_t arr_elem = java_elems[i];
1125                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
1126                         FREE((void*)arr_elem);
1127                         ret->data[i] = arr_elem_conv;
1128                 }
1129                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1130         }
1131         return (long)ret;
1132 }
1133 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
1134         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
1135         for (size_t i = 0; i < ret.datalen; i++) {
1136                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
1137         }
1138         return ret;
1139 }
1140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1141         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
1142         ret->datalen = (*env)->GetArrayLength(env, elems);
1143         if (ret->datalen == 0) {
1144                 ret->data = NULL;
1145         } else {
1146                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
1147                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1148                 for (size_t i = 0; i < ret->datalen; i++) {
1149                         int64_t arr_elem = java_elems[i];
1150                         LDKNodeAnnouncement arr_elem_conv;
1151                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1152                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1153                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
1154                         ret->data[i] = arr_elem_conv;
1155                 }
1156                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1157         }
1158         return (long)ret;
1159 }
1160 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
1161         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
1162         for (size_t i = 0; i < ret.datalen; i++) {
1163                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
1164         }
1165         return ret;
1166 }
1167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1168         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
1169 }
1170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1171         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
1172         CHECK(val->result_ok);
1173         return *val->contents.result;
1174 }
1175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1176         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
1177         CHECK(!val->result_ok);
1178         LDKLightningError err_var = (*val->contents.err);
1179         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1180         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1181         long err_ref = (long)err_var.inner & ~1;
1182         return err_ref;
1183 }
1184 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1185         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
1186 }
1187 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1188         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
1189         CHECK(val->result_ok);
1190         LDKCVec_u8Z res_var = (*val->contents.result);
1191         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
1192         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
1193         return res_arr;
1194 }
1195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1196         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
1197         CHECK(!val->result_ok);
1198         LDKPeerHandleError err_var = (*val->contents.err);
1199         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1200         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1201         long err_ref = (long)err_var.inner & ~1;
1202         return err_ref;
1203 }
1204 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1205         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
1206 }
1207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1208         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
1209         CHECK(val->result_ok);
1210         return *val->contents.result;
1211 }
1212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1213         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
1214         CHECK(!val->result_ok);
1215         LDKPeerHandleError err_var = (*val->contents.err);
1216         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1217         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1218         long err_ref = (long)err_var.inner & ~1;
1219         return err_ref;
1220 }
1221 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1222         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
1223 }
1224 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1225         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
1226         CHECK(val->result_ok);
1227         return *val->contents.result;
1228 }
1229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1230         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
1231         CHECK(!val->result_ok);
1232         LDKPeerHandleError err_var = (*val->contents.err);
1233         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1234         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1235         long err_ref = (long)err_var.inner & ~1;
1236         return err_ref;
1237 }
1238 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1239         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1240 }
1241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1242         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1243         CHECK(val->result_ok);
1244         LDKInitFeatures res_var = (*val->contents.result);
1245         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1246         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1247         long res_ref = (long)res_var.inner & ~1;
1248         return res_ref;
1249 }
1250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1251         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1252         CHECK(!val->result_ok);
1253         LDKDecodeError err_var = (*val->contents.err);
1254         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1255         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1256         long err_ref = (long)err_var.inner & ~1;
1257         return err_ref;
1258 }
1259 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1260         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1261 }
1262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1263         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1264         CHECK(val->result_ok);
1265         LDKNodeFeatures res_var = (*val->contents.result);
1266         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1267         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1268         long res_ref = (long)res_var.inner & ~1;
1269         return res_ref;
1270 }
1271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1272         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1273         CHECK(!val->result_ok);
1274         LDKDecodeError err_var = (*val->contents.err);
1275         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1276         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1277         long err_ref = (long)err_var.inner & ~1;
1278         return err_ref;
1279 }
1280 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1281         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1282 }
1283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1284         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1285         CHECK(val->result_ok);
1286         LDKChannelFeatures res_var = (*val->contents.result);
1287         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1288         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1289         long res_ref = (long)res_var.inner & ~1;
1290         return res_ref;
1291 }
1292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1293         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1294         CHECK(!val->result_ok);
1295         LDKDecodeError err_var = (*val->contents.err);
1296         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1297         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1298         long err_ref = (long)err_var.inner & ~1;
1299         return err_ref;
1300 }
1301 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1302         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
1303 }
1304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1305         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
1306         CHECK(val->result_ok);
1307         LDKChannelConfig res_var = (*val->contents.result);
1308         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1309         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1310         long res_ref = (long)res_var.inner & ~1;
1311         return res_ref;
1312 }
1313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1314         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
1315         CHECK(!val->result_ok);
1316         LDKDecodeError err_var = (*val->contents.err);
1317         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1318         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1319         long err_ref = (long)err_var.inner & ~1;
1320         return err_ref;
1321 }
1322 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1323         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
1324 }
1325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1326         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
1327         CHECK(val->result_ok);
1328         LDKDirectionalChannelInfo res_var = (*val->contents.result);
1329         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1330         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1331         long res_ref = (long)res_var.inner & ~1;
1332         return res_ref;
1333 }
1334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1335         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
1336         CHECK(!val->result_ok);
1337         LDKDecodeError err_var = (*val->contents.err);
1338         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1339         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1340         long err_ref = (long)err_var.inner & ~1;
1341         return err_ref;
1342 }
1343 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1344         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
1345 }
1346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1347         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
1348         CHECK(val->result_ok);
1349         LDKChannelInfo res_var = (*val->contents.result);
1350         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1351         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1352         long res_ref = (long)res_var.inner & ~1;
1353         return res_ref;
1354 }
1355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1356         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
1357         CHECK(!val->result_ok);
1358         LDKDecodeError err_var = (*val->contents.err);
1359         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1360         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1361         long err_ref = (long)err_var.inner & ~1;
1362         return err_ref;
1363 }
1364 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1365         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
1366 }
1367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1368         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
1369         CHECK(val->result_ok);
1370         LDKRoutingFees res_var = (*val->contents.result);
1371         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1372         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1373         long res_ref = (long)res_var.inner & ~1;
1374         return res_ref;
1375 }
1376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1377         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
1378         CHECK(!val->result_ok);
1379         LDKDecodeError err_var = (*val->contents.err);
1380         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1381         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1382         long err_ref = (long)err_var.inner & ~1;
1383         return err_ref;
1384 }
1385 static jclass LDKNetAddress_IPv4_class = NULL;
1386 static jmethodID LDKNetAddress_IPv4_meth = NULL;
1387 static jclass LDKNetAddress_IPv6_class = NULL;
1388 static jmethodID LDKNetAddress_IPv6_meth = NULL;
1389 static jclass LDKNetAddress_OnionV2_class = NULL;
1390 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
1391 static jclass LDKNetAddress_OnionV3_class = NULL;
1392 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
1393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
1394         LDKNetAddress_IPv4_class =
1395                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
1396         CHECK(LDKNetAddress_IPv4_class != NULL);
1397         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
1398         CHECK(LDKNetAddress_IPv4_meth != NULL);
1399         LDKNetAddress_IPv6_class =
1400                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
1401         CHECK(LDKNetAddress_IPv6_class != NULL);
1402         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
1403         CHECK(LDKNetAddress_IPv6_meth != NULL);
1404         LDKNetAddress_OnionV2_class =
1405                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
1406         CHECK(LDKNetAddress_OnionV2_class != NULL);
1407         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
1408         CHECK(LDKNetAddress_OnionV2_meth != NULL);
1409         LDKNetAddress_OnionV3_class =
1410                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
1411         CHECK(LDKNetAddress_OnionV3_class != NULL);
1412         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
1413         CHECK(LDKNetAddress_OnionV3_meth != NULL);
1414 }
1415 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1416         LDKNetAddress *obj = (LDKNetAddress*)ptr;
1417         switch(obj->tag) {
1418                 case LDKNetAddress_IPv4: {
1419                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
1420                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
1421                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
1422                 }
1423                 case LDKNetAddress_IPv6: {
1424                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
1425                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
1426                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
1427                 }
1428                 case LDKNetAddress_OnionV2: {
1429                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
1430                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
1431                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
1432                 }
1433                 case LDKNetAddress_OnionV3: {
1434                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
1435                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
1436                         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);
1437                 }
1438                 default: abort();
1439         }
1440 }
1441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1442         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
1443         ret->datalen = (*env)->GetArrayLength(env, elems);
1444         if (ret->datalen == 0) {
1445                 ret->data = NULL;
1446         } else {
1447                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
1448                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1449                 for (size_t i = 0; i < ret->datalen; i++) {
1450                         int64_t arr_elem = java_elems[i];
1451                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
1452                         FREE((void*)arr_elem);
1453                         ret->data[i] = arr_elem_conv;
1454                 }
1455                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1456         }
1457         return (long)ret;
1458 }
1459 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
1460         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
1461         for (size_t i = 0; i < ret.datalen; i++) {
1462                 ret.data[i] = NetAddress_clone(&orig->data[i]);
1463         }
1464         return ret;
1465 }
1466 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1467         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
1468 }
1469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1470         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
1471         CHECK(val->result_ok);
1472         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
1473         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1474         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1475         long res_ref = (long)res_var.inner & ~1;
1476         return res_ref;
1477 }
1478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1479         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
1480         CHECK(!val->result_ok);
1481         LDKDecodeError err_var = (*val->contents.err);
1482         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1483         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1484         long err_ref = (long)err_var.inner & ~1;
1485         return err_ref;
1486 }
1487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1488         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
1489         ret->datalen = (*env)->GetArrayLength(env, elems);
1490         if (ret->datalen == 0) {
1491                 ret->data = NULL;
1492         } else {
1493                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
1494                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1495                 for (size_t i = 0; i < ret->datalen; i++) {
1496                         ret->data[i] = java_elems[i];
1497                 }
1498                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1499         }
1500         return (long)ret;
1501 }
1502 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1503         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1504         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1505         return ret;
1506 }
1507 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1508         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
1509 }
1510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1511         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
1512         CHECK(val->result_ok);
1513         LDKNodeInfo res_var = (*val->contents.result);
1514         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1515         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1516         long res_ref = (long)res_var.inner & ~1;
1517         return res_ref;
1518 }
1519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1520         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
1521         CHECK(!val->result_ok);
1522         LDKDecodeError err_var = (*val->contents.err);
1523         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1524         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1525         long err_ref = (long)err_var.inner & ~1;
1526         return err_ref;
1527 }
1528 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1529         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
1530 }
1531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1532         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
1533         CHECK(val->result_ok);
1534         LDKNetworkGraph res_var = (*val->contents.result);
1535         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1536         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1537         long res_ref = (long)res_var.inner & ~1;
1538         return res_ref;
1539 }
1540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1541         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
1542         CHECK(!val->result_ok);
1543         LDKDecodeError err_var = (*val->contents.err);
1544         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1545         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1546         long err_ref = (long)err_var.inner & ~1;
1547         return err_ref;
1548 }
1549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1550         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1551         ret->a = a;
1552         LDKTransaction b_ref;
1553         b_ref.datalen = (*env)->GetArrayLength(env, b);
1554         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1555         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1556         b_ref.data_is_owned = false;
1557         ret->b = b_ref;
1558         return (long)ret;
1559 }
1560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1561         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1562         return tuple->a;
1563 }
1564 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1565         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1566         LDKTransaction b_var = tuple->b;
1567         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1568         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1569         return b_arr;
1570 }
1571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1572         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1573         ret->datalen = (*env)->GetArrayLength(env, elems);
1574         if (ret->datalen == 0) {
1575                 ret->data = NULL;
1576         } else {
1577                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1578                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1579                 for (size_t i = 0; i < ret->datalen; i++) {
1580                         int64_t arr_elem = java_elems[i];
1581                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1582                         FREE((void*)arr_elem);
1583                         ret->data[i] = arr_elem_conv;
1584                 }
1585                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1586         }
1587         return (long)ret;
1588 }
1589 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1590         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1591 }
1592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1593         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1594         CHECK(val->result_ok);
1595         return *val->contents.result;
1596 }
1597 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1598         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1599         CHECK(!val->result_ok);
1600         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1601         return err_conv;
1602 }
1603 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1604 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1605 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1606 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1608         LDKMonitorEvent_HTLCEvent_class =
1609                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1610         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1611         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "()V");
1612         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1613         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1614                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1615         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1616         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "()V");
1617         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1618 }
1619 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1620         LDKMonitorEvent *obj = (LDKMonitorEvent*)ptr;
1621         switch(obj->tag) {
1622                 case LDKMonitorEvent_HTLCEvent: {
1623                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth);
1624                 }
1625                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1626                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth);
1627                 }
1628                 default: abort();
1629         }
1630 }
1631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1632         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1633         ret->datalen = (*env)->GetArrayLength(env, elems);
1634         if (ret->datalen == 0) {
1635                 ret->data = NULL;
1636         } else {
1637                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1638                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1639                 for (size_t i = 0; i < ret->datalen; i++) {
1640                         int64_t arr_elem = java_elems[i];
1641                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1642                         FREE((void*)arr_elem);
1643                         ret->data[i] = arr_elem_conv;
1644                 }
1645                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1646         }
1647         return (long)ret;
1648 }
1649 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1650         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1651         for (size_t i = 0; i < ret.datalen; i++) {
1652                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1653         }
1654         return ret;
1655 }
1656 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1657 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1658 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1659 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1660 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1661 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1663         LDKSpendableOutputDescriptor_StaticOutput_class =
1664                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1665         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1666         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1667         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1668         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1669                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1670         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1671         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "()V");
1672         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1673         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1674                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1675         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1676         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "()V");
1677         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1678 }
1679 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1680         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
1681         switch(obj->tag) {
1682                 case LDKSpendableOutputDescriptor_StaticOutput: {
1683                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1684                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1685                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1686                         long outpoint_ref = (long)outpoint_var.inner & ~1;
1687                         long output_ref = ((long)&obj->static_output.output) | 1;
1688                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (long)output_ref);
1689                 }
1690                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1691                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth);
1692                 }
1693                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1694                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth);
1695                 }
1696                 default: abort();
1697         }
1698 }
1699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1700         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1701         ret->datalen = (*env)->GetArrayLength(env, elems);
1702         if (ret->datalen == 0) {
1703                 ret->data = NULL;
1704         } else {
1705                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1706                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1707                 for (size_t i = 0; i < ret->datalen; i++) {
1708                         int64_t arr_elem = java_elems[i];
1709                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1710                         FREE((void*)arr_elem);
1711                         ret->data[i] = arr_elem_conv;
1712                 }
1713                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1714         }
1715         return (long)ret;
1716 }
1717 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1718         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1719         for (size_t i = 0; i < ret.datalen; i++) {
1720                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1721         }
1722         return ret;
1723 }
1724 static jclass LDKEvent_FundingGenerationReady_class = NULL;
1725 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
1726 static jclass LDKEvent_FundingBroadcastSafe_class = NULL;
1727 static jmethodID LDKEvent_FundingBroadcastSafe_meth = NULL;
1728 static jclass LDKEvent_PaymentReceived_class = NULL;
1729 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
1730 static jclass LDKEvent_PaymentSent_class = NULL;
1731 static jmethodID LDKEvent_PaymentSent_meth = NULL;
1732 static jclass LDKEvent_PaymentFailed_class = NULL;
1733 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
1734 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
1735 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
1736 static jclass LDKEvent_SpendableOutputs_class = NULL;
1737 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
1738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
1739         LDKEvent_FundingGenerationReady_class =
1740                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
1741         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
1742         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
1743         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
1744         LDKEvent_FundingBroadcastSafe_class =
1745                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingBroadcastSafe;"));
1746         CHECK(LDKEvent_FundingBroadcastSafe_class != NULL);
1747         LDKEvent_FundingBroadcastSafe_meth = (*env)->GetMethodID(env, LDKEvent_FundingBroadcastSafe_class, "<init>", "(JJ)V");
1748         CHECK(LDKEvent_FundingBroadcastSafe_meth != NULL);
1749         LDKEvent_PaymentReceived_class =
1750                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
1751         CHECK(LDKEvent_PaymentReceived_class != NULL);
1752         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[BJ)V");
1753         CHECK(LDKEvent_PaymentReceived_meth != NULL);
1754         LDKEvent_PaymentSent_class =
1755                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
1756         CHECK(LDKEvent_PaymentSent_class != NULL);
1757         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
1758         CHECK(LDKEvent_PaymentSent_meth != NULL);
1759         LDKEvent_PaymentFailed_class =
1760                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
1761         CHECK(LDKEvent_PaymentFailed_class != NULL);
1762         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
1763         CHECK(LDKEvent_PaymentFailed_meth != NULL);
1764         LDKEvent_PendingHTLCsForwardable_class =
1765                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
1766         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
1767         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
1768         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
1769         LDKEvent_SpendableOutputs_class =
1770                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
1771         CHECK(LDKEvent_SpendableOutputs_class != NULL);
1772         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
1773         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
1774 }
1775 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1776         LDKEvent *obj = (LDKEvent*)ptr;
1777         switch(obj->tag) {
1778                 case LDKEvent_FundingGenerationReady: {
1779                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
1780                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
1781                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1782                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
1783                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
1784                         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);
1785                 }
1786                 case LDKEvent_FundingBroadcastSafe: {
1787                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
1788                         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1789                         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1790                         long funding_txo_ref = (long)funding_txo_var.inner & ~1;
1791                         return (*env)->NewObject(env, LDKEvent_FundingBroadcastSafe_class, LDKEvent_FundingBroadcastSafe_meth, funding_txo_ref, obj->funding_broadcast_safe.user_channel_id);
1792                 }
1793                 case LDKEvent_PaymentReceived: {
1794                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1795                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
1796                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1797                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
1798                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_secret_arr, obj->payment_received.amt);
1799                 }
1800                 case LDKEvent_PaymentSent: {
1801                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1802                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
1803                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
1804                 }
1805                 case LDKEvent_PaymentFailed: {
1806                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1807                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
1808                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
1809                 }
1810                 case LDKEvent_PendingHTLCsForwardable: {
1811                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
1812                 }
1813                 case LDKEvent_SpendableOutputs: {
1814                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1815                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
1816                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
1817                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1818                                 long outputs_conv_27_ref = ((long)&outputs_var.data[b]) | 1;
1819                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1820                         }
1821                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
1822                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
1823                 }
1824                 default: abort();
1825         }
1826 }
1827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1828         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
1829         ret->datalen = (*env)->GetArrayLength(env, elems);
1830         if (ret->datalen == 0) {
1831                 ret->data = NULL;
1832         } else {
1833                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
1834                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1835                 for (size_t i = 0; i < ret->datalen; i++) {
1836                         int64_t arr_elem = java_elems[i];
1837                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
1838                         FREE((void*)arr_elem);
1839                         ret->data[i] = arr_elem_conv;
1840                 }
1841                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1842         }
1843         return (long)ret;
1844 }
1845 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
1846         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
1847         for (size_t i = 0; i < ret.datalen; i++) {
1848                 ret.data[i] = Event_clone(&orig->data[i]);
1849         }
1850         return ret;
1851 }
1852 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1853         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
1854 }
1855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1856         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
1857         CHECK(val->result_ok);
1858         LDKOutPoint res_var = (*val->contents.result);
1859         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1860         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1861         long res_ref = (long)res_var.inner & ~1;
1862         return res_ref;
1863 }
1864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1865         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
1866         CHECK(!val->result_ok);
1867         LDKDecodeError err_var = (*val->contents.err);
1868         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1869         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1870         long err_ref = (long)err_var.inner & ~1;
1871         return err_ref;
1872 }
1873 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1874         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
1875 }
1876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1877         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
1878         CHECK(val->result_ok);
1879         LDKChannelMonitorUpdate res_var = (*val->contents.result);
1880         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1881         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1882         long res_ref = (long)res_var.inner & ~1;
1883         return res_ref;
1884 }
1885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1886         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
1887         CHECK(!val->result_ok);
1888         LDKDecodeError err_var = (*val->contents.err);
1889         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1890         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1891         long err_ref = (long)err_var.inner & ~1;
1892         return err_ref;
1893 }
1894 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1895         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
1896 }
1897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1898         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
1899         CHECK(val->result_ok);
1900         LDKHTLCUpdate res_var = (*val->contents.result);
1901         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1902         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1903         long res_ref = (long)res_var.inner & ~1;
1904         return res_ref;
1905 }
1906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1907         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
1908         CHECK(!val->result_ok);
1909         LDKDecodeError err_var = (*val->contents.err);
1910         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1911         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1912         long err_ref = (long)err_var.inner & ~1;
1913         return err_ref;
1914 }
1915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1916         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
1917 }
1918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1919         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
1920         CHECK(val->result_ok);
1921         return *val->contents.result;
1922 }
1923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1924         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
1925         CHECK(!val->result_ok);
1926         LDKMonitorUpdateError err_var = (*val->contents.err);
1927         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1928         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1929         long err_ref = (long)err_var.inner & ~1;
1930         return err_ref;
1931 }
1932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1933         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
1934         LDKOutPoint a_conv;
1935         a_conv.inner = (void*)(a & (~1));
1936         a_conv.is_owned = (a & 1) || (a == 0);
1937         a_conv = OutPoint_clone(&a_conv);
1938         ret->a = a_conv;
1939         LDKCVec_u8Z b_ref;
1940         b_ref.datalen = (*env)->GetArrayLength(env, b);
1941         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
1942         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1943         ret->b = b_ref;
1944         return (long)ret;
1945 }
1946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1947         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
1948         LDKOutPoint a_var = tuple->a;
1949         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1950         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1951         long a_ref = (long)a_var.inner & ~1;
1952         return a_ref;
1953 }
1954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1955         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
1956         LDKCVec_u8Z b_var = tuple->b;
1957         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1958         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1959         return b_arr;
1960 }
1961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
1962         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
1963         ret->a = a;
1964         LDKCVec_u8Z b_ref;
1965         b_ref.datalen = (*env)->GetArrayLength(env, b);
1966         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
1967         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1968         ret->b = b_ref;
1969         return (long)ret;
1970 }
1971 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1972         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
1973         return tuple->a;
1974 }
1975 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1976         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
1977         LDKCVec_u8Z b_var = tuple->b;
1978         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1979         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1980         return b_arr;
1981 }
1982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1983         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
1984         ret->datalen = (*env)->GetArrayLength(env, elems);
1985         if (ret->datalen == 0) {
1986                 ret->data = NULL;
1987         } else {
1988                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
1989                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1990                 for (size_t i = 0; i < ret->datalen; i++) {
1991                         int64_t arr_elem = java_elems[i];
1992                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
1993                         FREE((void*)arr_elem);
1994                         ret->data[i] = arr_elem_conv;
1995                 }
1996                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1997         }
1998         return (long)ret;
1999 }
2000 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
2001         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
2002         for (size_t i = 0; i < ret.datalen; i++) {
2003                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
2004         }
2005         return ret;
2006 }
2007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
2008         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
2009         LDKThirtyTwoBytes a_ref;
2010         CHECK((*env)->GetArrayLength(env, a) == 32);
2011         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2012         ret->a = a_ref;
2013         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
2014         b_constr.datalen = (*env)->GetArrayLength(env, b);
2015         if (b_constr.datalen > 0)
2016                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
2017         else
2018                 b_constr.data = NULL;
2019         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
2020         for (size_t b = 0; b < b_constr.datalen; b++) {
2021                 int64_t b_conv_27 = b_vals[b];
2022                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
2023                 FREE((void*)b_conv_27);
2024                 b_constr.data[b] = b_conv_27_conv;
2025         }
2026         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
2027         ret->b = b_constr;
2028         return (long)ret;
2029 }
2030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2031         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
2032         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2033         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2034         return a_arr;
2035 }
2036 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2037         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
2038         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
2039         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
2040         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
2041         for (size_t b = 0; b < b_var.datalen; b++) {
2042                 long b_conv_27_ref = (long)(&b_var.data[b]) | 1;
2043                 b_arr_ptr[b] = b_conv_27_ref;
2044         }
2045         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
2046         return b_arr;
2047 }
2048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2049         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
2050         ret->datalen = (*env)->GetArrayLength(env, elems);
2051         if (ret->datalen == 0) {
2052                 ret->data = NULL;
2053         } else {
2054                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
2055                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2056                 for (size_t i = 0; i < ret->datalen; i++) {
2057                         int64_t arr_elem = java_elems[i];
2058                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
2059                         FREE((void*)arr_elem);
2060                         ret->data[i] = arr_elem_conv;
2061                 }
2062                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2063         }
2064         return (long)ret;
2065 }
2066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
2067         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
2068         ret->a = a;
2069         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
2070         FREE((void*)b);
2071         ret->b = b_conv;
2072         return (long)ret;
2073 }
2074 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2075         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
2076         return tuple->a;
2077 }
2078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2079         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
2080         long b_ref = ((long)&tuple->b) | 1;
2081         return (long)b_ref;
2082 }
2083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2084         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
2085         ret->datalen = (*env)->GetArrayLength(env, elems);
2086         if (ret->datalen == 0) {
2087                 ret->data = NULL;
2088         } else {
2089                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
2090                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2091                 for (size_t i = 0; i < ret->datalen; i++) {
2092                         int64_t arr_elem = java_elems[i];
2093                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
2094                         FREE((void*)arr_elem);
2095                         ret->data[i] = arr_elem_conv;
2096                 }
2097                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2098         }
2099         return (long)ret;
2100 }
2101 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
2102         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
2103         for (size_t i = 0; i < ret.datalen; i++) {
2104                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
2105         }
2106         return ret;
2107 }
2108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
2109         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
2110         LDKThirtyTwoBytes a_ref;
2111         CHECK((*env)->GetArrayLength(env, a) == 32);
2112         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2113         ret->a = a_ref;
2114         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
2115         b_constr.datalen = (*env)->GetArrayLength(env, b);
2116         if (b_constr.datalen > 0)
2117                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
2118         else
2119                 b_constr.data = NULL;
2120         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
2121         for (size_t a = 0; a < b_constr.datalen; a++) {
2122                 int64_t b_conv_26 = b_vals[a];
2123                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
2124                 FREE((void*)b_conv_26);
2125                 b_constr.data[a] = b_conv_26_conv;
2126         }
2127         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
2128         ret->b = b_constr;
2129         return (long)ret;
2130 }
2131 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2132         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
2133         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2134         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2135         return a_arr;
2136 }
2137 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2138         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
2139         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
2140         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
2141         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
2142         for (size_t a = 0; a < b_var.datalen; a++) {
2143                 long b_conv_26_ref = (long)(&b_var.data[a]) | 1;
2144                 b_arr_ptr[a] = b_conv_26_ref;
2145         }
2146         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
2147         return b_arr;
2148 }
2149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2150         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
2151         ret->datalen = (*env)->GetArrayLength(env, elems);
2152         if (ret->datalen == 0) {
2153                 ret->data = NULL;
2154         } else {
2155                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
2156                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2157                 for (size_t i = 0; i < ret->datalen; i++) {
2158                         int64_t arr_elem = java_elems[i];
2159                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
2160                         FREE((void*)arr_elem);
2161                         ret->data[i] = arr_elem_conv;
2162                 }
2163                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2164         }
2165         return (long)ret;
2166 }
2167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2168         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2169         LDKSignature a_ref;
2170         CHECK((*env)->GetArrayLength(env, a) == 64);
2171         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2172         ret->a = a_ref;
2173         LDKCVec_SignatureZ b_constr;
2174         b_constr.datalen = (*env)->GetArrayLength(env, b);
2175         if (b_constr.datalen > 0)
2176                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2177         else
2178                 b_constr.data = NULL;
2179         for (size_t i = 0; i < b_constr.datalen; i++) {
2180                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2181                 LDKSignature b_conv_8_ref;
2182                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
2183                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
2184                 b_constr.data[i] = b_conv_8_ref;
2185         }
2186         ret->b = b_constr;
2187         return (long)ret;
2188 }
2189 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2190         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2191         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
2192         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
2193         return a_arr;
2194 }
2195 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2196         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2197         LDKCVec_SignatureZ b_var = tuple->b;
2198         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
2199         ;
2200         for (size_t i = 0; i < b_var.datalen; i++) {
2201                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
2202                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
2203                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
2204         }
2205         return b_arr;
2206 }
2207 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2208         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2209 }
2210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2211         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2212         CHECK(val->result_ok);
2213         long res_ref = (long)(&(*val->contents.result)) | 1;
2214         return res_ref;
2215 }
2216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2217         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2218         CHECK(!val->result_ok);
2219         return *val->contents.err;
2220 }
2221 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2222         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2223 }
2224 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2225         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2226         CHECK(val->result_ok);
2227         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2228         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2229         return res_arr;
2230 }
2231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2232         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2233         CHECK(!val->result_ok);
2234         return *val->contents.err;
2235 }
2236 typedef struct LDKSign_JCalls {
2237         atomic_size_t refcnt;
2238         JavaVM *vm;
2239         jweak o;
2240         jmethodID get_per_commitment_point_meth;
2241         jmethodID release_commitment_secret_meth;
2242         jmethodID channel_keys_id_meth;
2243         jmethodID sign_counterparty_commitment_meth;
2244         jmethodID sign_holder_commitment_and_htlcs_meth;
2245         jmethodID sign_justice_transaction_meth;
2246         jmethodID sign_counterparty_htlc_transaction_meth;
2247         jmethodID sign_closing_transaction_meth;
2248         jmethodID sign_channel_announcement_meth;
2249         jmethodID ready_channel_meth;
2250         jmethodID write_meth;
2251 } LDKSign_JCalls;
2252 static void LDKSign_JCalls_free(void* this_arg) {
2253         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2254         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2255                 JNIEnv *env;
2256                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2257                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2258                 FREE(j_calls);
2259         }
2260 }
2261 LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
2262         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2263         JNIEnv *env;
2264         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2265         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2266         CHECK(obj != NULL);
2267         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2268         LDKPublicKey ret_ref;
2269         CHECK((*env)->GetArrayLength(env, ret) == 33);
2270         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2271         return ret_ref;
2272 }
2273 LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
2274         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2275         JNIEnv *env;
2276         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2277         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2278         CHECK(obj != NULL);
2279         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2280         LDKThirtyTwoBytes ret_ref;
2281         CHECK((*env)->GetArrayLength(env, ret) == 32);
2282         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2283         return ret_ref;
2284 }
2285 LDKThirtyTwoBytes channel_keys_id_jcall(const void* this_arg) {
2286         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2287         JNIEnv *env;
2288         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2289         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2290         CHECK(obj != NULL);
2291         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2292         LDKThirtyTwoBytes ret_ref;
2293         CHECK((*env)->GetArrayLength(env, ret) == 32);
2294         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2295         return ret_ref;
2296 }
2297 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2298         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2299         JNIEnv *env;
2300         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2301         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2302         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2303         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2304         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2305         long commitment_tx_ref = (long)commitment_tx_var.inner;
2306         if (commitment_tx_var.is_owned) {
2307                 commitment_tx_ref |= 1;
2308         }
2309         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2310         CHECK(obj != NULL);
2311         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2312         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2313         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
2314         return ret_conv;
2315 }
2316 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2317         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2318         JNIEnv *env;
2319         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2320         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2321         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2322         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2323         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2324         long commitment_tx_ref = (long)commitment_tx_var.inner;
2325         if (commitment_tx_var.is_owned) {
2326                 commitment_tx_ref |= 1;
2327         }
2328         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2329         CHECK(obj != NULL);
2330         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2331         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2332         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
2333         return ret_conv;
2334 }
2335 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) {
2336         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2337         JNIEnv *env;
2338         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2339         LDKTransaction justice_tx_var = justice_tx;
2340         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2341         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2342         Transaction_free(justice_tx_var);
2343         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2344         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2345         LDKHTLCOutputInCommitment htlc_var = *htlc;
2346         htlc_var = HTLCOutputInCommitment_clone(htlc);
2347         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2348         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2349         long htlc_ref = (long)htlc_var.inner;
2350         if (htlc_var.is_owned) {
2351                 htlc_ref |= 1;
2352         }
2353         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2354         CHECK(obj != NULL);
2355         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);
2356         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2357         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
2358         return ret_conv;
2359 }
2360 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) {
2361         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2362         JNIEnv *env;
2363         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2364         LDKTransaction htlc_tx_var = htlc_tx;
2365         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2366         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2367         Transaction_free(htlc_tx_var);
2368         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2369         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2370         LDKHTLCOutputInCommitment htlc_var = *htlc;
2371         htlc_var = HTLCOutputInCommitment_clone(htlc);
2372         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2373         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2374         long htlc_ref = (long)htlc_var.inner;
2375         if (htlc_var.is_owned) {
2376                 htlc_ref |= 1;
2377         }
2378         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2379         CHECK(obj != NULL);
2380         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);
2381         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2382         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
2383         return ret_conv;
2384 }
2385 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
2386         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2387         JNIEnv *env;
2388         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2389         LDKTransaction closing_tx_var = closing_tx;
2390         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
2391         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
2392         Transaction_free(closing_tx_var);
2393         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2394         CHECK(obj != NULL);
2395         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
2396         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2397         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
2398         return ret_conv;
2399 }
2400 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2401         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2402         JNIEnv *env;
2403         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2404         LDKUnsignedChannelAnnouncement msg_var = *msg;
2405         msg_var = UnsignedChannelAnnouncement_clone(msg);
2406         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2407         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2408         long msg_ref = (long)msg_var.inner;
2409         if (msg_var.is_owned) {
2410                 msg_ref |= 1;
2411         }
2412         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2413         CHECK(obj != NULL);
2414         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2415         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2416         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
2417         return ret_conv;
2418 }
2419 void ready_channel_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2420         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2421         JNIEnv *env;
2422         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2423         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2424         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2425         CHECK((((long)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2426         CHECK((((long)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2427         long channel_parameters_ref = (long)channel_parameters_var.inner;
2428         if (channel_parameters_var.is_owned) {
2429                 channel_parameters_ref |= 1;
2430         }
2431         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2432         CHECK(obj != NULL);
2433         return (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2434 }
2435 LDKCVec_u8Z write_jcall(const void* this_arg) {
2436         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2437         JNIEnv *env;
2438         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2439         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2440         CHECK(obj != NULL);
2441         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2442         LDKCVec_u8Z ret_ref;
2443         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2444         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2445         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2446         return ret_ref;
2447 }
2448 static void* LDKSign_JCalls_clone(const void* this_arg) {
2449         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2450         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2451         return (void*) this_arg;
2452 }
2453 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2454         jclass c = (*env)->GetObjectClass(env, o);
2455         CHECK(c != NULL);
2456         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2457         atomic_init(&calls->refcnt, 1);
2458         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2459         calls->o = (*env)->NewWeakGlobalRef(env, o);
2460         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2461         CHECK(calls->get_per_commitment_point_meth != NULL);
2462         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2463         CHECK(calls->release_commitment_secret_meth != NULL);
2464         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2465         CHECK(calls->channel_keys_id_meth != NULL);
2466         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2467         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2468         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2469         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2470         calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "([BJJ[BJ)J");
2471         CHECK(calls->sign_justice_transaction_meth != NULL);
2472         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2473         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2474         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
2475         CHECK(calls->sign_closing_transaction_meth != NULL);
2476         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2477         CHECK(calls->sign_channel_announcement_meth != NULL);
2478         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2479         CHECK(calls->ready_channel_meth != NULL);
2480         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2481         CHECK(calls->write_meth != NULL);
2482
2483         LDKChannelPublicKeys pubkeys_conv;
2484         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2485         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2486         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2487
2488         LDKSign ret = {
2489                 .this_arg = (void*) calls,
2490                 .get_per_commitment_point = get_per_commitment_point_jcall,
2491                 .release_commitment_secret = release_commitment_secret_jcall,
2492                 .channel_keys_id = channel_keys_id_jcall,
2493                 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
2494                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_jcall,
2495                 .sign_justice_transaction = sign_justice_transaction_jcall,
2496                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
2497                 .sign_closing_transaction = sign_closing_transaction_jcall,
2498                 .sign_channel_announcement = sign_channel_announcement_jcall,
2499                 .ready_channel = ready_channel_jcall,
2500                 .clone = LDKSign_JCalls_clone,
2501                 .write = write_jcall,
2502                 .free = LDKSign_JCalls_free,
2503                 .pubkeys = pubkeys_conv,
2504                 .set_pubkeys = NULL,
2505         };
2506         return ret;
2507 }
2508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2509         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2510         *res_ptr = LDKSign_init(env, clz, o, pubkeys);
2511         return (long)res_ptr;
2512 }
2513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2514         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2515         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2516         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2517         return ret_arr;
2518 }
2519
2520 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2521         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2522         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2523         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2524         return ret_arr;
2525 }
2526
2527 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
2528         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2529         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2530         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2531         return ret_arr;
2532 }
2533
2534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1sign_1counterparty_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
2535         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2536         LDKCommitmentTransaction commitment_tx_conv;
2537         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2538         commitment_tx_conv.is_owned = false;
2539         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2540         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2541         return (long)ret_conv;
2542 }
2543
2544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1sign_1holder_1commitment_1and_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
2545         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2546         LDKHolderCommitmentTransaction commitment_tx_conv;
2547         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2548         commitment_tx_conv.is_owned = false;
2549         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2550         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2551         return (long)ret_conv;
2552 }
2553
2554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_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) {
2555         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2556         LDKTransaction justice_tx_ref;
2557         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2558         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2559         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2560         justice_tx_ref.data_is_owned = true;
2561         unsigned char per_commitment_key_arr[32];
2562         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2563         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2564         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2565         LDKHTLCOutputInCommitment htlc_conv;
2566         htlc_conv.inner = (void*)(htlc & (~1));
2567         htlc_conv.is_owned = false;
2568         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2569         *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
2570         return (long)ret_conv;
2571 }
2572
2573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_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) {
2574         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2575         LDKTransaction htlc_tx_ref;
2576         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2577         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2578         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2579         htlc_tx_ref.data_is_owned = true;
2580         LDKPublicKey per_commitment_point_ref;
2581         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2582         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2583         LDKHTLCOutputInCommitment htlc_conv;
2584         htlc_conv.inner = (void*)(htlc & (~1));
2585         htlc_conv.is_owned = false;
2586         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2587         *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);
2588         return (long)ret_conv;
2589 }
2590
2591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray closing_tx) {
2592         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2593         LDKTransaction closing_tx_ref;
2594         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
2595         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2596         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
2597         closing_tx_ref.data_is_owned = true;
2598         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2599         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2600         return (long)ret_conv;
2601 }
2602
2603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2604         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2605         LDKUnsignedChannelAnnouncement msg_conv;
2606         msg_conv.inner = (void*)(msg & (~1));
2607         msg_conv.is_owned = false;
2608         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2609         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2610         return (long)ret_conv;
2611 }
2612
2613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2614         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2615         LDKChannelTransactionParameters channel_parameters_conv;
2616         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2617         channel_parameters_conv.is_owned = false;
2618         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2619 }
2620
2621 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2622         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2623         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2624         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2625         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2626         CVec_u8Z_free(ret_var);
2627         return ret_arr;
2628 }
2629
2630 LDKChannelPublicKeys LDKSign_set_get_pubkeys(LDKSign* this_arg) {
2631         if (this_arg->set_pubkeys != NULL)
2632                 this_arg->set_pubkeys(this_arg);
2633         return this_arg->pubkeys;
2634 }
2635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2636         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2637         LDKChannelPublicKeys ret_var = LDKSign_set_get_pubkeys(this_arg_conv);
2638         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2639         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2640         long ret_ref = (long)ret_var.inner;
2641         if (ret_var.is_owned) {
2642                 ret_ref |= 1;
2643         }
2644         return ret_ref;
2645 }
2646
2647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
2648         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2649         LDKThirtyTwoBytes a_ref;
2650         CHECK((*env)->GetArrayLength(env, a) == 32);
2651         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2652         ret->a = a_ref;
2653         LDKChannelMonitor b_conv;
2654         b_conv.inner = (void*)(b & (~1));
2655         b_conv.is_owned = (b & 1) || (b == 0);
2656         b_conv = ChannelMonitor_clone(&b_conv);
2657         ret->b = b_conv;
2658         return (long)ret;
2659 }
2660 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2661         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2662         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2663         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2664         return a_arr;
2665 }
2666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2667         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2668         LDKChannelMonitor b_var = tuple->b;
2669         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2670         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2671         long b_ref = (long)b_var.inner & ~1;
2672         return b_ref;
2673 }
2674 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2675         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
2676 }
2677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2678         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2679         CHECK(val->result_ok);
2680         long res_ref = (long)(&(*val->contents.result)) | 1;
2681         return res_ref;
2682 }
2683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2684         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2685         CHECK(!val->result_ok);
2686         LDKDecodeError err_var = (*val->contents.err);
2687         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2688         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2689         long err_ref = (long)err_var.inner & ~1;
2690         return err_ref;
2691 }
2692 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2693         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
2694 }
2695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2696         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2697         CHECK(val->result_ok);
2698         long res_ref = ((long)&(*val->contents.result)) | 1;
2699         return (long)res_ref;
2700 }
2701 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2702         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2703         CHECK(!val->result_ok);
2704         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
2705         return err_conv;
2706 }
2707 static jclass LDKAPIError_APIMisuseError_class = NULL;
2708 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
2709 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
2710 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
2711 static jclass LDKAPIError_RouteError_class = NULL;
2712 static jmethodID LDKAPIError_RouteError_meth = NULL;
2713 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
2714 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
2715 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
2716 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
2717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
2718         LDKAPIError_APIMisuseError_class =
2719                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
2720         CHECK(LDKAPIError_APIMisuseError_class != NULL);
2721         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "([B)V");
2722         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
2723         LDKAPIError_FeeRateTooHigh_class =
2724                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
2725         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
2726         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "([BI)V");
2727         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
2728         LDKAPIError_RouteError_class =
2729                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
2730         CHECK(LDKAPIError_RouteError_class != NULL);
2731         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
2732         CHECK(LDKAPIError_RouteError_meth != NULL);
2733         LDKAPIError_ChannelUnavailable_class =
2734                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
2735         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
2736         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "([B)V");
2737         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
2738         LDKAPIError_MonitorUpdateFailed_class =
2739                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
2740         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
2741         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
2742         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
2743 }
2744 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2745         LDKAPIError *obj = (LDKAPIError*)ptr;
2746         switch(obj->tag) {
2747                 case LDKAPIError_APIMisuseError: {
2748                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
2749                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
2750                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
2751                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_arr);
2752                 }
2753                 case LDKAPIError_FeeRateTooHigh: {
2754                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
2755                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
2756                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
2757                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_arr, obj->fee_rate_too_high.feerate);
2758                 }
2759                 case LDKAPIError_RouteError: {
2760                         LDKStr err_str = obj->route_error.err;
2761                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2762                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
2763                 }
2764                 case LDKAPIError_ChannelUnavailable: {
2765                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
2766                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
2767                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
2768                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_arr);
2769                 }
2770                 case LDKAPIError_MonitorUpdateFailed: {
2771                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
2772                 }
2773                 default: abort();
2774         }
2775 }
2776 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2777         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2778 }
2779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2780         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2781         CHECK(val->result_ok);
2782         return *val->contents.result;
2783 }
2784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2785         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2786         CHECK(!val->result_ok);
2787         long err_ref = ((long)&(*val->contents.err)) | 1;
2788         return err_ref;
2789 }
2790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2791         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2792         ret->datalen = (*env)->GetArrayLength(env, elems);
2793         if (ret->datalen == 0) {
2794                 ret->data = NULL;
2795         } else {
2796                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2797                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2798                 for (size_t i = 0; i < ret->datalen; i++) {
2799                         int64_t arr_elem = java_elems[i];
2800                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2801                         FREE((void*)arr_elem);
2802                         ret->data[i] = arr_elem_conv;
2803                 }
2804                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2805         }
2806         return (long)ret;
2807 }
2808 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2809         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2810         for (size_t i = 0; i < ret.datalen; i++) {
2811                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2812         }
2813         return ret;
2814 }
2815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2816         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2817         ret->datalen = (*env)->GetArrayLength(env, elems);
2818         if (ret->datalen == 0) {
2819                 ret->data = NULL;
2820         } else {
2821                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
2822                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2823                 for (size_t i = 0; i < ret->datalen; i++) {
2824                         int64_t arr_elem = java_elems[i];
2825                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
2826                         FREE((void*)arr_elem);
2827                         ret->data[i] = arr_elem_conv;
2828                 }
2829                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2830         }
2831         return (long)ret;
2832 }
2833 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2834         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2835         for (size_t i = 0; i < ret.datalen; i++) {
2836                 ret.data[i] = APIError_clone(&orig->data[i]);
2837         }
2838         return ret;
2839 }
2840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2841         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
2842         ret->datalen = (*env)->GetArrayLength(env, elems);
2843         if (ret->datalen == 0) {
2844                 ret->data = NULL;
2845         } else {
2846                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
2847                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2848                 for (size_t i = 0; i < ret->datalen; i++) {
2849                         int64_t arr_elem = java_elems[i];
2850                         LDKChannelDetails arr_elem_conv;
2851                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2852                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2853                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
2854                         ret->data[i] = arr_elem_conv;
2855                 }
2856                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2857         }
2858         return (long)ret;
2859 }
2860 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2861         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2862         for (size_t i = 0; i < ret.datalen; i++) {
2863                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2864         }
2865         return ret;
2866 }
2867 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
2868 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
2869 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
2870 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
2871 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
2872 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
2873 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
2874 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
2875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
2876         LDKPaymentSendFailure_ParameterError_class =
2877                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
2878         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
2879         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "()V");
2880         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
2881         LDKPaymentSendFailure_PathParameterError_class =
2882                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
2883         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
2884         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "()V");
2885         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
2886         LDKPaymentSendFailure_AllFailedRetrySafe_class =
2887                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
2888         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
2889         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "()V");
2890         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
2891         LDKPaymentSendFailure_PartialFailure_class =
2892                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
2893         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
2894         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "()V");
2895         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
2896 }
2897 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2898         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)ptr;
2899         switch(obj->tag) {
2900                 case LDKPaymentSendFailure_ParameterError: {
2901                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth);
2902                 }
2903                 case LDKPaymentSendFailure_PathParameterError: {
2904                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth);
2905                 }
2906                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2907                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth);
2908                 }
2909                 case LDKPaymentSendFailure_PartialFailure: {
2910                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth);
2911                 }
2912                 default: abort();
2913         }
2914 }
2915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2916         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
2917 }
2918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2919         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2920         CHECK(val->result_ok);
2921         return *val->contents.result;
2922 }
2923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2924         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2925         CHECK(!val->result_ok);
2926         long err_ref = ((long)&(*val->contents.err)) | 1;
2927         return err_ref;
2928 }
2929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2930         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
2931         ret->datalen = (*env)->GetArrayLength(env, elems);
2932         if (ret->datalen == 0) {
2933                 ret->data = NULL;
2934         } else {
2935                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
2936                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2937                 for (size_t i = 0; i < ret->datalen; i++) {
2938                         int64_t arr_elem = java_elems[i];
2939                         LDKChannelMonitor arr_elem_conv;
2940                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2941                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2942                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
2943                         ret->data[i] = arr_elem_conv;
2944                 }
2945                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2946         }
2947         return (long)ret;
2948 }
2949 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2950         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2951         for (size_t i = 0; i < ret.datalen; i++) {
2952                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2953         }
2954         return ret;
2955 }
2956 typedef struct LDKWatch_JCalls {
2957         atomic_size_t refcnt;
2958         JavaVM *vm;
2959         jweak o;
2960         jmethodID watch_channel_meth;
2961         jmethodID update_channel_meth;
2962         jmethodID release_pending_monitor_events_meth;
2963 } LDKWatch_JCalls;
2964 static void LDKWatch_JCalls_free(void* this_arg) {
2965         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2966         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2967                 JNIEnv *env;
2968                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2969                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2970                 FREE(j_calls);
2971         }
2972 }
2973 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2974         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2975         JNIEnv *env;
2976         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2977         LDKOutPoint funding_txo_var = funding_txo;
2978         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2979         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2980         long funding_txo_ref = (long)funding_txo_var.inner;
2981         if (funding_txo_var.is_owned) {
2982                 funding_txo_ref |= 1;
2983         }
2984         LDKChannelMonitor monitor_var = monitor;
2985         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2986         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2987         long monitor_ref = (long)monitor_var.inner;
2988         if (monitor_var.is_owned) {
2989                 monitor_ref |= 1;
2990         }
2991         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2992         CHECK(obj != NULL);
2993         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2994         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2995         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
2996         return ret_conv;
2997 }
2998 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2999         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3000         JNIEnv *env;
3001         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3002         LDKOutPoint funding_txo_var = funding_txo;
3003         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3004         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3005         long funding_txo_ref = (long)funding_txo_var.inner;
3006         if (funding_txo_var.is_owned) {
3007                 funding_txo_ref |= 1;
3008         }
3009         LDKChannelMonitorUpdate update_var = update;
3010         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3011         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3012         long update_ref = (long)update_var.inner;
3013         if (update_var.is_owned) {
3014                 update_ref |= 1;
3015         }
3016         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3017         CHECK(obj != NULL);
3018         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3019         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3020         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
3021         return ret_conv;
3022 }
3023 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
3024         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3025         JNIEnv *env;
3026         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3027         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3028         CHECK(obj != NULL);
3029         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3030         LDKCVec_MonitorEventZ ret_constr;
3031         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3032         if (ret_constr.datalen > 0)
3033                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3034         else
3035                 ret_constr.data = NULL;
3036         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3037         for (size_t o = 0; o < ret_constr.datalen; o++) {
3038                 int64_t ret_conv_14 = ret_vals[o];
3039                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3040                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)ret_conv_14);
3041                 ret_constr.data[o] = ret_conv_14_conv;
3042         }
3043         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3044         return ret_constr;
3045 }
3046 static void* LDKWatch_JCalls_clone(const void* this_arg) {
3047         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3048         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3049         return (void*) this_arg;
3050 }
3051 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3052         jclass c = (*env)->GetObjectClass(env, o);
3053         CHECK(c != NULL);
3054         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3055         atomic_init(&calls->refcnt, 1);
3056         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3057         calls->o = (*env)->NewWeakGlobalRef(env, o);
3058         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3059         CHECK(calls->watch_channel_meth != NULL);
3060         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3061         CHECK(calls->update_channel_meth != NULL);
3062         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3063         CHECK(calls->release_pending_monitor_events_meth != NULL);
3064
3065         LDKWatch ret = {
3066                 .this_arg = (void*) calls,
3067                 .watch_channel = watch_channel_jcall,
3068                 .update_channel = update_channel_jcall,
3069                 .release_pending_monitor_events = release_pending_monitor_events_jcall,
3070                 .free = LDKWatch_JCalls_free,
3071         };
3072         return ret;
3073 }
3074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3075         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3076         *res_ptr = LDKWatch_init(env, clz, o);
3077         return (long)res_ptr;
3078 }
3079 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) {
3080         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3081         LDKOutPoint funding_txo_conv;
3082         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3083         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3084         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3085         LDKChannelMonitor monitor_conv;
3086         monitor_conv.inner = (void*)(monitor & (~1));
3087         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3088         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3089         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3090         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3091         return (long)ret_conv;
3092 }
3093
3094 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) {
3095         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3096         LDKOutPoint funding_txo_conv;
3097         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3098         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3099         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3100         LDKChannelMonitorUpdate update_conv;
3101         update_conv.inner = (void*)(update & (~1));
3102         update_conv.is_owned = (update & 1) || (update == 0);
3103         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3104         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3105         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3106         return (long)ret_conv;
3107 }
3108
3109 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3110         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3111         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3112         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3113         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3114         for (size_t o = 0; o < ret_var.datalen; o++) {
3115                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3116                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3117                 long ret_conv_14_ref = (long)ret_conv_14_copy;
3118                 ret_arr_ptr[o] = ret_conv_14_ref;
3119         }
3120         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3121         FREE(ret_var.data);
3122         return ret_arr;
3123 }
3124
3125 typedef struct LDKBroadcasterInterface_JCalls {
3126         atomic_size_t refcnt;
3127         JavaVM *vm;
3128         jweak o;
3129         jmethodID broadcast_transaction_meth;
3130 } LDKBroadcasterInterface_JCalls;
3131 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3132         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3133         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3134                 JNIEnv *env;
3135                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3136                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3137                 FREE(j_calls);
3138         }
3139 }
3140 void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) {
3141         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3142         JNIEnv *env;
3143         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3144         LDKTransaction tx_var = tx;
3145         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3146         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3147         Transaction_free(tx_var);
3148         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3149         CHECK(obj != NULL);
3150         return (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3151 }
3152 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
3153         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3154         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3155         return (void*) this_arg;
3156 }
3157 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
3158         jclass c = (*env)->GetObjectClass(env, o);
3159         CHECK(c != NULL);
3160         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3161         atomic_init(&calls->refcnt, 1);
3162         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3163         calls->o = (*env)->NewWeakGlobalRef(env, o);
3164         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
3165         CHECK(calls->broadcast_transaction_meth != NULL);
3166
3167         LDKBroadcasterInterface ret = {
3168                 .this_arg = (void*) calls,
3169                 .broadcast_transaction = broadcast_transaction_jcall,
3170                 .free = LDKBroadcasterInterface_JCalls_free,
3171         };
3172         return ret;
3173 }
3174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3175         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3176         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
3177         return (long)res_ptr;
3178 }
3179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
3180         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
3181         LDKTransaction tx_ref;
3182         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
3183         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3184         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
3185         tx_ref.data_is_owned = true;
3186         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3187 }
3188
3189 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3190         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
3191 }
3192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3193         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3194         CHECK(val->result_ok);
3195         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3196         *ret = Sign_clone(&(*val->contents.result));
3197         return (long)ret;
3198 }
3199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3200         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3201         CHECK(!val->result_ok);
3202         LDKDecodeError err_var = (*val->contents.err);
3203         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3204         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3205         long err_ref = (long)err_var.inner & ~1;
3206         return err_ref;
3207 }
3208 typedef struct LDKKeysInterface_JCalls {
3209         atomic_size_t refcnt;
3210         JavaVM *vm;
3211         jweak o;
3212         jmethodID get_node_secret_meth;
3213         jmethodID get_destination_script_meth;
3214         jmethodID get_shutdown_pubkey_meth;
3215         jmethodID get_channel_signer_meth;
3216         jmethodID get_secure_random_bytes_meth;
3217         jmethodID read_chan_signer_meth;
3218 } LDKKeysInterface_JCalls;
3219 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3220         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3221         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3222                 JNIEnv *env;
3223                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3224                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3225                 FREE(j_calls);
3226         }
3227 }
3228 LDKSecretKey get_node_secret_jcall(const void* this_arg) {
3229         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3230         JNIEnv *env;
3231         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3232         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3233         CHECK(obj != NULL);
3234         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3235         LDKSecretKey ret_ref;
3236         CHECK((*env)->GetArrayLength(env, ret) == 32);
3237         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
3238         return ret_ref;
3239 }
3240 LDKCVec_u8Z get_destination_script_jcall(const void* this_arg) {
3241         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3242         JNIEnv *env;
3243         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3244         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3245         CHECK(obj != NULL);
3246         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
3247         LDKCVec_u8Z ret_ref;
3248         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3249         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3250         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3251         return ret_ref;
3252 }
3253 LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) {
3254         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3255         JNIEnv *env;
3256         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3257         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3258         CHECK(obj != NULL);
3259         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
3260         LDKPublicKey ret_ref;
3261         CHECK((*env)->GetArrayLength(env, ret) == 33);
3262         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3263         return ret_ref;
3264 }
3265 LDKSign get_channel_signer_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3266         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3267         JNIEnv *env;
3268         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3269         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3270         CHECK(obj != NULL);
3271         LDKSign* ret = (LDKSign*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3272         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
3273         ret_conv = Sign_clone(ret);
3274         return ret_conv;
3275 }
3276 LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) {
3277         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3278         JNIEnv *env;
3279         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3280         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3281         CHECK(obj != NULL);
3282         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
3283         LDKThirtyTwoBytes ret_ref;
3284         CHECK((*env)->GetArrayLength(env, ret) == 32);
3285         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3286         return ret_ref;
3287 }
3288 LDKCResult_SignDecodeErrorZ read_chan_signer_jcall(const void* this_arg, LDKu8slice reader) {
3289         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3290         JNIEnv *env;
3291         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3292         LDKu8slice reader_var = reader;
3293         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
3294         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
3295         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3296         CHECK(obj != NULL);
3297         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
3298         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
3299         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)ret);
3300         return ret_conv;
3301 }
3302 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
3303         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3304         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3305         return (void*) this_arg;
3306 }
3307 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
3308         jclass c = (*env)->GetObjectClass(env, o);
3309         CHECK(c != NULL);
3310         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3311         atomic_init(&calls->refcnt, 1);
3312         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3313         calls->o = (*env)->NewWeakGlobalRef(env, o);
3314         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
3315         CHECK(calls->get_node_secret_meth != NULL);
3316         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
3317         CHECK(calls->get_destination_script_meth != NULL);
3318         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
3319         CHECK(calls->get_shutdown_pubkey_meth != NULL);
3320         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
3321         CHECK(calls->get_channel_signer_meth != NULL);
3322         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
3323         CHECK(calls->get_secure_random_bytes_meth != NULL);
3324         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
3325         CHECK(calls->read_chan_signer_meth != NULL);
3326
3327         LDKKeysInterface ret = {
3328                 .this_arg = (void*) calls,
3329                 .get_node_secret = get_node_secret_jcall,
3330                 .get_destination_script = get_destination_script_jcall,
3331                 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
3332                 .get_channel_signer = get_channel_signer_jcall,
3333                 .get_secure_random_bytes = get_secure_random_bytes_jcall,
3334                 .read_chan_signer = read_chan_signer_jcall,
3335                 .free = LDKKeysInterface_JCalls_free,
3336         };
3337         return ret;
3338 }
3339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3340         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3341         *res_ptr = LDKKeysInterface_init(env, clz, o);
3342         return (long)res_ptr;
3343 }
3344 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
3345         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3346         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3347         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
3348         return ret_arr;
3349 }
3350
3351 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
3352         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3353         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3354         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3355         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3356         CVec_u8Z_free(ret_var);
3357         return ret_arr;
3358 }
3359
3360 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
3361         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3362         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3363         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
3364         return ret_arr;
3365 }
3366
3367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1channel_1signer(JNIEnv *env, jclass clz, int64_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
3368         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3369         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3370         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
3371         return (long)ret;
3372 }
3373
3374 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
3375         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3376         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3377         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
3378         return ret_arr;
3379 }
3380
3381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
3382         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3383         LDKu8slice reader_ref;
3384         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
3385         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
3386         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
3387         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
3388         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
3389         return (long)ret_conv;
3390 }
3391
3392 typedef struct LDKFeeEstimator_JCalls {
3393         atomic_size_t refcnt;
3394         JavaVM *vm;
3395         jweak o;
3396         jmethodID get_est_sat_per_1000_weight_meth;
3397 } LDKFeeEstimator_JCalls;
3398 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3399         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3400         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3401                 JNIEnv *env;
3402                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3403                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3404                 FREE(j_calls);
3405         }
3406 }
3407 uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
3408         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3409         JNIEnv *env;
3410         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3411         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
3412         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3413         CHECK(obj != NULL);
3414         return (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
3415 }
3416 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
3417         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3418         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3419         return (void*) this_arg;
3420 }
3421 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
3422         jclass c = (*env)->GetObjectClass(env, o);
3423         CHECK(c != NULL);
3424         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
3425         atomic_init(&calls->refcnt, 1);
3426         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3427         calls->o = (*env)->NewWeakGlobalRef(env, o);
3428         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I");
3429         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
3430
3431         LDKFeeEstimator ret = {
3432                 .this_arg = (void*) calls,
3433                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
3434                 .free = LDKFeeEstimator_JCalls_free,
3435         };
3436         return ret;
3437 }
3438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
3439         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
3440         *res_ptr = LDKFeeEstimator_init(env, clz, o);
3441         return (long)res_ptr;
3442 }
3443 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) {
3444         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
3445         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
3446         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
3447         return ret_val;
3448 }
3449
3450 typedef struct LDKLogger_JCalls {
3451         atomic_size_t refcnt;
3452         JavaVM *vm;
3453         jweak o;
3454         jmethodID log_meth;
3455 } LDKLogger_JCalls;
3456 static void LDKLogger_JCalls_free(void* this_arg) {
3457         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3458         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3459                 JNIEnv *env;
3460                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3461                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3462                 FREE(j_calls);
3463         }
3464 }
3465 void log_jcall(const void* this_arg, const char* record) {
3466         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3467         JNIEnv *env;
3468         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3469         const char* record_str = record;
3470         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
3471         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3472         CHECK(obj != NULL);
3473         return (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
3474 }
3475 static void* LDKLogger_JCalls_clone(const void* this_arg) {
3476         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3477         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3478         return (void*) this_arg;
3479 }
3480 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3481         jclass c = (*env)->GetObjectClass(env, o);
3482         CHECK(c != NULL);
3483         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3484         atomic_init(&calls->refcnt, 1);
3485         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3486         calls->o = (*env)->NewWeakGlobalRef(env, o);
3487         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
3488         CHECK(calls->log_meth != NULL);
3489
3490         LDKLogger ret = {
3491                 .this_arg = (void*) calls,
3492                 .log = log_jcall,
3493                 .free = LDKLogger_JCalls_free,
3494         };
3495         return ret;
3496 }
3497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3498         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3499         *res_ptr = LDKLogger_init(env, clz, o);
3500         return (long)res_ptr;
3501 }
3502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
3503         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
3504         LDKThirtyTwoBytes a_ref;
3505         CHECK((*env)->GetArrayLength(env, a) == 32);
3506         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3507         ret->a = a_ref;
3508         LDKChannelManager b_conv;
3509         b_conv.inner = (void*)(b & (~1));
3510         b_conv.is_owned = (b & 1) || (b == 0);
3511         // Warning: we need a move here but no clone is available for LDKChannelManager
3512         ret->b = b_conv;
3513         return (long)ret;
3514 }
3515 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3516         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
3517         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3518         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3519         return a_arr;
3520 }
3521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3522         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
3523         LDKChannelManager b_var = tuple->b;
3524         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3525         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3526         long b_ref = (long)b_var.inner & ~1;
3527         return b_ref;
3528 }
3529 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3530         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
3531 }
3532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3533         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3534         CHECK(val->result_ok);
3535         long res_ref = (long)(&(*val->contents.result)) | 1;
3536         return res_ref;
3537 }
3538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3539         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3540         CHECK(!val->result_ok);
3541         LDKDecodeError err_var = (*val->contents.err);
3542         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3543         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3544         long err_ref = (long)err_var.inner & ~1;
3545         return err_ref;
3546 }
3547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3548         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
3549 }
3550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3551         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
3552         CHECK(val->result_ok);
3553         long res_ref = ((long)&(*val->contents.result)) | 1;
3554         return res_ref;
3555 }
3556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3557         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
3558         CHECK(!val->result_ok);
3559         LDKDecodeError err_var = (*val->contents.err);
3560         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3561         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3562         long err_ref = (long)err_var.inner & ~1;
3563         return err_ref;
3564 }
3565 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3566         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3567         for (size_t i = 0; i < ret.datalen; i++) {
3568                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3569         }
3570         return ret;
3571 }
3572 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3573         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
3574 }
3575 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3576         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3577         CHECK(val->result_ok);
3578         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
3579         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
3580         ;
3581         for (size_t i = 0; i < res_var.datalen; i++) {
3582                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
3583                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
3584                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
3585                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
3586         }
3587         return res_arr;
3588 }
3589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3590         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3591         CHECK(!val->result_ok);
3592         return *val->contents.err;
3593 }
3594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3595         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
3596 }
3597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3598         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3599         CHECK(val->result_ok);
3600         LDKInMemorySigner res_var = (*val->contents.result);
3601         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3602         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3603         long res_ref = (long)res_var.inner & ~1;
3604         return res_ref;
3605 }
3606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3607         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3608         CHECK(!val->result_ok);
3609         LDKDecodeError err_var = (*val->contents.err);
3610         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3611         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3612         long err_ref = (long)err_var.inner & ~1;
3613         return err_ref;
3614 }
3615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3616         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
3617         ret->datalen = (*env)->GetArrayLength(env, elems);
3618         if (ret->datalen == 0) {
3619                 ret->data = NULL;
3620         } else {
3621                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
3622                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3623                 for (size_t i = 0; i < ret->datalen; i++) {
3624                         int64_t arr_elem = java_elems[i];
3625                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
3626                         FREE((void*)arr_elem);
3627                         ret->data[i] = arr_elem_conv;
3628                 }
3629                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3630         }
3631         return (long)ret;
3632 }
3633 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3634         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3635         for (size_t i = 0; i < ret.datalen; i++) {
3636                 ret.data[i] = TxOut_clone(&orig->data[i]);
3637         }
3638         return ret;
3639 }
3640 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3641         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
3642 }
3643 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3644         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3645         CHECK(val->result_ok);
3646         LDKTransaction res_var = (*val->contents.result);
3647         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
3648         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
3649         return res_arr;
3650 }
3651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3652         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3653         CHECK(!val->result_ok);
3654         return *val->contents.err;
3655 }
3656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3657         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
3658         ret->datalen = (*env)->GetArrayLength(env, elems);
3659         if (ret->datalen == 0) {
3660                 ret->data = NULL;
3661         } else {
3662                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
3663                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3664                 for (size_t i = 0; i < ret->datalen; i++) {
3665                         int64_t arr_elem = java_elems[i];
3666                         LDKRouteHop arr_elem_conv;
3667                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3668                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3669                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
3670                         ret->data[i] = arr_elem_conv;
3671                 }
3672                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3673         }
3674         return (long)ret;
3675 }
3676 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
3677         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
3678         for (size_t i = 0; i < ret.datalen; i++) {
3679                 ret.data[i] = RouteHop_clone(&orig->data[i]);
3680         }
3681         return ret;
3682 }
3683 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
3684         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
3685         for (size_t i = 0; i < ret.datalen; i++) {
3686                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
3687         }
3688         return ret;
3689 }
3690 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3691         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
3692 }
3693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3694         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
3695         CHECK(val->result_ok);
3696         LDKRoute res_var = (*val->contents.result);
3697         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3698         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3699         long res_ref = (long)res_var.inner & ~1;
3700         return res_ref;
3701 }
3702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3703         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
3704         CHECK(!val->result_ok);
3705         LDKDecodeError err_var = (*val->contents.err);
3706         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3707         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3708         long err_ref = (long)err_var.inner & ~1;
3709         return err_ref;
3710 }
3711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3712         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
3713         ret->datalen = (*env)->GetArrayLength(env, elems);
3714         if (ret->datalen == 0) {
3715                 ret->data = NULL;
3716         } else {
3717                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
3718                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3719                 for (size_t i = 0; i < ret->datalen; i++) {
3720                         int64_t arr_elem = java_elems[i];
3721                         LDKRouteHint arr_elem_conv;
3722                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3723                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3724                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
3725                         ret->data[i] = arr_elem_conv;
3726                 }
3727                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3728         }
3729         return (long)ret;
3730 }
3731 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
3732         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
3733         for (size_t i = 0; i < ret.datalen; i++) {
3734                 ret.data[i] = RouteHint_clone(&orig->data[i]);
3735         }
3736         return ret;
3737 }
3738 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3739         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
3740 }
3741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3742         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
3743         CHECK(val->result_ok);
3744         LDKRoute res_var = (*val->contents.result);
3745         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3746         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3747         long res_ref = (long)res_var.inner & ~1;
3748         return res_ref;
3749 }
3750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3751         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
3752         CHECK(!val->result_ok);
3753         LDKLightningError err_var = (*val->contents.err);
3754         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3755         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3756         long err_ref = (long)err_var.inner & ~1;
3757         return err_ref;
3758 }
3759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3760         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
3761 }
3762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3763         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3764         CHECK(val->result_ok);
3765         long res_ref = ((long)&(*val->contents.result)) | 1;
3766         return res_ref;
3767 }
3768 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3769         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3770         CHECK(!val->result_ok);
3771         return *val->contents.err;
3772 }
3773 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3774         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
3775 }
3776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3777         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3778         CHECK(val->result_ok);
3779         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3780         *res_conv = (*val->contents.result);
3781         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
3782         return (long)res_conv;
3783 }
3784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3785         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3786         CHECK(!val->result_ok);
3787         LDKDecodeError err_var = (*val->contents.err);
3788         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3789         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3790         long err_ref = (long)err_var.inner & ~1;
3791         return err_ref;
3792 }
3793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3794         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
3795         ret->datalen = (*env)->GetArrayLength(env, elems);
3796         if (ret->datalen == 0) {
3797                 ret->data = NULL;
3798         } else {
3799                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
3800                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3801                 for (size_t i = 0; i < ret->datalen; i++) {
3802                         int64_t arr_elem = java_elems[i];
3803                         LDKUpdateAddHTLC arr_elem_conv;
3804                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3805                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3806                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3807                         ret->data[i] = arr_elem_conv;
3808                 }
3809                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3810         }
3811         return (long)ret;
3812 }
3813 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
3814         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
3815         for (size_t i = 0; i < ret.datalen; i++) {
3816                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
3817         }
3818         return ret;
3819 }
3820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3821         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
3822         ret->datalen = (*env)->GetArrayLength(env, elems);
3823         if (ret->datalen == 0) {
3824                 ret->data = NULL;
3825         } else {
3826                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
3827                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3828                 for (size_t i = 0; i < ret->datalen; i++) {
3829                         int64_t arr_elem = java_elems[i];
3830                         LDKUpdateFulfillHTLC arr_elem_conv;
3831                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3832                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3833                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3834                         ret->data[i] = arr_elem_conv;
3835                 }
3836                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3837         }
3838         return (long)ret;
3839 }
3840 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
3841         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
3842         for (size_t i = 0; i < ret.datalen; i++) {
3843                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
3844         }
3845         return ret;
3846 }
3847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3848         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
3849         ret->datalen = (*env)->GetArrayLength(env, elems);
3850         if (ret->datalen == 0) {
3851                 ret->data = NULL;
3852         } else {
3853                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
3854                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3855                 for (size_t i = 0; i < ret->datalen; i++) {
3856                         int64_t arr_elem = java_elems[i];
3857                         LDKUpdateFailHTLC arr_elem_conv;
3858                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3859                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3860                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
3861                         ret->data[i] = arr_elem_conv;
3862                 }
3863                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3864         }
3865         return (long)ret;
3866 }
3867 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
3868         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
3869         for (size_t i = 0; i < ret.datalen; i++) {
3870                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
3871         }
3872         return ret;
3873 }
3874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3875         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
3876         ret->datalen = (*env)->GetArrayLength(env, elems);
3877         if (ret->datalen == 0) {
3878                 ret->data = NULL;
3879         } else {
3880                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
3881                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3882                 for (size_t i = 0; i < ret->datalen; i++) {
3883                         int64_t arr_elem = java_elems[i];
3884                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3885                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3886                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3887                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3888                         ret->data[i] = arr_elem_conv;
3889                 }
3890                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3891         }
3892         return (long)ret;
3893 }
3894 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
3895         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
3896         for (size_t i = 0; i < ret.datalen; i++) {
3897                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
3898         }
3899         return ret;
3900 }
3901 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3902         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
3903 }
3904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3905         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3906         CHECK(val->result_ok);
3907         LDKAcceptChannel res_var = (*val->contents.result);
3908         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3909         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3910         long res_ref = (long)res_var.inner & ~1;
3911         return res_ref;
3912 }
3913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3914         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3915         CHECK(!val->result_ok);
3916         LDKDecodeError err_var = (*val->contents.err);
3917         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3918         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3919         long err_ref = (long)err_var.inner & ~1;
3920         return err_ref;
3921 }
3922 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3923         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
3924 }
3925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3926         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3927         CHECK(val->result_ok);
3928         LDKAnnouncementSignatures res_var = (*val->contents.result);
3929         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3930         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3931         long res_ref = (long)res_var.inner & ~1;
3932         return res_ref;
3933 }
3934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3935         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3936         CHECK(!val->result_ok);
3937         LDKDecodeError err_var = (*val->contents.err);
3938         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3939         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3940         long err_ref = (long)err_var.inner & ~1;
3941         return err_ref;
3942 }
3943 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3944         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
3945 }
3946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3947         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3948         CHECK(val->result_ok);
3949         LDKChannelReestablish res_var = (*val->contents.result);
3950         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3951         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3952         long res_ref = (long)res_var.inner & ~1;
3953         return res_ref;
3954 }
3955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3956         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3957         CHECK(!val->result_ok);
3958         LDKDecodeError err_var = (*val->contents.err);
3959         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3960         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3961         long err_ref = (long)err_var.inner & ~1;
3962         return err_ref;
3963 }
3964 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3965         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
3966 }
3967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3968         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
3969         CHECK(val->result_ok);
3970         LDKClosingSigned res_var = (*val->contents.result);
3971         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3972         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3973         long res_ref = (long)res_var.inner & ~1;
3974         return res_ref;
3975 }
3976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3977         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
3978         CHECK(!val->result_ok);
3979         LDKDecodeError err_var = (*val->contents.err);
3980         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3981         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3982         long err_ref = (long)err_var.inner & ~1;
3983         return err_ref;
3984 }
3985 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3986         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
3987 }
3988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3989         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
3990         CHECK(val->result_ok);
3991         LDKCommitmentSigned res_var = (*val->contents.result);
3992         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3993         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3994         long res_ref = (long)res_var.inner & ~1;
3995         return res_ref;
3996 }
3997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3998         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
3999         CHECK(!val->result_ok);
4000         LDKDecodeError err_var = (*val->contents.err);
4001         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4002         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4003         long err_ref = (long)err_var.inner & ~1;
4004         return err_ref;
4005 }
4006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4007         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
4008 }
4009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4010         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4011         CHECK(val->result_ok);
4012         LDKFundingCreated res_var = (*val->contents.result);
4013         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4014         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4015         long res_ref = (long)res_var.inner & ~1;
4016         return res_ref;
4017 }
4018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4019         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4020         CHECK(!val->result_ok);
4021         LDKDecodeError err_var = (*val->contents.err);
4022         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4023         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4024         long err_ref = (long)err_var.inner & ~1;
4025         return err_ref;
4026 }
4027 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4028         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
4029 }
4030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4031         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4032         CHECK(val->result_ok);
4033         LDKFundingSigned res_var = (*val->contents.result);
4034         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4035         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4036         long res_ref = (long)res_var.inner & ~1;
4037         return res_ref;
4038 }
4039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4040         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4041         CHECK(!val->result_ok);
4042         LDKDecodeError err_var = (*val->contents.err);
4043         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4044         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4045         long err_ref = (long)err_var.inner & ~1;
4046         return err_ref;
4047 }
4048 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4049         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
4050 }
4051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4052         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4053         CHECK(val->result_ok);
4054         LDKFundingLocked res_var = (*val->contents.result);
4055         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4056         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4057         long res_ref = (long)res_var.inner & ~1;
4058         return res_ref;
4059 }
4060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4061         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4062         CHECK(!val->result_ok);
4063         LDKDecodeError err_var = (*val->contents.err);
4064         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4065         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4066         long err_ref = (long)err_var.inner & ~1;
4067         return err_ref;
4068 }
4069 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4070         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
4071 }
4072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4073         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4074         CHECK(val->result_ok);
4075         LDKInit res_var = (*val->contents.result);
4076         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4077         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4078         long res_ref = (long)res_var.inner & ~1;
4079         return res_ref;
4080 }
4081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4082         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4083         CHECK(!val->result_ok);
4084         LDKDecodeError err_var = (*val->contents.err);
4085         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4086         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4087         long err_ref = (long)err_var.inner & ~1;
4088         return err_ref;
4089 }
4090 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4091         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
4092 }
4093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4094         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4095         CHECK(val->result_ok);
4096         LDKOpenChannel res_var = (*val->contents.result);
4097         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4098         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4099         long res_ref = (long)res_var.inner & ~1;
4100         return res_ref;
4101 }
4102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4103         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4104         CHECK(!val->result_ok);
4105         LDKDecodeError err_var = (*val->contents.err);
4106         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4107         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4108         long err_ref = (long)err_var.inner & ~1;
4109         return err_ref;
4110 }
4111 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4112         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
4113 }
4114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4115         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4116         CHECK(val->result_ok);
4117         LDKRevokeAndACK res_var = (*val->contents.result);
4118         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4119         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4120         long res_ref = (long)res_var.inner & ~1;
4121         return res_ref;
4122 }
4123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4124         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4125         CHECK(!val->result_ok);
4126         LDKDecodeError err_var = (*val->contents.err);
4127         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4128         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4129         long err_ref = (long)err_var.inner & ~1;
4130         return err_ref;
4131 }
4132 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4133         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
4134 }
4135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4136         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4137         CHECK(val->result_ok);
4138         LDKShutdown res_var = (*val->contents.result);
4139         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4140         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4141         long res_ref = (long)res_var.inner & ~1;
4142         return res_ref;
4143 }
4144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4145         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4146         CHECK(!val->result_ok);
4147         LDKDecodeError err_var = (*val->contents.err);
4148         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4149         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4150         long err_ref = (long)err_var.inner & ~1;
4151         return err_ref;
4152 }
4153 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4154         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
4155 }
4156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4157         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4158         CHECK(val->result_ok);
4159         LDKUpdateFailHTLC res_var = (*val->contents.result);
4160         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4161         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4162         long res_ref = (long)res_var.inner & ~1;
4163         return res_ref;
4164 }
4165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4166         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4167         CHECK(!val->result_ok);
4168         LDKDecodeError err_var = (*val->contents.err);
4169         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4170         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4171         long err_ref = (long)err_var.inner & ~1;
4172         return err_ref;
4173 }
4174 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4175         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
4176 }
4177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4178         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4179         CHECK(val->result_ok);
4180         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
4181         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4182         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4183         long res_ref = (long)res_var.inner & ~1;
4184         return res_ref;
4185 }
4186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4187         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4188         CHECK(!val->result_ok);
4189         LDKDecodeError err_var = (*val->contents.err);
4190         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4191         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4192         long err_ref = (long)err_var.inner & ~1;
4193         return err_ref;
4194 }
4195 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4196         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
4197 }
4198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4199         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4200         CHECK(val->result_ok);
4201         LDKUpdateFee res_var = (*val->contents.result);
4202         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4203         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4204         long res_ref = (long)res_var.inner & ~1;
4205         return res_ref;
4206 }
4207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4208         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4209         CHECK(!val->result_ok);
4210         LDKDecodeError err_var = (*val->contents.err);
4211         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4212         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4213         long err_ref = (long)err_var.inner & ~1;
4214         return err_ref;
4215 }
4216 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4217         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
4218 }
4219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4220         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4221         CHECK(val->result_ok);
4222         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
4223         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4224         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4225         long res_ref = (long)res_var.inner & ~1;
4226         return res_ref;
4227 }
4228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4229         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4230         CHECK(!val->result_ok);
4231         LDKDecodeError err_var = (*val->contents.err);
4232         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4233         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4234         long err_ref = (long)err_var.inner & ~1;
4235         return err_ref;
4236 }
4237 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4238         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
4239 }
4240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4241         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4242         CHECK(val->result_ok);
4243         LDKUpdateAddHTLC res_var = (*val->contents.result);
4244         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4245         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4246         long res_ref = (long)res_var.inner & ~1;
4247         return res_ref;
4248 }
4249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4250         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4251         CHECK(!val->result_ok);
4252         LDKDecodeError err_var = (*val->contents.err);
4253         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4254         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4255         long err_ref = (long)err_var.inner & ~1;
4256         return err_ref;
4257 }
4258 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4259         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
4260 }
4261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4262         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4263         CHECK(val->result_ok);
4264         LDKPing res_var = (*val->contents.result);
4265         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4266         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4267         long res_ref = (long)res_var.inner & ~1;
4268         return res_ref;
4269 }
4270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4271         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4272         CHECK(!val->result_ok);
4273         LDKDecodeError err_var = (*val->contents.err);
4274         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4275         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4276         long err_ref = (long)err_var.inner & ~1;
4277         return err_ref;
4278 }
4279 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4280         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
4281 }
4282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4283         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4284         CHECK(val->result_ok);
4285         LDKPong res_var = (*val->contents.result);
4286         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4287         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4288         long res_ref = (long)res_var.inner & ~1;
4289         return res_ref;
4290 }
4291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4292         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4293         CHECK(!val->result_ok);
4294         LDKDecodeError err_var = (*val->contents.err);
4295         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4296         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4297         long err_ref = (long)err_var.inner & ~1;
4298         return err_ref;
4299 }
4300 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4301         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4302 }
4303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4304         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4305         CHECK(val->result_ok);
4306         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
4307         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4308         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4309         long res_ref = (long)res_var.inner & ~1;
4310         return res_ref;
4311 }
4312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4313         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4314         CHECK(!val->result_ok);
4315         LDKDecodeError err_var = (*val->contents.err);
4316         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4317         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4318         long err_ref = (long)err_var.inner & ~1;
4319         return err_ref;
4320 }
4321 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4322         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4323 }
4324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4325         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4326         CHECK(val->result_ok);
4327         LDKChannelAnnouncement res_var = (*val->contents.result);
4328         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4329         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4330         long res_ref = (long)res_var.inner & ~1;
4331         return res_ref;
4332 }
4333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4334         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4335         CHECK(!val->result_ok);
4336         LDKDecodeError err_var = (*val->contents.err);
4337         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4338         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4339         long err_ref = (long)err_var.inner & ~1;
4340         return err_ref;
4341 }
4342 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4343         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
4344 }
4345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4346         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4347         CHECK(val->result_ok);
4348         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
4349         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4350         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4351         long res_ref = (long)res_var.inner & ~1;
4352         return res_ref;
4353 }
4354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4355         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4356         CHECK(!val->result_ok);
4357         LDKDecodeError err_var = (*val->contents.err);
4358         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4359         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4360         long err_ref = (long)err_var.inner & ~1;
4361         return err_ref;
4362 }
4363 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4364         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
4365 }
4366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4367         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4368         CHECK(val->result_ok);
4369         LDKChannelUpdate res_var = (*val->contents.result);
4370         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4371         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4372         long res_ref = (long)res_var.inner & ~1;
4373         return res_ref;
4374 }
4375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4376         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4377         CHECK(!val->result_ok);
4378         LDKDecodeError err_var = (*val->contents.err);
4379         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4380         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4381         long err_ref = (long)err_var.inner & ~1;
4382         return err_ref;
4383 }
4384 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4385         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
4386 }
4387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4388         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4389         CHECK(val->result_ok);
4390         LDKErrorMessage res_var = (*val->contents.result);
4391         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4392         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4393         long res_ref = (long)res_var.inner & ~1;
4394         return res_ref;
4395 }
4396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4397         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4398         CHECK(!val->result_ok);
4399         LDKDecodeError err_var = (*val->contents.err);
4400         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4401         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4402         long err_ref = (long)err_var.inner & ~1;
4403         return err_ref;
4404 }
4405 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4406         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4407 }
4408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4409         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4410         CHECK(val->result_ok);
4411         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
4412         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4413         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4414         long res_ref = (long)res_var.inner & ~1;
4415         return res_ref;
4416 }
4417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4418         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4419         CHECK(!val->result_ok);
4420         LDKDecodeError err_var = (*val->contents.err);
4421         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4422         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4423         long err_ref = (long)err_var.inner & ~1;
4424         return err_ref;
4425 }
4426 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4427         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4428 }
4429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4430         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4431         CHECK(val->result_ok);
4432         LDKNodeAnnouncement res_var = (*val->contents.result);
4433         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4434         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4435         long res_ref = (long)res_var.inner & ~1;
4436         return res_ref;
4437 }
4438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4439         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4440         CHECK(!val->result_ok);
4441         LDKDecodeError err_var = (*val->contents.err);
4442         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4443         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4444         long err_ref = (long)err_var.inner & ~1;
4445         return err_ref;
4446 }
4447 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4448         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
4449 }
4450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4451         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4452         CHECK(val->result_ok);
4453         LDKQueryShortChannelIds res_var = (*val->contents.result);
4454         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4455         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4456         long res_ref = (long)res_var.inner & ~1;
4457         return res_ref;
4458 }
4459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4460         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4461         CHECK(!val->result_ok);
4462         LDKDecodeError err_var = (*val->contents.err);
4463         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4464         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4465         long err_ref = (long)err_var.inner & ~1;
4466         return err_ref;
4467 }
4468 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4469         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
4470 }
4471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4472         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4473         CHECK(val->result_ok);
4474         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
4475         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4476         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4477         long res_ref = (long)res_var.inner & ~1;
4478         return res_ref;
4479 }
4480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4481         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4482         CHECK(!val->result_ok);
4483         LDKDecodeError err_var = (*val->contents.err);
4484         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4485         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4486         long err_ref = (long)err_var.inner & ~1;
4487         return err_ref;
4488 }
4489 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4490         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
4491 }
4492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4493         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4494         CHECK(val->result_ok);
4495         LDKQueryChannelRange res_var = (*val->contents.result);
4496         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4497         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4498         long res_ref = (long)res_var.inner & ~1;
4499         return res_ref;
4500 }
4501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4502         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4503         CHECK(!val->result_ok);
4504         LDKDecodeError err_var = (*val->contents.err);
4505         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4506         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4507         long err_ref = (long)err_var.inner & ~1;
4508         return err_ref;
4509 }
4510 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4511         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
4512 }
4513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4514         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4515         CHECK(val->result_ok);
4516         LDKReplyChannelRange res_var = (*val->contents.result);
4517         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4518         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4519         long res_ref = (long)res_var.inner & ~1;
4520         return res_ref;
4521 }
4522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4523         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4524         CHECK(!val->result_ok);
4525         LDKDecodeError err_var = (*val->contents.err);
4526         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4527         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4528         long err_ref = (long)err_var.inner & ~1;
4529         return err_ref;
4530 }
4531 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4532         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
4533 }
4534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4535         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4536         CHECK(val->result_ok);
4537         LDKGossipTimestampFilter res_var = (*val->contents.result);
4538         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4539         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4540         long res_ref = (long)res_var.inner & ~1;
4541         return res_ref;
4542 }
4543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4544         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4545         CHECK(!val->result_ok);
4546         LDKDecodeError err_var = (*val->contents.err);
4547         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4548         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4549         long err_ref = (long)err_var.inner & ~1;
4550         return err_ref;
4551 }
4552 typedef struct LDKMessageSendEventsProvider_JCalls {
4553         atomic_size_t refcnt;
4554         JavaVM *vm;
4555         jweak o;
4556         jmethodID get_and_clear_pending_msg_events_meth;
4557 } LDKMessageSendEventsProvider_JCalls;
4558 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
4559         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4560         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4561                 JNIEnv *env;
4562                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4563                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4564                 FREE(j_calls);
4565         }
4566 }
4567 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
4568         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4569         JNIEnv *env;
4570         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4571         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4572         CHECK(obj != NULL);
4573         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
4574         LDKCVec_MessageSendEventZ ret_constr;
4575         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
4576         if (ret_constr.datalen > 0)
4577                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4578         else
4579                 ret_constr.data = NULL;
4580         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
4581         for (size_t s = 0; s < ret_constr.datalen; s++) {
4582                 int64_t ret_conv_18 = ret_vals[s];
4583                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
4584                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)ret_conv_18);
4585                 ret_constr.data[s] = ret_conv_18_conv;
4586         }
4587         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
4588         return ret_constr;
4589 }
4590 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
4591         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4592         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4593         return (void*) this_arg;
4594 }
4595 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
4596         jclass c = (*env)->GetObjectClass(env, o);
4597         CHECK(c != NULL);
4598         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
4599         atomic_init(&calls->refcnt, 1);
4600         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4601         calls->o = (*env)->NewWeakGlobalRef(env, o);
4602         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
4603         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
4604
4605         LDKMessageSendEventsProvider ret = {
4606                 .this_arg = (void*) calls,
4607                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
4608                 .free = LDKMessageSendEventsProvider_JCalls_free,
4609         };
4610         return ret;
4611 }
4612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
4613         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
4614         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
4615         return (long)res_ptr;
4616 }
4617 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4618         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
4619         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
4620         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4621         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4622         for (size_t s = 0; s < ret_var.datalen; s++) {
4623                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
4624                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
4625                 long ret_conv_18_ref = (long)ret_conv_18_copy;
4626                 ret_arr_ptr[s] = ret_conv_18_ref;
4627         }
4628         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4629         FREE(ret_var.data);
4630         return ret_arr;
4631 }
4632
4633 typedef struct LDKEventsProvider_JCalls {
4634         atomic_size_t refcnt;
4635         JavaVM *vm;
4636         jweak o;
4637         jmethodID get_and_clear_pending_events_meth;
4638 } LDKEventsProvider_JCalls;
4639 static void LDKEventsProvider_JCalls_free(void* this_arg) {
4640         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4641         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4642                 JNIEnv *env;
4643                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4644                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4645                 FREE(j_calls);
4646         }
4647 }
4648 LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
4649         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4650         JNIEnv *env;
4651         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4652         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4653         CHECK(obj != NULL);
4654         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_events_meth);
4655         LDKCVec_EventZ ret_constr;
4656         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
4657         if (ret_constr.datalen > 0)
4658                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
4659         else
4660                 ret_constr.data = NULL;
4661         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
4662         for (size_t h = 0; h < ret_constr.datalen; h++) {
4663                 int64_t ret_conv_7 = ret_vals[h];
4664                 LDKEvent ret_conv_7_conv = *(LDKEvent*)(((uint64_t)ret_conv_7) & ~1);
4665                 ret_conv_7_conv = Event_clone((LDKEvent*)ret_conv_7);
4666                 ret_constr.data[h] = ret_conv_7_conv;
4667         }
4668         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
4669         return ret_constr;
4670 }
4671 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
4672         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4673         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4674         return (void*) this_arg;
4675 }
4676 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
4677         jclass c = (*env)->GetObjectClass(env, o);
4678         CHECK(c != NULL);
4679         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
4680         atomic_init(&calls->refcnt, 1);
4681         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4682         calls->o = (*env)->NewWeakGlobalRef(env, o);
4683         calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()[J");
4684         CHECK(calls->get_and_clear_pending_events_meth != NULL);
4685
4686         LDKEventsProvider ret = {
4687                 .this_arg = (void*) calls,
4688                 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
4689                 .free = LDKEventsProvider_JCalls_free,
4690         };
4691         return ret;
4692 }
4693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
4694         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
4695         *res_ptr = LDKEventsProvider_init(env, clz, o);
4696         return (long)res_ptr;
4697 }
4698 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_EventsProvider_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4699         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
4700         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
4701         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4702         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4703         for (size_t h = 0; h < ret_var.datalen; h++) {
4704                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
4705                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
4706                 long ret_conv_7_ref = (long)ret_conv_7_copy;
4707                 ret_arr_ptr[h] = ret_conv_7_ref;
4708         }
4709         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4710         FREE(ret_var.data);
4711         return ret_arr;
4712 }
4713
4714 typedef struct LDKAccess_JCalls {
4715         atomic_size_t refcnt;
4716         JavaVM *vm;
4717         jweak o;
4718         jmethodID get_utxo_meth;
4719 } LDKAccess_JCalls;
4720 static void LDKAccess_JCalls_free(void* this_arg) {
4721         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4722         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4723                 JNIEnv *env;
4724                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4725                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4726                 FREE(j_calls);
4727         }
4728 }
4729 LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4730         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4731         JNIEnv *env;
4732         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4733         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
4734         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
4735         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4736         CHECK(obj != NULL);
4737         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4738         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
4739         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)ret);
4740         return ret_conv;
4741 }
4742 static void* LDKAccess_JCalls_clone(const void* this_arg) {
4743         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4744         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4745         return (void*) this_arg;
4746 }
4747 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
4748         jclass c = (*env)->GetObjectClass(env, o);
4749         CHECK(c != NULL);
4750         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4751         atomic_init(&calls->refcnt, 1);
4752         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4753         calls->o = (*env)->NewWeakGlobalRef(env, o);
4754         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
4755         CHECK(calls->get_utxo_meth != NULL);
4756
4757         LDKAccess ret = {
4758                 .this_arg = (void*) calls,
4759                 .get_utxo = get_utxo_jcall,
4760                 .free = LDKAccess_JCalls_free,
4761         };
4762         return ret;
4763 }
4764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
4765         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4766         *res_ptr = LDKAccess_init(env, clz, o);
4767         return (long)res_ptr;
4768 }
4769 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) {
4770         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
4771         unsigned char genesis_hash_arr[32];
4772         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
4773         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
4774         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4775         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4776         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4777         return (long)ret_conv;
4778 }
4779
4780 typedef struct LDKListen_JCalls {
4781         atomic_size_t refcnt;
4782         JavaVM *vm;
4783         jweak o;
4784         jmethodID block_connected_meth;
4785         jmethodID block_disconnected_meth;
4786 } LDKListen_JCalls;
4787 static void LDKListen_JCalls_free(void* this_arg) {
4788         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4789         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4790                 JNIEnv *env;
4791                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4792                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4793                 FREE(j_calls);
4794         }
4795 }
4796 void block_connected_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
4797         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4798         JNIEnv *env;
4799         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4800         LDKu8slice block_var = block;
4801         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
4802         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
4803         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4804         CHECK(obj != NULL);
4805         return (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
4806 }
4807 void block_disconnected_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
4808         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4809         JNIEnv *env;
4810         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4811         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
4812         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
4813         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4814         CHECK(obj != NULL);
4815         return (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
4816 }
4817 static void* LDKListen_JCalls_clone(const void* this_arg) {
4818         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4819         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4820         return (void*) this_arg;
4821 }
4822 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
4823         jclass c = (*env)->GetObjectClass(env, o);
4824         CHECK(c != NULL);
4825         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
4826         atomic_init(&calls->refcnt, 1);
4827         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4828         calls->o = (*env)->NewWeakGlobalRef(env, o);
4829         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
4830         CHECK(calls->block_connected_meth != NULL);
4831         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
4832         CHECK(calls->block_disconnected_meth != NULL);
4833
4834         LDKListen ret = {
4835                 .this_arg = (void*) calls,
4836                 .block_connected = block_connected_jcall,
4837                 .block_disconnected = block_disconnected_jcall,
4838                 .free = LDKListen_JCalls_free,
4839         };
4840         return ret;
4841 }
4842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
4843         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
4844         *res_ptr = LDKListen_init(env, clz, o);
4845         return (long)res_ptr;
4846 }
4847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray block, int32_t height) {
4848         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4849         LDKu8slice block_ref;
4850         block_ref.datalen = (*env)->GetArrayLength(env, block);
4851         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
4852         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
4853         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
4854 }
4855
4856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1block_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height) {
4857         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4858         unsigned char header_arr[80];
4859         CHECK((*env)->GetArrayLength(env, header) == 80);
4860         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
4861         unsigned char (*header_ref)[80] = &header_arr;
4862         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
4863 }
4864
4865 typedef struct LDKFilter_JCalls {
4866         atomic_size_t refcnt;
4867         JavaVM *vm;
4868         jweak o;
4869         jmethodID register_tx_meth;
4870         jmethodID register_output_meth;
4871 } LDKFilter_JCalls;
4872 static void LDKFilter_JCalls_free(void* this_arg) {
4873         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4874         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4875                 JNIEnv *env;
4876                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4877                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4878                 FREE(j_calls);
4879         }
4880 }
4881 void register_tx_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
4882         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4883         JNIEnv *env;
4884         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4885         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
4886         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
4887         LDKu8slice script_pubkey_var = script_pubkey;
4888         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
4889         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
4890         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4891         CHECK(obj != NULL);
4892         return (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
4893 }
4894 void register_output_jcall(const void* this_arg, const LDKOutPoint * outpoint, LDKu8slice script_pubkey) {
4895         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4896         JNIEnv *env;
4897         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4898         LDKOutPoint outpoint_var = *outpoint;
4899         outpoint_var = OutPoint_clone(outpoint);
4900         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4901         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4902         long outpoint_ref = (long)outpoint_var.inner;
4903         if (outpoint_var.is_owned) {
4904                 outpoint_ref |= 1;
4905         }
4906         LDKu8slice script_pubkey_var = script_pubkey;
4907         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
4908         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
4909         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4910         CHECK(obj != NULL);
4911         return (*env)->CallVoidMethod(env, obj, j_calls->register_output_meth, outpoint_ref, script_pubkey_arr);
4912 }
4913 static void* LDKFilter_JCalls_clone(const void* this_arg) {
4914         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4915         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4916         return (void*) this_arg;
4917 }
4918 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
4919         jclass c = (*env)->GetObjectClass(env, o);
4920         CHECK(c != NULL);
4921         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
4922         atomic_init(&calls->refcnt, 1);
4923         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4924         calls->o = (*env)->NewWeakGlobalRef(env, o);
4925         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
4926         CHECK(calls->register_tx_meth != NULL);
4927         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J[B)V");
4928         CHECK(calls->register_output_meth != NULL);
4929
4930         LDKFilter ret = {
4931                 .this_arg = (void*) calls,
4932                 .register_tx = register_tx_jcall,
4933                 .register_output = register_output_jcall,
4934                 .free = LDKFilter_JCalls_free,
4935         };
4936         return ret;
4937 }
4938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
4939         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
4940         *res_ptr = LDKFilter_init(env, clz, o);
4941         return (long)res_ptr;
4942 }
4943 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) {
4944         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
4945         unsigned char txid_arr[32];
4946         CHECK((*env)->GetArrayLength(env, txid) == 32);
4947         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
4948         unsigned char (*txid_ref)[32] = &txid_arr;
4949         LDKu8slice script_pubkey_ref;
4950         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
4951         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
4952         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
4953         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
4954 }
4955
4956 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) {
4957         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
4958         LDKOutPoint outpoint_conv;
4959         outpoint_conv.inner = (void*)(outpoint & (~1));
4960         outpoint_conv.is_owned = false;
4961         LDKu8slice script_pubkey_ref;
4962         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
4963         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
4964         (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_ref);
4965         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
4966 }
4967
4968 typedef struct LDKPersist_JCalls {
4969         atomic_size_t refcnt;
4970         JavaVM *vm;
4971         jweak o;
4972         jmethodID persist_new_channel_meth;
4973         jmethodID update_persisted_channel_meth;
4974 } LDKPersist_JCalls;
4975 static void LDKPersist_JCalls_free(void* this_arg) {
4976         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4977         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4978                 JNIEnv *env;
4979                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4980                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4981                 FREE(j_calls);
4982         }
4983 }
4984 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
4985         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4986         JNIEnv *env;
4987         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4988         LDKOutPoint id_var = id;
4989         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4990         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4991         long id_ref = (long)id_var.inner;
4992         if (id_var.is_owned) {
4993                 id_ref |= 1;
4994         }
4995         LDKChannelMonitor data_var = *data;
4996         data_var = ChannelMonitor_clone(data);
4997         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4998         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4999         long data_ref = (long)data_var.inner;
5000         if (data_var.is_owned) {
5001                 data_ref |= 1;
5002         }
5003         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5004         CHECK(obj != NULL);
5005         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
5006         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5007         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
5008         return ret_conv;
5009 }
5010 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
5011         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5012         JNIEnv *env;
5013         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5014         LDKOutPoint id_var = id;
5015         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5016         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5017         long id_ref = (long)id_var.inner;
5018         if (id_var.is_owned) {
5019                 id_ref |= 1;
5020         }
5021         LDKChannelMonitorUpdate update_var = *update;
5022         update_var = ChannelMonitorUpdate_clone(update);
5023         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5024         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5025         long update_ref = (long)update_var.inner;
5026         if (update_var.is_owned) {
5027                 update_ref |= 1;
5028         }
5029         LDKChannelMonitor data_var = *data;
5030         data_var = ChannelMonitor_clone(data);
5031         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5032         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5033         long data_ref = (long)data_var.inner;
5034         if (data_var.is_owned) {
5035                 data_ref |= 1;
5036         }
5037         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5038         CHECK(obj != NULL);
5039         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
5040         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5041         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
5042         return ret_conv;
5043 }
5044 static void* LDKPersist_JCalls_clone(const void* this_arg) {
5045         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5046         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5047         return (void*) this_arg;
5048 }
5049 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
5050         jclass c = (*env)->GetObjectClass(env, o);
5051         CHECK(c != NULL);
5052         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
5053         atomic_init(&calls->refcnt, 1);
5054         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5055         calls->o = (*env)->NewWeakGlobalRef(env, o);
5056         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
5057         CHECK(calls->persist_new_channel_meth != NULL);
5058         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
5059         CHECK(calls->update_persisted_channel_meth != NULL);
5060
5061         LDKPersist ret = {
5062                 .this_arg = (void*) calls,
5063                 .persist_new_channel = persist_new_channel_jcall,
5064                 .update_persisted_channel = update_persisted_channel_jcall,
5065                 .free = LDKPersist_JCalls_free,
5066         };
5067         return ret;
5068 }
5069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
5070         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
5071         *res_ptr = LDKPersist_init(env, clz, o);
5072         return (long)res_ptr;
5073 }
5074 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) {
5075         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5076         LDKOutPoint id_conv;
5077         id_conv.inner = (void*)(id & (~1));
5078         id_conv.is_owned = (id & 1) || (id == 0);
5079         id_conv = OutPoint_clone(&id_conv);
5080         LDKChannelMonitor data_conv;
5081         data_conv.inner = (void*)(data & (~1));
5082         data_conv.is_owned = false;
5083         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5084         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
5085         return (long)ret_conv;
5086 }
5087
5088 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) {
5089         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5090         LDKOutPoint id_conv;
5091         id_conv.inner = (void*)(id & (~1));
5092         id_conv.is_owned = (id & 1) || (id == 0);
5093         id_conv = OutPoint_clone(&id_conv);
5094         LDKChannelMonitorUpdate update_conv;
5095         update_conv.inner = (void*)(update & (~1));
5096         update_conv.is_owned = false;
5097         LDKChannelMonitor data_conv;
5098         data_conv.inner = (void*)(data & (~1));
5099         data_conv.is_owned = false;
5100         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5101         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
5102         return (long)ret_conv;
5103 }
5104
5105 typedef struct LDKChannelMessageHandler_JCalls {
5106         atomic_size_t refcnt;
5107         JavaVM *vm;
5108         jweak o;
5109         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5110         jmethodID handle_open_channel_meth;
5111         jmethodID handle_accept_channel_meth;
5112         jmethodID handle_funding_created_meth;
5113         jmethodID handle_funding_signed_meth;
5114         jmethodID handle_funding_locked_meth;
5115         jmethodID handle_shutdown_meth;
5116         jmethodID handle_closing_signed_meth;
5117         jmethodID handle_update_add_htlc_meth;
5118         jmethodID handle_update_fulfill_htlc_meth;
5119         jmethodID handle_update_fail_htlc_meth;
5120         jmethodID handle_update_fail_malformed_htlc_meth;
5121         jmethodID handle_commitment_signed_meth;
5122         jmethodID handle_revoke_and_ack_meth;
5123         jmethodID handle_update_fee_meth;
5124         jmethodID handle_announcement_signatures_meth;
5125         jmethodID peer_disconnected_meth;
5126         jmethodID peer_connected_meth;
5127         jmethodID handle_channel_reestablish_meth;
5128         jmethodID handle_error_meth;
5129 } LDKChannelMessageHandler_JCalls;
5130 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
5131         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5132         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5133                 JNIEnv *env;
5134                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5135                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5136                 FREE(j_calls);
5137         }
5138 }
5139 void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
5140         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5141         JNIEnv *env;
5142         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5143         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5144         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5145         LDKInitFeatures their_features_var = their_features;
5146         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5147         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5148         long their_features_ref = (long)their_features_var.inner;
5149         if (their_features_var.is_owned) {
5150                 their_features_ref |= 1;
5151         }
5152         LDKOpenChannel msg_var = *msg;
5153         msg_var = OpenChannel_clone(msg);
5154         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5155         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5156         long msg_ref = (long)msg_var.inner;
5157         if (msg_var.is_owned) {
5158                 msg_ref |= 1;
5159         }
5160         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5161         CHECK(obj != NULL);
5162         return (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5163 }
5164 void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
5165         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5166         JNIEnv *env;
5167         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5168         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5169         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5170         LDKInitFeatures their_features_var = their_features;
5171         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5172         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5173         long their_features_ref = (long)their_features_var.inner;
5174         if (their_features_var.is_owned) {
5175                 their_features_ref |= 1;
5176         }
5177         LDKAcceptChannel msg_var = *msg;
5178         msg_var = AcceptChannel_clone(msg);
5179         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5180         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5181         long msg_ref = (long)msg_var.inner;
5182         if (msg_var.is_owned) {
5183                 msg_ref |= 1;
5184         }
5185         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5186         CHECK(obj != NULL);
5187         return (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5188 }
5189 void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
5190         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5191         JNIEnv *env;
5192         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5193         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5194         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5195         LDKFundingCreated msg_var = *msg;
5196         msg_var = FundingCreated_clone(msg);
5197         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5198         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5199         long msg_ref = (long)msg_var.inner;
5200         if (msg_var.is_owned) {
5201                 msg_ref |= 1;
5202         }
5203         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5204         CHECK(obj != NULL);
5205         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
5206 }
5207 void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
5208         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5209         JNIEnv *env;
5210         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5211         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5212         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5213         LDKFundingSigned msg_var = *msg;
5214         msg_var = FundingSigned_clone(msg);
5215         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5216         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5217         long msg_ref = (long)msg_var.inner;
5218         if (msg_var.is_owned) {
5219                 msg_ref |= 1;
5220         }
5221         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5222         CHECK(obj != NULL);
5223         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
5224 }
5225 void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
5226         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5227         JNIEnv *env;
5228         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5229         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5230         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5231         LDKFundingLocked msg_var = *msg;
5232         msg_var = FundingLocked_clone(msg);
5233         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5234         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5235         long msg_ref = (long)msg_var.inner;
5236         if (msg_var.is_owned) {
5237                 msg_ref |= 1;
5238         }
5239         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5240         CHECK(obj != NULL);
5241         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
5242 }
5243 void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
5244         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5245         JNIEnv *env;
5246         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5247         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5248         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5249         LDKInitFeatures their_features_var = *their_features;
5250         their_features_var = InitFeatures_clone(their_features);
5251         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5252         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5253         long their_features_ref = (long)their_features_var.inner;
5254         if (their_features_var.is_owned) {
5255                 their_features_ref |= 1;
5256         }
5257         LDKShutdown msg_var = *msg;
5258         msg_var = Shutdown_clone(msg);
5259         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5260         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5261         long msg_ref = (long)msg_var.inner;
5262         if (msg_var.is_owned) {
5263                 msg_ref |= 1;
5264         }
5265         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5266         CHECK(obj != NULL);
5267         return (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
5268 }
5269 void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
5270         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5271         JNIEnv *env;
5272         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5273         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5274         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5275         LDKClosingSigned msg_var = *msg;
5276         msg_var = ClosingSigned_clone(msg);
5277         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5278         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5279         long msg_ref = (long)msg_var.inner;
5280         if (msg_var.is_owned) {
5281                 msg_ref |= 1;
5282         }
5283         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5284         CHECK(obj != NULL);
5285         return (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
5286 }
5287 void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
5288         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5289         JNIEnv *env;
5290         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5291         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5292         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5293         LDKUpdateAddHTLC msg_var = *msg;
5294         msg_var = UpdateAddHTLC_clone(msg);
5295         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5296         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5297         long msg_ref = (long)msg_var.inner;
5298         if (msg_var.is_owned) {
5299                 msg_ref |= 1;
5300         }
5301         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5302         CHECK(obj != NULL);
5303         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
5304 }
5305 void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
5306         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5307         JNIEnv *env;
5308         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5309         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5310         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5311         LDKUpdateFulfillHTLC msg_var = *msg;
5312         msg_var = UpdateFulfillHTLC_clone(msg);
5313         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5314         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5315         long msg_ref = (long)msg_var.inner;
5316         if (msg_var.is_owned) {
5317                 msg_ref |= 1;
5318         }
5319         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5320         CHECK(obj != NULL);
5321         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
5322 }
5323 void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
5324         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5325         JNIEnv *env;
5326         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5327         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5328         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5329         LDKUpdateFailHTLC msg_var = *msg;
5330         msg_var = UpdateFailHTLC_clone(msg);
5331         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5332         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5333         long msg_ref = (long)msg_var.inner;
5334         if (msg_var.is_owned) {
5335                 msg_ref |= 1;
5336         }
5337         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5338         CHECK(obj != NULL);
5339         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
5340 }
5341 void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
5342         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5343         JNIEnv *env;
5344         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5345         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5346         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5347         LDKUpdateFailMalformedHTLC msg_var = *msg;
5348         msg_var = UpdateFailMalformedHTLC_clone(msg);
5349         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5350         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5351         long msg_ref = (long)msg_var.inner;
5352         if (msg_var.is_owned) {
5353                 msg_ref |= 1;
5354         }
5355         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5356         CHECK(obj != NULL);
5357         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
5358 }
5359 void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
5360         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5361         JNIEnv *env;
5362         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5363         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5364         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5365         LDKCommitmentSigned msg_var = *msg;
5366         msg_var = CommitmentSigned_clone(msg);
5367         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5368         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5369         long msg_ref = (long)msg_var.inner;
5370         if (msg_var.is_owned) {
5371                 msg_ref |= 1;
5372         }
5373         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5374         CHECK(obj != NULL);
5375         return (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
5376 }
5377 void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
5378         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5379         JNIEnv *env;
5380         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5381         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5382         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5383         LDKRevokeAndACK msg_var = *msg;
5384         msg_var = RevokeAndACK_clone(msg);
5385         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5386         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5387         long msg_ref = (long)msg_var.inner;
5388         if (msg_var.is_owned) {
5389                 msg_ref |= 1;
5390         }
5391         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5392         CHECK(obj != NULL);
5393         return (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
5394 }
5395 void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
5396         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5397         JNIEnv *env;
5398         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5399         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5400         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5401         LDKUpdateFee msg_var = *msg;
5402         msg_var = UpdateFee_clone(msg);
5403         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5404         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5405         long msg_ref = (long)msg_var.inner;
5406         if (msg_var.is_owned) {
5407                 msg_ref |= 1;
5408         }
5409         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5410         CHECK(obj != NULL);
5411         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
5412 }
5413 void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
5414         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5415         JNIEnv *env;
5416         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5417         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5418         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5419         LDKAnnouncementSignatures msg_var = *msg;
5420         msg_var = AnnouncementSignatures_clone(msg);
5421         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5422         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5423         long msg_ref = (long)msg_var.inner;
5424         if (msg_var.is_owned) {
5425                 msg_ref |= 1;
5426         }
5427         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5428         CHECK(obj != NULL);
5429         return (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
5430 }
5431 void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
5432         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5433         JNIEnv *env;
5434         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5435         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5436         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5437         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5438         CHECK(obj != NULL);
5439         return (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
5440 }
5441 void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
5442         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5443         JNIEnv *env;
5444         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5445         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5446         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5447         LDKInit msg_var = *msg;
5448         msg_var = Init_clone(msg);
5449         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5450         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5451         long msg_ref = (long)msg_var.inner;
5452         if (msg_var.is_owned) {
5453                 msg_ref |= 1;
5454         }
5455         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5456         CHECK(obj != NULL);
5457         return (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
5458 }
5459 void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
5460         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_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         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5464         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5465         LDKChannelReestablish msg_var = *msg;
5466         msg_var = ChannelReestablish_clone(msg);
5467         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5468         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5469         long msg_ref = (long)msg_var.inner;
5470         if (msg_var.is_owned) {
5471                 msg_ref |= 1;
5472         }
5473         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5474         CHECK(obj != NULL);
5475         return (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
5476 }
5477 void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
5478         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5479         JNIEnv *env;
5480         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5481         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5482         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5483         LDKErrorMessage msg_var = *msg;
5484         msg_var = ErrorMessage_clone(msg);
5485         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5486         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5487         long msg_ref = (long)msg_var.inner;
5488         if (msg_var.is_owned) {
5489                 msg_ref |= 1;
5490         }
5491         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5492         CHECK(obj != NULL);
5493         return (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
5494 }
5495 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
5496         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5497         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5498         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5499         return (void*) this_arg;
5500 }
5501 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
5502         jclass c = (*env)->GetObjectClass(env, o);
5503         CHECK(c != NULL);
5504         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
5505         atomic_init(&calls->refcnt, 1);
5506         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5507         calls->o = (*env)->NewWeakGlobalRef(env, o);
5508         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
5509         CHECK(calls->handle_open_channel_meth != NULL);
5510         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
5511         CHECK(calls->handle_accept_channel_meth != NULL);
5512         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
5513         CHECK(calls->handle_funding_created_meth != NULL);
5514         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
5515         CHECK(calls->handle_funding_signed_meth != NULL);
5516         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
5517         CHECK(calls->handle_funding_locked_meth != NULL);
5518         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
5519         CHECK(calls->handle_shutdown_meth != NULL);
5520         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
5521         CHECK(calls->handle_closing_signed_meth != NULL);
5522         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
5523         CHECK(calls->handle_update_add_htlc_meth != NULL);
5524         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
5525         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
5526         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
5527         CHECK(calls->handle_update_fail_htlc_meth != NULL);
5528         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
5529         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
5530         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
5531         CHECK(calls->handle_commitment_signed_meth != NULL);
5532         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
5533         CHECK(calls->handle_revoke_and_ack_meth != NULL);
5534         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
5535         CHECK(calls->handle_update_fee_meth != NULL);
5536         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
5537         CHECK(calls->handle_announcement_signatures_meth != NULL);
5538         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
5539         CHECK(calls->peer_disconnected_meth != NULL);
5540         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
5541         CHECK(calls->peer_connected_meth != NULL);
5542         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
5543         CHECK(calls->handle_channel_reestablish_meth != NULL);
5544         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
5545         CHECK(calls->handle_error_meth != NULL);
5546
5547         LDKChannelMessageHandler ret = {
5548                 .this_arg = (void*) calls,
5549                 .handle_open_channel = handle_open_channel_jcall,
5550                 .handle_accept_channel = handle_accept_channel_jcall,
5551                 .handle_funding_created = handle_funding_created_jcall,
5552                 .handle_funding_signed = handle_funding_signed_jcall,
5553                 .handle_funding_locked = handle_funding_locked_jcall,
5554                 .handle_shutdown = handle_shutdown_jcall,
5555                 .handle_closing_signed = handle_closing_signed_jcall,
5556                 .handle_update_add_htlc = handle_update_add_htlc_jcall,
5557                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
5558                 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
5559                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
5560                 .handle_commitment_signed = handle_commitment_signed_jcall,
5561                 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
5562                 .handle_update_fee = handle_update_fee_jcall,
5563                 .handle_announcement_signatures = handle_announcement_signatures_jcall,
5564                 .peer_disconnected = peer_disconnected_jcall,
5565                 .peer_connected = peer_connected_jcall,
5566                 .handle_channel_reestablish = handle_channel_reestablish_jcall,
5567                 .handle_error = handle_error_jcall,
5568                 .free = LDKChannelMessageHandler_JCalls_free,
5569                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
5570         };
5571         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5572         return ret;
5573 }
5574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
5575         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
5576         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
5577         return (long)res_ptr;
5578 }
5579 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) {
5580         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5581         LDKPublicKey their_node_id_ref;
5582         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5583         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5584         LDKInitFeatures their_features_conv;
5585         their_features_conv.inner = (void*)(their_features & (~1));
5586         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5587         their_features_conv = InitFeatures_clone(&their_features_conv);
5588         LDKOpenChannel msg_conv;
5589         msg_conv.inner = (void*)(msg & (~1));
5590         msg_conv.is_owned = false;
5591         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5592 }
5593
5594 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) {
5595         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5596         LDKPublicKey their_node_id_ref;
5597         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5598         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5599         LDKInitFeatures their_features_conv;
5600         their_features_conv.inner = (void*)(their_features & (~1));
5601         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5602         their_features_conv = InitFeatures_clone(&their_features_conv);
5603         LDKAcceptChannel msg_conv;
5604         msg_conv.inner = (void*)(msg & (~1));
5605         msg_conv.is_owned = false;
5606         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5607 }
5608
5609 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) {
5610         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5611         LDKPublicKey their_node_id_ref;
5612         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5613         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5614         LDKFundingCreated msg_conv;
5615         msg_conv.inner = (void*)(msg & (~1));
5616         msg_conv.is_owned = false;
5617         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5618 }
5619
5620 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) {
5621         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5622         LDKPublicKey their_node_id_ref;
5623         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5624         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5625         LDKFundingSigned msg_conv;
5626         msg_conv.inner = (void*)(msg & (~1));
5627         msg_conv.is_owned = false;
5628         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5629 }
5630
5631 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) {
5632         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5633         LDKPublicKey their_node_id_ref;
5634         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5635         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5636         LDKFundingLocked msg_conv;
5637         msg_conv.inner = (void*)(msg & (~1));
5638         msg_conv.is_owned = false;
5639         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5640 }
5641
5642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1shutdown(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t their_features, int64_t msg) {
5643         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5644         LDKPublicKey their_node_id_ref;
5645         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5646         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5647         LDKInitFeatures their_features_conv;
5648         their_features_conv.inner = (void*)(their_features & (~1));
5649         their_features_conv.is_owned = false;
5650         LDKShutdown msg_conv;
5651         msg_conv.inner = (void*)(msg & (~1));
5652         msg_conv.is_owned = false;
5653         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
5654 }
5655
5656 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) {
5657         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5658         LDKPublicKey their_node_id_ref;
5659         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5660         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5661         LDKClosingSigned msg_conv;
5662         msg_conv.inner = (void*)(msg & (~1));
5663         msg_conv.is_owned = false;
5664         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5665 }
5666
5667 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) {
5668         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5669         LDKPublicKey their_node_id_ref;
5670         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5671         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5672         LDKUpdateAddHTLC msg_conv;
5673         msg_conv.inner = (void*)(msg & (~1));
5674         msg_conv.is_owned = false;
5675         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5676 }
5677
5678 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) {
5679         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5680         LDKPublicKey their_node_id_ref;
5681         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5682         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5683         LDKUpdateFulfillHTLC msg_conv;
5684         msg_conv.inner = (void*)(msg & (~1));
5685         msg_conv.is_owned = false;
5686         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5687 }
5688
5689 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) {
5690         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5691         LDKPublicKey their_node_id_ref;
5692         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5693         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5694         LDKUpdateFailHTLC msg_conv;
5695         msg_conv.inner = (void*)(msg & (~1));
5696         msg_conv.is_owned = false;
5697         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5698 }
5699
5700 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) {
5701         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5702         LDKPublicKey their_node_id_ref;
5703         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5704         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5705         LDKUpdateFailMalformedHTLC msg_conv;
5706         msg_conv.inner = (void*)(msg & (~1));
5707         msg_conv.is_owned = false;
5708         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5709 }
5710
5711 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) {
5712         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5713         LDKPublicKey their_node_id_ref;
5714         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5715         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5716         LDKCommitmentSigned msg_conv;
5717         msg_conv.inner = (void*)(msg & (~1));
5718         msg_conv.is_owned = false;
5719         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5720 }
5721
5722 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) {
5723         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5724         LDKPublicKey their_node_id_ref;
5725         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5726         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5727         LDKRevokeAndACK msg_conv;
5728         msg_conv.inner = (void*)(msg & (~1));
5729         msg_conv.is_owned = false;
5730         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5731 }
5732
5733 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) {
5734         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5735         LDKPublicKey their_node_id_ref;
5736         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5737         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5738         LDKUpdateFee msg_conv;
5739         msg_conv.inner = (void*)(msg & (~1));
5740         msg_conv.is_owned = false;
5741         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5742 }
5743
5744 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) {
5745         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5746         LDKPublicKey their_node_id_ref;
5747         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5748         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5749         LDKAnnouncementSignatures msg_conv;
5750         msg_conv.inner = (void*)(msg & (~1));
5751         msg_conv.is_owned = false;
5752         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5753 }
5754
5755 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) {
5756         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5757         LDKPublicKey their_node_id_ref;
5758         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5759         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5760         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
5761 }
5762
5763 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) {
5764         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5765         LDKPublicKey their_node_id_ref;
5766         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5767         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5768         LDKInit msg_conv;
5769         msg_conv.inner = (void*)(msg & (~1));
5770         msg_conv.is_owned = false;
5771         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5772 }
5773
5774 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) {
5775         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5776         LDKPublicKey their_node_id_ref;
5777         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5778         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5779         LDKChannelReestablish msg_conv;
5780         msg_conv.inner = (void*)(msg & (~1));
5781         msg_conv.is_owned = false;
5782         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5783 }
5784
5785 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) {
5786         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5787         LDKPublicKey their_node_id_ref;
5788         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5789         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5790         LDKErrorMessage msg_conv;
5791         msg_conv.inner = (void*)(msg & (~1));
5792         msg_conv.is_owned = false;
5793         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5794 }
5795
5796 typedef struct LDKRoutingMessageHandler_JCalls {
5797         atomic_size_t refcnt;
5798         JavaVM *vm;
5799         jweak o;
5800         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5801         jmethodID handle_node_announcement_meth;
5802         jmethodID handle_channel_announcement_meth;
5803         jmethodID handle_channel_update_meth;
5804         jmethodID handle_htlc_fail_channel_update_meth;
5805         jmethodID get_next_channel_announcements_meth;
5806         jmethodID get_next_node_announcements_meth;
5807         jmethodID sync_routing_table_meth;
5808         jmethodID handle_reply_channel_range_meth;
5809         jmethodID handle_reply_short_channel_ids_end_meth;
5810         jmethodID handle_query_channel_range_meth;
5811         jmethodID handle_query_short_channel_ids_meth;
5812 } LDKRoutingMessageHandler_JCalls;
5813 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
5814         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5815         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5816                 JNIEnv *env;
5817                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5818                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5819                 FREE(j_calls);
5820         }
5821 }
5822 LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
5823         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5824         JNIEnv *env;
5825         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5826         LDKNodeAnnouncement msg_var = *msg;
5827         msg_var = NodeAnnouncement_clone(msg);
5828         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5829         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5830         long msg_ref = (long)msg_var.inner;
5831         if (msg_var.is_owned) {
5832                 msg_ref |= 1;
5833         }
5834         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5835         CHECK(obj != NULL);
5836         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
5837         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5838         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
5839         return ret_conv;
5840 }
5841 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
5842         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5843         JNIEnv *env;
5844         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5845         LDKChannelAnnouncement msg_var = *msg;
5846         msg_var = ChannelAnnouncement_clone(msg);
5847         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5848         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5849         long msg_ref = (long)msg_var.inner;
5850         if (msg_var.is_owned) {
5851                 msg_ref |= 1;
5852         }
5853         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5854         CHECK(obj != NULL);
5855         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
5856         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5857         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
5858         return ret_conv;
5859 }
5860 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
5861         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5862         JNIEnv *env;
5863         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5864         LDKChannelUpdate msg_var = *msg;
5865         msg_var = ChannelUpdate_clone(msg);
5866         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5867         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5868         long msg_ref = (long)msg_var.inner;
5869         if (msg_var.is_owned) {
5870                 msg_ref |= 1;
5871         }
5872         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5873         CHECK(obj != NULL);
5874         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
5875         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5876         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
5877         return ret_conv;
5878 }
5879 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
5880         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5881         JNIEnv *env;
5882         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5883         long ret_update = (long)update;
5884         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5885         CHECK(obj != NULL);
5886         return (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
5887 }
5888 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
5889         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5890         JNIEnv *env;
5891         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5892         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5893         CHECK(obj != NULL);
5894         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
5895         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
5896         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
5897         if (ret_constr.datalen > 0)
5898                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
5899         else
5900                 ret_constr.data = NULL;
5901         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
5902         for (size_t l = 0; l < ret_constr.datalen; l++) {
5903                 int64_t ret_conv_63 = ret_vals[l];
5904                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
5905                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ret_conv_63);
5906                 ret_constr.data[l] = ret_conv_63_conv;
5907         }
5908         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
5909         return ret_constr;
5910 }
5911 LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
5912         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_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         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
5916         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
5917         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5918         CHECK(obj != NULL);
5919         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
5920         LDKCVec_NodeAnnouncementZ ret_constr;
5921         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
5922         if (ret_constr.datalen > 0)
5923                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
5924         else
5925                 ret_constr.data = NULL;
5926         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
5927         for (size_t s = 0; s < ret_constr.datalen; s++) {
5928                 int64_t ret_conv_18 = ret_vals[s];
5929                 LDKNodeAnnouncement ret_conv_18_conv;
5930                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
5931                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
5932                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
5933                 ret_constr.data[s] = ret_conv_18_conv;
5934         }
5935         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
5936         return ret_constr;
5937 }
5938 void sync_routing_table_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
5939         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5940         JNIEnv *env;
5941         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5942         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5943         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5944         LDKInit init_var = *init;
5945         init_var = Init_clone(init);
5946         CHECK((((long)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5947         CHECK((((long)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5948         long init_ref = (long)init_var.inner;
5949         if (init_var.is_owned) {
5950                 init_ref |= 1;
5951         }
5952         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5953         CHECK(obj != NULL);
5954         return (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
5955 }
5956 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
5957         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5958         JNIEnv *env;
5959         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5960         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5961         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5962         LDKReplyChannelRange msg_var = msg;
5963         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5964         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5965         long msg_ref = (long)msg_var.inner;
5966         if (msg_var.is_owned) {
5967                 msg_ref |= 1;
5968         }
5969         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5970         CHECK(obj != NULL);
5971         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
5972         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5973         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
5974         return ret_conv;
5975 }
5976 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
5977         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5978         JNIEnv *env;
5979         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5980         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5981         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5982         LDKReplyShortChannelIdsEnd msg_var = msg;
5983         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5984         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5985         long msg_ref = (long)msg_var.inner;
5986         if (msg_var.is_owned) {
5987                 msg_ref |= 1;
5988         }
5989         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5990         CHECK(obj != NULL);
5991         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
5992         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5993         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
5994         return ret_conv;
5995 }
5996 LDKCResult_NoneLightningErrorZ handle_query_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
5997         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5998         JNIEnv *env;
5999         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6000         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6001         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6002         LDKQueryChannelRange msg_var = msg;
6003         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6004         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6005         long msg_ref = (long)msg_var.inner;
6006         if (msg_var.is_owned) {
6007                 msg_ref |= 1;
6008         }
6009         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6010         CHECK(obj != NULL);
6011         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
6012         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6013         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
6014         return ret_conv;
6015 }
6016 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
6017         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6018         JNIEnv *env;
6019         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6020         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6021         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6022         LDKQueryShortChannelIds msg_var = msg;
6023         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6024         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6025         long msg_ref = (long)msg_var.inner;
6026         if (msg_var.is_owned) {
6027                 msg_ref |= 1;
6028         }
6029         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6030         CHECK(obj != NULL);
6031         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
6032         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6033         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
6034         return ret_conv;
6035 }
6036 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
6037         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6038         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6039         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6040         return (void*) this_arg;
6041 }
6042 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
6043         jclass c = (*env)->GetObjectClass(env, o);
6044         CHECK(c != NULL);
6045         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
6046         atomic_init(&calls->refcnt, 1);
6047         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6048         calls->o = (*env)->NewWeakGlobalRef(env, o);
6049         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
6050         CHECK(calls->handle_node_announcement_meth != NULL);
6051         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
6052         CHECK(calls->handle_channel_announcement_meth != NULL);
6053         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
6054         CHECK(calls->handle_channel_update_meth != NULL);
6055         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
6056         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
6057         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
6058         CHECK(calls->get_next_channel_announcements_meth != NULL);
6059         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
6060         CHECK(calls->get_next_node_announcements_meth != NULL);
6061         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
6062         CHECK(calls->sync_routing_table_meth != NULL);
6063         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
6064         CHECK(calls->handle_reply_channel_range_meth != NULL);
6065         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
6066         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
6067         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
6068         CHECK(calls->handle_query_channel_range_meth != NULL);
6069         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
6070         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
6071
6072         LDKRoutingMessageHandler ret = {
6073                 .this_arg = (void*) calls,
6074                 .handle_node_announcement = handle_node_announcement_jcall,
6075                 .handle_channel_announcement = handle_channel_announcement_jcall,
6076                 .handle_channel_update = handle_channel_update_jcall,
6077                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
6078                 .get_next_channel_announcements = get_next_channel_announcements_jcall,
6079                 .get_next_node_announcements = get_next_node_announcements_jcall,
6080                 .sync_routing_table = sync_routing_table_jcall,
6081                 .handle_reply_channel_range = handle_reply_channel_range_jcall,
6082                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_jcall,
6083                 .handle_query_channel_range = handle_query_channel_range_jcall,
6084                 .handle_query_short_channel_ids = handle_query_short_channel_ids_jcall,
6085                 .free = LDKRoutingMessageHandler_JCalls_free,
6086                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
6087         };
6088         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6089         return ret;
6090 }
6091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
6092         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
6093         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
6094         return (long)res_ptr;
6095 }
6096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6097         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6098         LDKNodeAnnouncement msg_conv;
6099         msg_conv.inner = (void*)(msg & (~1));
6100         msg_conv.is_owned = false;
6101         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6102         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
6103         return (long)ret_conv;
6104 }
6105
6106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6107         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6108         LDKChannelAnnouncement msg_conv;
6109         msg_conv.inner = (void*)(msg & (~1));
6110         msg_conv.is_owned = false;
6111         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6112         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6113         return (long)ret_conv;
6114 }
6115
6116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6117         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6118         LDKChannelUpdate msg_conv;
6119         msg_conv.inner = (void*)(msg & (~1));
6120         msg_conv.is_owned = false;
6121         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6122         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
6123         return (long)ret_conv;
6124 }
6125
6126 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) {
6127         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6128         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
6129         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
6130 }
6131
6132 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) {
6133         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6134         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
6135         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6136         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6137         for (size_t l = 0; l < ret_var.datalen; l++) {
6138                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6139                 *ret_conv_63_ref = ret_var.data[l];
6140                 ret_arr_ptr[l] = (long)ret_conv_63_ref;
6141         }
6142         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6143         FREE(ret_var.data);
6144         return ret_arr;
6145 }
6146
6147 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) {
6148         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6149         LDKPublicKey starting_point_ref;
6150         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
6151         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
6152         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
6153         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6154         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6155         for (size_t s = 0; s < ret_var.datalen; s++) {
6156                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
6157                 CHECK((((long)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6158                 CHECK((((long)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6159                 long ret_conv_18_ref = (long)ret_conv_18_var.inner;
6160                 if (ret_conv_18_var.is_owned) {
6161                         ret_conv_18_ref |= 1;
6162                 }
6163                 ret_arr_ptr[s] = ret_conv_18_ref;
6164         }
6165         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6166         FREE(ret_var.data);
6167         return ret_arr;
6168 }
6169
6170 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) {
6171         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6172         LDKPublicKey their_node_id_ref;
6173         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6174         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6175         LDKInit init_conv;
6176         init_conv.inner = (void*)(init & (~1));
6177         init_conv.is_owned = false;
6178         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
6179 }
6180
6181 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) {
6182         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6183         LDKPublicKey their_node_id_ref;
6184         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6185         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6186         LDKReplyChannelRange msg_conv;
6187         msg_conv.inner = (void*)(msg & (~1));
6188         msg_conv.is_owned = (msg & 1) || (msg == 0);
6189         msg_conv = ReplyChannelRange_clone(&msg_conv);
6190         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6191         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6192         return (long)ret_conv;
6193 }
6194
6195 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) {
6196         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6197         LDKPublicKey their_node_id_ref;
6198         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6199         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6200         LDKReplyShortChannelIdsEnd msg_conv;
6201         msg_conv.inner = (void*)(msg & (~1));
6202         msg_conv.is_owned = (msg & 1) || (msg == 0);
6203         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
6204         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6205         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6206         return (long)ret_conv;
6207 }
6208
6209 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) {
6210         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6211         LDKPublicKey their_node_id_ref;
6212         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6213         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6214         LDKQueryChannelRange msg_conv;
6215         msg_conv.inner = (void*)(msg & (~1));
6216         msg_conv.is_owned = (msg & 1) || (msg == 0);
6217         msg_conv = QueryChannelRange_clone(&msg_conv);
6218         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6219         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6220         return (long)ret_conv;
6221 }
6222
6223 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) {
6224         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6225         LDKPublicKey their_node_id_ref;
6226         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6227         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6228         LDKQueryShortChannelIds msg_conv;
6229         msg_conv.inner = (void*)(msg & (~1));
6230         msg_conv.is_owned = (msg & 1) || (msg == 0);
6231         msg_conv = QueryShortChannelIds_clone(&msg_conv);
6232         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6233         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6234         return (long)ret_conv;
6235 }
6236
6237 typedef struct LDKSocketDescriptor_JCalls {
6238         atomic_size_t refcnt;
6239         JavaVM *vm;
6240         jweak o;
6241         jmethodID send_data_meth;
6242         jmethodID disconnect_socket_meth;
6243         jmethodID eq_meth;
6244         jmethodID hash_meth;
6245 } LDKSocketDescriptor_JCalls;
6246 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
6247         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6248         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6249                 JNIEnv *env;
6250                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6251                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6252                 FREE(j_calls);
6253         }
6254 }
6255 uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
6256         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6257         JNIEnv *env;
6258         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6259         LDKu8slice data_var = data;
6260         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
6261         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
6262         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6263         CHECK(obj != NULL);
6264         return (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
6265 }
6266 void disconnect_socket_jcall(void* this_arg) {
6267         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6268         JNIEnv *env;
6269         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6270         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6271         CHECK(obj != NULL);
6272         return (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
6273 }
6274 bool eq_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
6275         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6276         JNIEnv *env;
6277         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6278         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6279         *other_arg_clone = SocketDescriptor_clone(other_arg);
6280         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6281         CHECK(obj != NULL);
6282         return (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (long)other_arg_clone);
6283 }
6284 uint64_t hash_jcall(const void* this_arg) {
6285         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6286         JNIEnv *env;
6287         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6288         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6289         CHECK(obj != NULL);
6290         return (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
6291 }
6292 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
6293         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6294         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6295         return (void*) this_arg;
6296 }
6297 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
6298         jclass c = (*env)->GetObjectClass(env, o);
6299         CHECK(c != NULL);
6300         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
6301         atomic_init(&calls->refcnt, 1);
6302         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6303         calls->o = (*env)->NewWeakGlobalRef(env, o);
6304         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
6305         CHECK(calls->send_data_meth != NULL);
6306         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
6307         CHECK(calls->disconnect_socket_meth != NULL);
6308         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
6309         CHECK(calls->eq_meth != NULL);
6310         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
6311         CHECK(calls->hash_meth != NULL);
6312
6313         LDKSocketDescriptor ret = {
6314                 .this_arg = (void*) calls,
6315                 .send_data = send_data_jcall,
6316                 .disconnect_socket = disconnect_socket_jcall,
6317                 .eq = eq_jcall,
6318                 .hash = hash_jcall,
6319                 .clone = LDKSocketDescriptor_JCalls_clone,
6320                 .free = LDKSocketDescriptor_JCalls_free,
6321         };
6322         return ret;
6323 }
6324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
6325         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6326         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
6327         return (long)res_ptr;
6328 }
6329 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) {
6330         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6331         LDKu8slice data_ref;
6332         data_ref.datalen = (*env)->GetArrayLength(env, data);
6333         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
6334         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
6335         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
6336         return ret_val;
6337 }
6338
6339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
6340         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6341         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
6342 }
6343
6344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
6345         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6346         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
6347         return ret_val;
6348 }
6349
6350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
6351         LDKTransaction _res_ref;
6352         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
6353         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
6354         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
6355         _res_ref.data_is_owned = true;
6356         Transaction_free(_res_ref);
6357 }
6358
6359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
6360         if ((_res & 1) != 0) return;
6361         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
6362         FREE((void*)_res);
6363         TxOut_free(_res_conv);
6364 }
6365
6366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6367         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
6368         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6369         *ret_ref = TxOut_clone(orig_conv);
6370         return (long)ret_ref;
6371 }
6372
6373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
6374         LDKSecretKey o_ref;
6375         CHECK((*env)->GetArrayLength(env, o) == 32);
6376         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
6377         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6378         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
6379         return (long)ret_conv;
6380 }
6381
6382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6383         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6384         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6385         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
6386         return (long)ret_conv;
6387 }
6388
6389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6390         if ((_res & 1) != 0) return;
6391         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
6392         FREE((void*)_res);
6393         CResult_SecretKeyErrorZ_free(_res_conv);
6394 }
6395
6396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
6397         LDKPublicKey o_ref;
6398         CHECK((*env)->GetArrayLength(env, o) == 33);
6399         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
6400         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6401         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
6402         return (long)ret_conv;
6403 }
6404
6405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6406         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6407         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6408         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
6409         return (long)ret_conv;
6410 }
6411
6412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6413         if ((_res & 1) != 0) return;
6414         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
6415         FREE((void*)_res);
6416         CResult_PublicKeyErrorZ_free(_res_conv);
6417 }
6418
6419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6420         LDKTxCreationKeys o_conv;
6421         o_conv.inner = (void*)(o & (~1));
6422         o_conv.is_owned = (o & 1) || (o == 0);
6423         o_conv = TxCreationKeys_clone(&o_conv);
6424         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6425         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
6426         return (long)ret_conv;
6427 }
6428
6429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6430         LDKDecodeError e_conv;
6431         e_conv.inner = (void*)(e & (~1));
6432         e_conv.is_owned = (e & 1) || (e == 0);
6433         e_conv = DecodeError_clone(&e_conv);
6434         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6435         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
6436         return (long)ret_conv;
6437 }
6438
6439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6440         if ((_res & 1) != 0) return;
6441         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6442         FREE((void*)_res);
6443         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
6444 }
6445
6446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6447         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
6448         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6449         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
6450         return (long)ret_conv;
6451 }
6452
6453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6454         LDKChannelPublicKeys o_conv;
6455         o_conv.inner = (void*)(o & (~1));
6456         o_conv.is_owned = (o & 1) || (o == 0);
6457         o_conv = ChannelPublicKeys_clone(&o_conv);
6458         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6459         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
6460         return (long)ret_conv;
6461 }
6462
6463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6464         LDKDecodeError e_conv;
6465         e_conv.inner = (void*)(e & (~1));
6466         e_conv.is_owned = (e & 1) || (e == 0);
6467         e_conv = DecodeError_clone(&e_conv);
6468         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6469         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
6470         return (long)ret_conv;
6471 }
6472
6473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6474         if ((_res & 1) != 0) return;
6475         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6476         FREE((void*)_res);
6477         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
6478 }
6479
6480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6481         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
6482         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6483         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
6484         return (long)ret_conv;
6485 }
6486
6487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6488         LDKTxCreationKeys o_conv;
6489         o_conv.inner = (void*)(o & (~1));
6490         o_conv.is_owned = (o & 1) || (o == 0);
6491         o_conv = TxCreationKeys_clone(&o_conv);
6492         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6493         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
6494         return (long)ret_conv;
6495 }
6496
6497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6498         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6499         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6500         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
6501         return (long)ret_conv;
6502 }
6503
6504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6505         if ((_res & 1) != 0) return;
6506         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
6507         FREE((void*)_res);
6508         CResult_TxCreationKeysErrorZ_free(_res_conv);
6509 }
6510
6511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6512         LDKHTLCOutputInCommitment o_conv;
6513         o_conv.inner = (void*)(o & (~1));
6514         o_conv.is_owned = (o & 1) || (o == 0);
6515         o_conv = HTLCOutputInCommitment_clone(&o_conv);
6516         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6517         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
6518         return (long)ret_conv;
6519 }
6520
6521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6522         LDKDecodeError e_conv;
6523         e_conv.inner = (void*)(e & (~1));
6524         e_conv.is_owned = (e & 1) || (e == 0);
6525         e_conv = DecodeError_clone(&e_conv);
6526         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6527         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
6528         return (long)ret_conv;
6529 }
6530
6531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6532         if ((_res & 1) != 0) return;
6533         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
6534         FREE((void*)_res);
6535         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
6536 }
6537
6538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6539         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
6540         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6541         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
6542         return (long)ret_conv;
6543 }
6544
6545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6546         LDKCounterpartyChannelTransactionParameters o_conv;
6547         o_conv.inner = (void*)(o & (~1));
6548         o_conv.is_owned = (o & 1) || (o == 0);
6549         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
6550         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6551         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6552         return (long)ret_conv;
6553 }
6554
6555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6556         LDKDecodeError e_conv;
6557         e_conv.inner = (void*)(e & (~1));
6558         e_conv.is_owned = (e & 1) || (e == 0);
6559         e_conv = DecodeError_clone(&e_conv);
6560         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6561         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
6562         return (long)ret_conv;
6563 }
6564
6565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6566         if ((_res & 1) != 0) return;
6567         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6568         FREE((void*)_res);
6569         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6570 }
6571
6572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6573         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6574         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6575         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6576         return (long)ret_conv;
6577 }
6578
6579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6580         LDKChannelTransactionParameters o_conv;
6581         o_conv.inner = (void*)(o & (~1));
6582         o_conv.is_owned = (o & 1) || (o == 0);
6583         o_conv = ChannelTransactionParameters_clone(&o_conv);
6584         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6585         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6586         return (long)ret_conv;
6587 }
6588
6589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6590         LDKDecodeError e_conv;
6591         e_conv.inner = (void*)(e & (~1));
6592         e_conv.is_owned = (e & 1) || (e == 0);
6593         e_conv = DecodeError_clone(&e_conv);
6594         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6595         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
6596         return (long)ret_conv;
6597 }
6598
6599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6600         if ((_res & 1) != 0) return;
6601         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6602         FREE((void*)_res);
6603         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6604 }
6605
6606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6607         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6608         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6609         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6610         return (long)ret_conv;
6611 }
6612
6613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
6614         LDKCVec_SignatureZ _res_constr;
6615         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
6616         if (_res_constr.datalen > 0)
6617                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6618         else
6619                 _res_constr.data = NULL;
6620         for (size_t i = 0; i < _res_constr.datalen; i++) {
6621                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
6622                 LDKSignature _res_conv_8_ref;
6623                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
6624                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
6625                 _res_constr.data[i] = _res_conv_8_ref;
6626         }
6627         CVec_SignatureZ_free(_res_constr);
6628 }
6629
6630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6631         LDKHolderCommitmentTransaction o_conv;
6632         o_conv.inner = (void*)(o & (~1));
6633         o_conv.is_owned = (o & 1) || (o == 0);
6634         o_conv = HolderCommitmentTransaction_clone(&o_conv);
6635         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6636         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
6637         return (long)ret_conv;
6638 }
6639
6640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6641         LDKDecodeError e_conv;
6642         e_conv.inner = (void*)(e & (~1));
6643         e_conv.is_owned = (e & 1) || (e == 0);
6644         e_conv = DecodeError_clone(&e_conv);
6645         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6646         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
6647         return (long)ret_conv;
6648 }
6649
6650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6651         if ((_res & 1) != 0) return;
6652         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6653         FREE((void*)_res);
6654         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
6655 }
6656
6657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6658         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6659         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6660         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6661         return (long)ret_conv;
6662 }
6663
6664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6665         LDKBuiltCommitmentTransaction o_conv;
6666         o_conv.inner = (void*)(o & (~1));
6667         o_conv.is_owned = (o & 1) || (o == 0);
6668         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
6669         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6670         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
6671         return (long)ret_conv;
6672 }
6673
6674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6675         LDKDecodeError e_conv;
6676         e_conv.inner = (void*)(e & (~1));
6677         e_conv.is_owned = (e & 1) || (e == 0);
6678         e_conv = DecodeError_clone(&e_conv);
6679         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6680         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
6681         return (long)ret_conv;
6682 }
6683
6684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6685         if ((_res & 1) != 0) return;
6686         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6687         FREE((void*)_res);
6688         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
6689 }
6690
6691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6692         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6693         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6694         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6695         return (long)ret_conv;
6696 }
6697
6698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6699         LDKCommitmentTransaction o_conv;
6700         o_conv.inner = (void*)(o & (~1));
6701         o_conv.is_owned = (o & 1) || (o == 0);
6702         o_conv = CommitmentTransaction_clone(&o_conv);
6703         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6704         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
6705         return (long)ret_conv;
6706 }
6707
6708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6709         LDKDecodeError e_conv;
6710         e_conv.inner = (void*)(e & (~1));
6711         e_conv.is_owned = (e & 1) || (e == 0);
6712         e_conv = DecodeError_clone(&e_conv);
6713         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6714         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
6715         return (long)ret_conv;
6716 }
6717
6718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6719         if ((_res & 1) != 0) return;
6720         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6721         FREE((void*)_res);
6722         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
6723 }
6724
6725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6726         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
6727         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6728         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
6729         return (long)ret_conv;
6730 }
6731
6732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6733         LDKTrustedCommitmentTransaction o_conv;
6734         o_conv.inner = (void*)(o & (~1));
6735         o_conv.is_owned = (o & 1) || (o == 0);
6736         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
6737         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6738         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
6739         return (long)ret_conv;
6740 }
6741
6742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
6743         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6744         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
6745         return (long)ret_conv;
6746 }
6747
6748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6749         if ((_res & 1) != 0) return;
6750         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
6751         FREE((void*)_res);
6752         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
6753 }
6754
6755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
6756         LDKCVec_SignatureZ o_constr;
6757         o_constr.datalen = (*env)->GetArrayLength(env, o);
6758         if (o_constr.datalen > 0)
6759                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6760         else
6761                 o_constr.data = NULL;
6762         for (size_t i = 0; i < o_constr.datalen; i++) {
6763                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
6764                 LDKSignature o_conv_8_ref;
6765                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
6766                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
6767                 o_constr.data[i] = o_conv_8_ref;
6768         }
6769         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6770         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
6771         return (long)ret_conv;
6772 }
6773
6774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
6775         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6776         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
6777         return (long)ret_conv;
6778 }
6779
6780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6781         if ((_res & 1) != 0) return;
6782         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
6783         FREE((void*)_res);
6784         CResult_CVec_SignatureZNoneZ_free(_res_conv);
6785 }
6786
6787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6788         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
6789         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6790         *ret_conv = CResult_CVec_SignatureZNoneZ_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 _res_conv_18 = _res_vals[s];
6804                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
6805                 FREE((void*)_res_conv_18);
6806                 _res_constr.data[s] = _res_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_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
6813         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6814         *ret_conv = CResult_boolLightningErrorZ_ok(o);
6815         return (long)ret_conv;
6816 }
6817
6818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6819         LDKLightningError e_conv;
6820         e_conv.inner = (void*)(e & (~1));
6821         e_conv.is_owned = (e & 1) || (e == 0);
6822         e_conv = LightningError_clone(&e_conv);
6823         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6824         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
6825         return (long)ret_conv;
6826 }
6827
6828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6829         if ((_res & 1) != 0) return;
6830         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
6831         FREE((void*)_res);
6832         CResult_boolLightningErrorZ_free(_res_conv);
6833 }
6834
6835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6836         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
6837         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6838         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
6839         return (long)ret_conv;
6840 }
6841
6842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6843         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
6844         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6845         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
6846         return (long)ret_ref;
6847 }
6848
6849 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) {
6850         LDKChannelAnnouncement a_conv;
6851         a_conv.inner = (void*)(a & (~1));
6852         a_conv.is_owned = (a & 1) || (a == 0);
6853         a_conv = ChannelAnnouncement_clone(&a_conv);
6854         LDKChannelUpdate b_conv;
6855         b_conv.inner = (void*)(b & (~1));
6856         b_conv.is_owned = (b & 1) || (b == 0);
6857         b_conv = ChannelUpdate_clone(&b_conv);
6858         LDKChannelUpdate c_conv;
6859         c_conv.inner = (void*)(c & (~1));
6860         c_conv.is_owned = (c & 1) || (c == 0);
6861         c_conv = ChannelUpdate_clone(&c_conv);
6862         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6863         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
6864         return (long)ret_ref;
6865 }
6866
6867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6868         if ((_res & 1) != 0) return;
6869         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
6870         FREE((void*)_res);
6871         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
6872 }
6873
6874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
6875         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
6876         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
6877         if (_res_constr.datalen > 0)
6878                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
6879         else
6880                 _res_constr.data = NULL;
6881         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
6882         for (size_t l = 0; l < _res_constr.datalen; l++) {
6883                 int64_t _res_conv_63 = _res_vals[l];
6884                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
6885                 FREE((void*)_res_conv_63);
6886                 _res_constr.data[l] = _res_conv_63_conv;
6887         }
6888         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
6889         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
6890 }
6891
6892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
6893         LDKCVec_NodeAnnouncementZ _res_constr;
6894         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
6895         if (_res_constr.datalen > 0)
6896                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
6897         else
6898                 _res_constr.data = NULL;
6899         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
6900         for (size_t s = 0; s < _res_constr.datalen; s++) {
6901                 int64_t _res_conv_18 = _res_vals[s];
6902                 LDKNodeAnnouncement _res_conv_18_conv;
6903                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
6904                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
6905                 _res_constr.data[s] = _res_conv_18_conv;
6906         }
6907         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
6908         CVec_NodeAnnouncementZ_free(_res_constr);
6909 }
6910
6911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
6912         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6913         *ret_conv = CResult_NoneLightningErrorZ_ok();
6914         return (long)ret_conv;
6915 }
6916
6917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6918         LDKLightningError e_conv;
6919         e_conv.inner = (void*)(e & (~1));
6920         e_conv.is_owned = (e & 1) || (e == 0);
6921         e_conv = LightningError_clone(&e_conv);
6922         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6923         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
6924         return (long)ret_conv;
6925 }
6926
6927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6928         if ((_res & 1) != 0) return;
6929         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
6930         FREE((void*)_res);
6931         CResult_NoneLightningErrorZ_free(_res_conv);
6932 }
6933
6934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6935         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
6936         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6937         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
6938         return (long)ret_conv;
6939 }
6940
6941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
6942         LDKCVec_PublicKeyZ _res_constr;
6943         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
6944         if (_res_constr.datalen > 0)
6945                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
6946         else
6947                 _res_constr.data = NULL;
6948         for (size_t i = 0; i < _res_constr.datalen; i++) {
6949                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
6950                 LDKPublicKey _res_conv_8_ref;
6951                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
6952                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
6953                 _res_constr.data[i] = _res_conv_8_ref;
6954         }
6955         CVec_PublicKeyZ_free(_res_constr);
6956 }
6957
6958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
6959         LDKCVec_u8Z _res_ref;
6960         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
6961         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
6962         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
6963         CVec_u8Z_free(_res_ref);
6964 }
6965
6966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
6967         LDKCVec_u8Z o_ref;
6968         o_ref.datalen = (*env)->GetArrayLength(env, o);
6969         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
6970         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
6971         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
6972         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
6973         return (long)ret_conv;
6974 }
6975
6976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6977         LDKPeerHandleError e_conv;
6978         e_conv.inner = (void*)(e & (~1));
6979         e_conv.is_owned = (e & 1) || (e == 0);
6980         e_conv = PeerHandleError_clone(&e_conv);
6981         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
6982         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
6983         return (long)ret_conv;
6984 }
6985
6986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6987         if ((_res & 1) != 0) return;
6988         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
6989         FREE((void*)_res);
6990         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
6991 }
6992
6993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6994         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
6995         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
6996         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
6997         return (long)ret_conv;
6998 }
6999
7000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
7001         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
7002         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
7003         return (long)ret_conv;
7004 }
7005
7006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7007         LDKPeerHandleError e_conv;
7008         e_conv.inner = (void*)(e & (~1));
7009         e_conv.is_owned = (e & 1) || (e == 0);
7010         e_conv = PeerHandleError_clone(&e_conv);
7011         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
7012         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
7013         return (long)ret_conv;
7014 }
7015
7016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7017         if ((_res & 1) != 0) return;
7018         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
7019         FREE((void*)_res);
7020         CResult_NonePeerHandleErrorZ_free(_res_conv);
7021 }
7022
7023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7024         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
7025         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
7026         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
7027         return (long)ret_conv;
7028 }
7029
7030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
7031         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
7032         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
7033         return (long)ret_conv;
7034 }
7035
7036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7037         LDKPeerHandleError e_conv;
7038         e_conv.inner = (void*)(e & (~1));
7039         e_conv.is_owned = (e & 1) || (e == 0);
7040         e_conv = PeerHandleError_clone(&e_conv);
7041         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
7042         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
7043         return (long)ret_conv;
7044 }
7045
7046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7047         if ((_res & 1) != 0) return;
7048         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
7049         FREE((void*)_res);
7050         CResult_boolPeerHandleErrorZ_free(_res_conv);
7051 }
7052
7053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7054         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
7055         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
7056         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
7057         return (long)ret_conv;
7058 }
7059
7060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7061         LDKInitFeatures o_conv;
7062         o_conv.inner = (void*)(o & (~1));
7063         o_conv.is_owned = (o & 1) || (o == 0);
7064         o_conv = InitFeatures_clone(&o_conv);
7065         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7066         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
7067         return (long)ret_conv;
7068 }
7069
7070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7071         LDKDecodeError e_conv;
7072         e_conv.inner = (void*)(e & (~1));
7073         e_conv.is_owned = (e & 1) || (e == 0);
7074         e_conv = DecodeError_clone(&e_conv);
7075         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7076         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
7077         return (long)ret_conv;
7078 }
7079
7080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7081         if ((_res & 1) != 0) return;
7082         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7083         FREE((void*)_res);
7084         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
7085 }
7086
7087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7088         LDKNodeFeatures o_conv;
7089         o_conv.inner = (void*)(o & (~1));
7090         o_conv.is_owned = (o & 1) || (o == 0);
7091         o_conv = NodeFeatures_clone(&o_conv);
7092         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7093         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
7094         return (long)ret_conv;
7095 }
7096
7097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7098         LDKDecodeError e_conv;
7099         e_conv.inner = (void*)(e & (~1));
7100         e_conv.is_owned = (e & 1) || (e == 0);
7101         e_conv = DecodeError_clone(&e_conv);
7102         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7103         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
7104         return (long)ret_conv;
7105 }
7106
7107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7108         if ((_res & 1) != 0) return;
7109         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7110         FREE((void*)_res);
7111         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
7112 }
7113
7114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7115         LDKChannelFeatures o_conv;
7116         o_conv.inner = (void*)(o & (~1));
7117         o_conv.is_owned = (o & 1) || (o == 0);
7118         o_conv = ChannelFeatures_clone(&o_conv);
7119         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7120         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
7121         return (long)ret_conv;
7122 }
7123
7124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7125         LDKDecodeError e_conv;
7126         e_conv.inner = (void*)(e & (~1));
7127         e_conv.is_owned = (e & 1) || (e == 0);
7128         e_conv = DecodeError_clone(&e_conv);
7129         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7130         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
7131         return (long)ret_conv;
7132 }
7133
7134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7135         if ((_res & 1) != 0) return;
7136         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7137         FREE((void*)_res);
7138         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
7139 }
7140
7141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7142         LDKChannelConfig o_conv;
7143         o_conv.inner = (void*)(o & (~1));
7144         o_conv.is_owned = (o & 1) || (o == 0);
7145         o_conv = ChannelConfig_clone(&o_conv);
7146         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
7147         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
7148         return (long)ret_conv;
7149 }
7150
7151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7152         LDKDecodeError e_conv;
7153         e_conv.inner = (void*)(e & (~1));
7154         e_conv.is_owned = (e & 1) || (e == 0);
7155         e_conv = DecodeError_clone(&e_conv);
7156         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
7157         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
7158         return (long)ret_conv;
7159 }
7160
7161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7162         if ((_res & 1) != 0) return;
7163         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
7164         FREE((void*)_res);
7165         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
7166 }
7167
7168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7169         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
7170         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
7171         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
7172         return (long)ret_conv;
7173 }
7174
7175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7176         LDKDirectionalChannelInfo o_conv;
7177         o_conv.inner = (void*)(o & (~1));
7178         o_conv.is_owned = (o & 1) || (o == 0);
7179         o_conv = DirectionalChannelInfo_clone(&o_conv);
7180         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
7181         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
7182         return (long)ret_conv;
7183 }
7184
7185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7186         LDKDecodeError e_conv;
7187         e_conv.inner = (void*)(e & (~1));
7188         e_conv.is_owned = (e & 1) || (e == 0);
7189         e_conv = DecodeError_clone(&e_conv);
7190         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
7191         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
7192         return (long)ret_conv;
7193 }
7194
7195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7196         if ((_res & 1) != 0) return;
7197         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7198         FREE((void*)_res);
7199         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
7200 }
7201
7202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7203         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
7204         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
7205         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
7206         return (long)ret_conv;
7207 }
7208
7209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7210         LDKChannelInfo o_conv;
7211         o_conv.inner = (void*)(o & (~1));
7212         o_conv.is_owned = (o & 1) || (o == 0);
7213         o_conv = ChannelInfo_clone(&o_conv);
7214         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
7215         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
7216         return (long)ret_conv;
7217 }
7218
7219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7220         LDKDecodeError e_conv;
7221         e_conv.inner = (void*)(e & (~1));
7222         e_conv.is_owned = (e & 1) || (e == 0);
7223         e_conv = DecodeError_clone(&e_conv);
7224         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
7225         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
7226         return (long)ret_conv;
7227 }
7228
7229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7230         if ((_res & 1) != 0) return;
7231         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7232         FREE((void*)_res);
7233         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
7234 }
7235
7236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7237         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
7238         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
7239         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
7240         return (long)ret_conv;
7241 }
7242
7243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7244         LDKRoutingFees o_conv;
7245         o_conv.inner = (void*)(o & (~1));
7246         o_conv.is_owned = (o & 1) || (o == 0);
7247         o_conv = RoutingFees_clone(&o_conv);
7248         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
7249         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
7250         return (long)ret_conv;
7251 }
7252
7253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7254         LDKDecodeError e_conv;
7255         e_conv.inner = (void*)(e & (~1));
7256         e_conv.is_owned = (e & 1) || (e == 0);
7257         e_conv = DecodeError_clone(&e_conv);
7258         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
7259         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
7260         return (long)ret_conv;
7261 }
7262
7263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7264         if ((_res & 1) != 0) return;
7265         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7266         FREE((void*)_res);
7267         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
7268 }
7269
7270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7271         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
7272         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
7273         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
7274         return (long)ret_conv;
7275 }
7276
7277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7278         LDKCVec_NetAddressZ _res_constr;
7279         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7280         if (_res_constr.datalen > 0)
7281                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
7282         else
7283                 _res_constr.data = NULL;
7284         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7285         for (size_t m = 0; m < _res_constr.datalen; m++) {
7286                 int64_t _res_conv_12 = _res_vals[m];
7287                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
7288                 FREE((void*)_res_conv_12);
7289                 _res_constr.data[m] = _res_conv_12_conv;
7290         }
7291         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7292         CVec_NetAddressZ_free(_res_constr);
7293 }
7294
7295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7296         LDKNodeAnnouncementInfo o_conv;
7297         o_conv.inner = (void*)(o & (~1));
7298         o_conv.is_owned = (o & 1) || (o == 0);
7299         o_conv = NodeAnnouncementInfo_clone(&o_conv);
7300         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
7301         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
7302         return (long)ret_conv;
7303 }
7304
7305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7306         LDKDecodeError e_conv;
7307         e_conv.inner = (void*)(e & (~1));
7308         e_conv.is_owned = (e & 1) || (e == 0);
7309         e_conv = DecodeError_clone(&e_conv);
7310         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
7311         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
7312         return (long)ret_conv;
7313 }
7314
7315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7316         if ((_res & 1) != 0) return;
7317         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7318         FREE((void*)_res);
7319         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
7320 }
7321
7322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7323         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
7324         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
7325         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
7326         return (long)ret_conv;
7327 }
7328
7329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7330         LDKCVec_u64Z _res_constr;
7331         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7332         if (_res_constr.datalen > 0)
7333                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
7334         else
7335                 _res_constr.data = NULL;
7336         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7337         for (size_t g = 0; g < _res_constr.datalen; g++) {
7338                 int64_t _res_conv_6 = _res_vals[g];
7339                 _res_constr.data[g] = _res_conv_6;
7340         }
7341         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7342         CVec_u64Z_free(_res_constr);
7343 }
7344
7345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7346         LDKNodeInfo o_conv;
7347         o_conv.inner = (void*)(o & (~1));
7348         o_conv.is_owned = (o & 1) || (o == 0);
7349         o_conv = NodeInfo_clone(&o_conv);
7350         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
7351         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
7352         return (long)ret_conv;
7353 }
7354
7355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7356         LDKDecodeError e_conv;
7357         e_conv.inner = (void*)(e & (~1));
7358         e_conv.is_owned = (e & 1) || (e == 0);
7359         e_conv = DecodeError_clone(&e_conv);
7360         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
7361         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
7362         return (long)ret_conv;
7363 }
7364
7365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7366         if ((_res & 1) != 0) return;
7367         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7368         FREE((void*)_res);
7369         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
7370 }
7371
7372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7373         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
7374         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
7375         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
7376         return (long)ret_conv;
7377 }
7378
7379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7380         LDKNetworkGraph o_conv;
7381         o_conv.inner = (void*)(o & (~1));
7382         o_conv.is_owned = (o & 1) || (o == 0);
7383         o_conv = NetworkGraph_clone(&o_conv);
7384         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
7385         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
7386         return (long)ret_conv;
7387 }
7388
7389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7390         LDKDecodeError e_conv;
7391         e_conv.inner = (void*)(e & (~1));
7392         e_conv.is_owned = (e & 1) || (e == 0);
7393         e_conv = DecodeError_clone(&e_conv);
7394         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
7395         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
7396         return (long)ret_conv;
7397 }
7398
7399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7400         if ((_res & 1) != 0) return;
7401         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
7402         FREE((void*)_res);
7403         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
7404 }
7405
7406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7407         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
7408         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
7409         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
7410         return (long)ret_conv;
7411 }
7412
7413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
7414         LDKTransaction b_ref;
7415         b_ref.datalen = (*env)->GetArrayLength(env, b);
7416         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
7417         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7418         b_ref.data_is_owned = true;
7419         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7420         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
7421         return (long)ret_ref;
7422 }
7423
7424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7425         if ((_res & 1) != 0) return;
7426         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
7427         FREE((void*)_res);
7428         C2Tuple_usizeTransactionZ_free(_res_conv);
7429 }
7430
7431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7432         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
7433         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7434         if (_res_constr.datalen > 0)
7435                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7436         else
7437                 _res_constr.data = NULL;
7438         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7439         for (size_t y = 0; y < _res_constr.datalen; y++) {
7440                 int64_t _res_conv_24 = _res_vals[y];
7441                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
7442                 FREE((void*)_res_conv_24);
7443                 _res_constr.data[y] = _res_conv_24_conv;
7444         }
7445         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7446         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
7447 }
7448
7449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
7450         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7451         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
7452         return (long)ret_conv;
7453 }
7454
7455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
7456         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
7457         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7458         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
7459         return (long)ret_conv;
7460 }
7461
7462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7463         if ((_res & 1) != 0) return;
7464         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
7465         FREE((void*)_res);
7466         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
7467 }
7468
7469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7470         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
7471         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7472         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
7473         return (long)ret_conv;
7474 }
7475
7476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7477         LDKCVec_MonitorEventZ _res_constr;
7478         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7479         if (_res_constr.datalen > 0)
7480                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
7481         else
7482                 _res_constr.data = NULL;
7483         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7484         for (size_t o = 0; o < _res_constr.datalen; o++) {
7485                 int64_t _res_conv_14 = _res_vals[o];
7486                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
7487                 FREE((void*)_res_conv_14);
7488                 _res_constr.data[o] = _res_conv_14_conv;
7489         }
7490         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7491         CVec_MonitorEventZ_free(_res_constr);
7492 }
7493
7494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7495         LDKCVec_EventZ _res_constr;
7496         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7497         if (_res_constr.datalen > 0)
7498                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
7499         else
7500                 _res_constr.data = NULL;
7501         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7502         for (size_t h = 0; h < _res_constr.datalen; h++) {
7503                 int64_t _res_conv_7 = _res_vals[h];
7504                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
7505                 FREE((void*)_res_conv_7);
7506                 _res_constr.data[h] = _res_conv_7_conv;
7507         }
7508         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7509         CVec_EventZ_free(_res_constr);
7510 }
7511
7512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7513         LDKOutPoint o_conv;
7514         o_conv.inner = (void*)(o & (~1));
7515         o_conv.is_owned = (o & 1) || (o == 0);
7516         o_conv = OutPoint_clone(&o_conv);
7517         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
7518         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
7519         return (long)ret_conv;
7520 }
7521
7522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7523         LDKDecodeError e_conv;
7524         e_conv.inner = (void*)(e & (~1));
7525         e_conv.is_owned = (e & 1) || (e == 0);
7526         e_conv = DecodeError_clone(&e_conv);
7527         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
7528         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
7529         return (long)ret_conv;
7530 }
7531
7532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7533         if ((_res & 1) != 0) return;
7534         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
7535         FREE((void*)_res);
7536         CResult_OutPointDecodeErrorZ_free(_res_conv);
7537 }
7538
7539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7540         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
7541         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
7542         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
7543         return (long)ret_conv;
7544 }
7545
7546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7547         LDKChannelMonitorUpdate o_conv;
7548         o_conv.inner = (void*)(o & (~1));
7549         o_conv.is_owned = (o & 1) || (o == 0);
7550         o_conv = ChannelMonitorUpdate_clone(&o_conv);
7551         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7552         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
7553         return (long)ret_conv;
7554 }
7555
7556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7557         LDKDecodeError e_conv;
7558         e_conv.inner = (void*)(e & (~1));
7559         e_conv.is_owned = (e & 1) || (e == 0);
7560         e_conv = DecodeError_clone(&e_conv);
7561         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7562         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
7563         return (long)ret_conv;
7564 }
7565
7566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7567         if ((_res & 1) != 0) return;
7568         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
7569         FREE((void*)_res);
7570         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
7571 }
7572
7573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7574         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
7575         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7576         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
7577         return (long)ret_conv;
7578 }
7579
7580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7581         LDKHTLCUpdate o_conv;
7582         o_conv.inner = (void*)(o & (~1));
7583         o_conv.is_owned = (o & 1) || (o == 0);
7584         o_conv = HTLCUpdate_clone(&o_conv);
7585         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7586         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
7587         return (long)ret_conv;
7588 }
7589
7590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7591         LDKDecodeError e_conv;
7592         e_conv.inner = (void*)(e & (~1));
7593         e_conv.is_owned = (e & 1) || (e == 0);
7594         e_conv = DecodeError_clone(&e_conv);
7595         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7596         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
7597         return (long)ret_conv;
7598 }
7599
7600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7601         if ((_res & 1) != 0) return;
7602         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
7603         FREE((void*)_res);
7604         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
7605 }
7606
7607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7608         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
7609         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7610         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
7611         return (long)ret_conv;
7612 }
7613
7614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
7615         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7616         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
7617         return (long)ret_conv;
7618 }
7619
7620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7621         LDKMonitorUpdateError e_conv;
7622         e_conv.inner = (void*)(e & (~1));
7623         e_conv.is_owned = (e & 1) || (e == 0);
7624         e_conv = MonitorUpdateError_clone(&e_conv);
7625         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7626         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
7627         return (long)ret_conv;
7628 }
7629
7630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7631         if ((_res & 1) != 0) return;
7632         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
7633         FREE((void*)_res);
7634         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
7635 }
7636
7637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7638         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
7639         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7640         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
7641         return (long)ret_conv;
7642 }
7643
7644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7645         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
7646         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
7647         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
7648         return (long)ret_ref;
7649 }
7650
7651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
7652         LDKOutPoint a_conv;
7653         a_conv.inner = (void*)(a & (~1));
7654         a_conv.is_owned = (a & 1) || (a == 0);
7655         a_conv = OutPoint_clone(&a_conv);
7656         LDKCVec_u8Z b_ref;
7657         b_ref.datalen = (*env)->GetArrayLength(env, b);
7658         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
7659         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7660         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
7661         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
7662         return (long)ret_ref;
7663 }
7664
7665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7666         if ((_res & 1) != 0) return;
7667         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
7668         FREE((void*)_res);
7669         C2Tuple_OutPointScriptZ_free(_res_conv);
7670 }
7671
7672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7673         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
7674         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
7675         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
7676         return (long)ret_ref;
7677 }
7678
7679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
7680         LDKCVec_u8Z b_ref;
7681         b_ref.datalen = (*env)->GetArrayLength(env, b);
7682         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
7683         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7684         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
7685         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
7686         return (long)ret_ref;
7687 }
7688
7689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7690         if ((_res & 1) != 0) return;
7691         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
7692         FREE((void*)_res);
7693         C2Tuple_u32ScriptZ_free(_res_conv);
7694 }
7695
7696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7697         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
7698         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7699         if (_res_constr.datalen > 0)
7700                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
7701         else
7702                 _res_constr.data = NULL;
7703         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7704         for (size_t b = 0; b < _res_constr.datalen; b++) {
7705                 int64_t _res_conv_27 = _res_vals[b];
7706                 LDKC2Tuple_u32ScriptZ _res_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_27) & ~1);
7707                 FREE((void*)_res_conv_27);
7708                 _res_constr.data[b] = _res_conv_27_conv;
7709         }
7710         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7711         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
7712 }
7713
7714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
7715         LDKThirtyTwoBytes a_ref;
7716         CHECK((*env)->GetArrayLength(env, a) == 32);
7717         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
7718         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
7719         b_constr.datalen = (*env)->GetArrayLength(env, b);
7720         if (b_constr.datalen > 0)
7721                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
7722         else
7723                 b_constr.data = NULL;
7724         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
7725         for (size_t b = 0; b < b_constr.datalen; b++) {
7726                 int64_t b_conv_27 = b_vals[b];
7727                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
7728                 FREE((void*)b_conv_27);
7729                 b_constr.data[b] = b_conv_27_conv;
7730         }
7731         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
7732         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
7733         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
7734         return (long)ret_ref;
7735 }
7736
7737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7738         if ((_res & 1) != 0) return;
7739         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
7740         FREE((void*)_res);
7741         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
7742 }
7743
7744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7745         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
7746         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7747         if (_res_constr.datalen > 0)
7748                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
7749         else
7750                 _res_constr.data = NULL;
7751         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7752         for (size_t v = 0; v < _res_constr.datalen; v++) {
7753                 int64_t _res_conv_47 = _res_vals[v];
7754                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_47_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_47) & ~1);
7755                 FREE((void*)_res_conv_47);
7756                 _res_constr.data[v] = _res_conv_47_conv;
7757         }
7758         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7759         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
7760 }
7761
7762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
7763         LDKCVec_TransactionZ _res_constr;
7764         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7765         if (_res_constr.datalen > 0)
7766                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
7767         else
7768                 _res_constr.data = NULL;
7769         for (size_t i = 0; i < _res_constr.datalen; i++) {
7770                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
7771                 LDKTransaction _res_conv_8_ref;
7772                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
7773                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
7774                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
7775                 _res_conv_8_ref.data_is_owned = true;
7776                 _res_constr.data[i] = _res_conv_8_ref;
7777         }
7778         CVec_TransactionZ_free(_res_constr);
7779 }
7780
7781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7782         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
7783         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7784         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
7785         return (long)ret_ref;
7786 }
7787
7788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
7789         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
7790         FREE((void*)b);
7791         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7792         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
7793         return (long)ret_ref;
7794 }
7795
7796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7797         if ((_res & 1) != 0) return;
7798         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
7799         FREE((void*)_res);
7800         C2Tuple_u32TxOutZ_free(_res_conv);
7801 }
7802
7803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7804         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
7805         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7806         if (_res_constr.datalen > 0)
7807                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
7808         else
7809                 _res_constr.data = NULL;
7810         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7811         for (size_t a = 0; a < _res_constr.datalen; a++) {
7812                 int64_t _res_conv_26 = _res_vals[a];
7813                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
7814                 FREE((void*)_res_conv_26);
7815                 _res_constr.data[a] = _res_conv_26_conv;
7816         }
7817         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7818         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
7819 }
7820
7821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
7822         LDKThirtyTwoBytes a_ref;
7823         CHECK((*env)->GetArrayLength(env, a) == 32);
7824         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
7825         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
7826         b_constr.datalen = (*env)->GetArrayLength(env, b);
7827         if (b_constr.datalen > 0)
7828                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
7829         else
7830                 b_constr.data = NULL;
7831         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
7832         for (size_t a = 0; a < b_constr.datalen; a++) {
7833                 int64_t b_conv_26 = b_vals[a];
7834                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
7835                 FREE((void*)b_conv_26);
7836                 b_constr.data[a] = b_conv_26_conv;
7837         }
7838         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
7839         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
7840         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
7841         return (long)ret_ref;
7842 }
7843
7844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7845         if ((_res & 1) != 0) return;
7846         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
7847         FREE((void*)_res);
7848         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
7849 }
7850
7851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7852         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
7853         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7854         if (_res_constr.datalen > 0)
7855                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
7856         else
7857                 _res_constr.data = NULL;
7858         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7859         for (size_t u = 0; u < _res_constr.datalen; u++) {
7860                 int64_t _res_conv_46 = _res_vals[u];
7861                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
7862                 FREE((void*)_res_conv_46);
7863                 _res_constr.data[u] = _res_conv_46_conv;
7864         }
7865         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7866         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
7867 }
7868
7869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
7870         LDKThirtyTwoBytes a_ref;
7871         CHECK((*env)->GetArrayLength(env, a) == 32);
7872         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
7873         LDKChannelMonitor b_conv;
7874         b_conv.inner = (void*)(b & (~1));
7875         b_conv.is_owned = (b & 1) || (b == 0);
7876         b_conv = ChannelMonitor_clone(&b_conv);
7877         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7878         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
7879         return (long)ret_ref;
7880 }
7881
7882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7883         if ((_res & 1) != 0) return;
7884         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
7885         FREE((void*)_res);
7886         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
7887 }
7888
7889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7890         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
7891         FREE((void*)o);
7892         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
7893         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
7894         return (long)ret_conv;
7895 }
7896
7897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7898         LDKDecodeError e_conv;
7899         e_conv.inner = (void*)(e & (~1));
7900         e_conv.is_owned = (e & 1) || (e == 0);
7901         e_conv = DecodeError_clone(&e_conv);
7902         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
7903         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
7904         return (long)ret_conv;
7905 }
7906
7907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7908         if ((_res & 1) != 0) return;
7909         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
7910         FREE((void*)_res);
7911         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
7912 }
7913
7914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7915         LDKCVec_SpendableOutputDescriptorZ _res_constr;
7916         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7917         if (_res_constr.datalen > 0)
7918                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
7919         else
7920                 _res_constr.data = NULL;
7921         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7922         for (size_t b = 0; b < _res_constr.datalen; b++) {
7923                 int64_t _res_conv_27 = _res_vals[b];
7924                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
7925                 FREE((void*)_res_conv_27);
7926                 _res_constr.data[b] = _res_conv_27_conv;
7927         }
7928         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7929         CVec_SpendableOutputDescriptorZ_free(_res_constr);
7930 }
7931
7932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7933         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
7934         FREE((void*)o);
7935         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7936         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
7937         return (long)ret_conv;
7938 }
7939
7940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
7941         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
7942         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7943         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
7944         return (long)ret_conv;
7945 }
7946
7947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7948         if ((_res & 1) != 0) return;
7949         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
7950         FREE((void*)_res);
7951         CResult_TxOutAccessErrorZ_free(_res_conv);
7952 }
7953
7954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7955         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
7956         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7957         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
7958         return (long)ret_conv;
7959 }
7960
7961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
7962         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7963         *ret_conv = CResult_NoneAPIErrorZ_ok();
7964         return (long)ret_conv;
7965 }
7966
7967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7968         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
7969         FREE((void*)e);
7970         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7971         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
7972         return (long)ret_conv;
7973 }
7974
7975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7976         if ((_res & 1) != 0) return;
7977         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
7978         FREE((void*)_res);
7979         CResult_NoneAPIErrorZ_free(_res_conv);
7980 }
7981
7982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7983         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
7984         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7985         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
7986         return (long)ret_conv;
7987 }
7988
7989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7990         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
7991         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7992         if (_res_constr.datalen > 0)
7993                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
7994         else
7995                 _res_constr.data = NULL;
7996         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7997         for (size_t w = 0; w < _res_constr.datalen; w++) {
7998                 int64_t _res_conv_22 = _res_vals[w];
7999                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
8000                 FREE((void*)_res_conv_22);
8001                 _res_constr.data[w] = _res_conv_22_conv;
8002         }
8003         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8004         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
8005 }
8006
8007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8008         LDKCVec_APIErrorZ _res_constr;
8009         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8010         if (_res_constr.datalen > 0)
8011                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
8012         else
8013                 _res_constr.data = NULL;
8014         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8015         for (size_t k = 0; k < _res_constr.datalen; k++) {
8016                 int64_t _res_conv_10 = _res_vals[k];
8017                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
8018                 FREE((void*)_res_conv_10);
8019                 _res_constr.data[k] = _res_conv_10_conv;
8020         }
8021         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8022         CVec_APIErrorZ_free(_res_constr);
8023 }
8024
8025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8026         LDKCVec_ChannelDetailsZ _res_constr;
8027         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8028         if (_res_constr.datalen > 0)
8029                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
8030         else
8031                 _res_constr.data = NULL;
8032         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8033         for (size_t q = 0; q < _res_constr.datalen; q++) {
8034                 int64_t _res_conv_16 = _res_vals[q];
8035                 LDKChannelDetails _res_conv_16_conv;
8036                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8037                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8038                 _res_constr.data[q] = _res_conv_16_conv;
8039         }
8040         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8041         CVec_ChannelDetailsZ_free(_res_constr);
8042 }
8043
8044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
8045         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8046         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
8047         return (long)ret_conv;
8048 }
8049
8050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8051         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
8052         FREE((void*)e);
8053         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8054         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
8055         return (long)ret_conv;
8056 }
8057
8058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8059         if ((_res & 1) != 0) return;
8060         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
8061         FREE((void*)_res);
8062         CResult_NonePaymentSendFailureZ_free(_res_conv);
8063 }
8064
8065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8066         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
8067         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8068         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
8069         return (long)ret_conv;
8070 }
8071
8072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8073         LDKCVec_ChannelMonitorZ _res_constr;
8074         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8075         if (_res_constr.datalen > 0)
8076                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
8077         else
8078                 _res_constr.data = NULL;
8079         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8080         for (size_t q = 0; q < _res_constr.datalen; q++) {
8081                 int64_t _res_conv_16 = _res_vals[q];
8082                 LDKChannelMonitor _res_conv_16_conv;
8083                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8084                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8085                 _res_constr.data[q] = _res_conv_16_conv;
8086         }
8087         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8088         CVec_ChannelMonitorZ_free(_res_constr);
8089 }
8090
8091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
8092         LDKThirtyTwoBytes a_ref;
8093         CHECK((*env)->GetArrayLength(env, a) == 32);
8094         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
8095         LDKChannelManager b_conv;
8096         b_conv.inner = (void*)(b & (~1));
8097         b_conv.is_owned = (b & 1) || (b == 0);
8098         // Warning: we need a move here but no clone is available for LDKChannelManager
8099         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
8100         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
8101         return (long)ret_ref;
8102 }
8103
8104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8105         if ((_res & 1) != 0) return;
8106         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
8107         FREE((void*)_res);
8108         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
8109 }
8110
8111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8112         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
8113         FREE((void*)o);
8114         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8115         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
8116         return (long)ret_conv;
8117 }
8118
8119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8120         LDKDecodeError e_conv;
8121         e_conv.inner = (void*)(e & (~1));
8122         e_conv.is_owned = (e & 1) || (e == 0);
8123         e_conv = DecodeError_clone(&e_conv);
8124         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8125         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
8126         return (long)ret_conv;
8127 }
8128
8129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8130         if ((_res & 1) != 0) return;
8131         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8132         FREE((void*)_res);
8133         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
8134 }
8135
8136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8137         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
8138         FREE((void*)o);
8139         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8140         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
8141         return (long)ret_conv;
8142 }
8143
8144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8145         LDKDecodeError e_conv;
8146         e_conv.inner = (void*)(e & (~1));
8147         e_conv.is_owned = (e & 1) || (e == 0);
8148         e_conv = DecodeError_clone(&e_conv);
8149         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8150         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
8151         return (long)ret_conv;
8152 }
8153
8154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8155         if ((_res & 1) != 0) return;
8156         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
8157         FREE((void*)_res);
8158         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
8159 }
8160
8161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8162         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
8163         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8164         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
8165         return (long)ret_conv;
8166 }
8167
8168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8169         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
8170         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
8171         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
8172         return (long)ret_ref;
8173 }
8174
8175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
8176         LDKSignature a_ref;
8177         CHECK((*env)->GetArrayLength(env, a) == 64);
8178         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
8179         LDKCVec_SignatureZ b_constr;
8180         b_constr.datalen = (*env)->GetArrayLength(env, b);
8181         if (b_constr.datalen > 0)
8182                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8183         else
8184                 b_constr.data = NULL;
8185         for (size_t i = 0; i < b_constr.datalen; i++) {
8186                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
8187                 LDKSignature b_conv_8_ref;
8188                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
8189                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
8190                 b_constr.data[i] = b_conv_8_ref;
8191         }
8192         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
8193         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
8194         return (long)ret_ref;
8195 }
8196
8197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8198         if ((_res & 1) != 0) return;
8199         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
8200         FREE((void*)_res);
8201         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
8202 }
8203
8204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8205         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
8206         FREE((void*)o);
8207         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8208         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
8209         return (long)ret_conv;
8210 }
8211
8212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
8213         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8214         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
8215         return (long)ret_conv;
8216 }
8217
8218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8219         if ((_res & 1) != 0) return;
8220         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
8221         FREE((void*)_res);
8222         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
8223 }
8224
8225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8226         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
8227         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8228         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
8229         return (long)ret_conv;
8230 }
8231
8232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8233         LDKSignature o_ref;
8234         CHECK((*env)->GetArrayLength(env, o) == 64);
8235         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
8236         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8237         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
8238         return (long)ret_conv;
8239 }
8240
8241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
8242         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8243         *ret_conv = CResult_SignatureNoneZ_err();
8244         return (long)ret_conv;
8245 }
8246
8247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8248         if ((_res & 1) != 0) return;
8249         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
8250         FREE((void*)_res);
8251         CResult_SignatureNoneZ_free(_res_conv);
8252 }
8253
8254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8255         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
8256         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8257         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
8258         return (long)ret_conv;
8259 }
8260
8261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8262         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
8263         if (o_conv.free == LDKSign_JCalls_free) {
8264                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8265                 LDKSign_JCalls_clone(o_conv.this_arg);
8266         }
8267         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8268         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
8269         return (long)ret_conv;
8270 }
8271
8272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8273         LDKDecodeError e_conv;
8274         e_conv.inner = (void*)(e & (~1));
8275         e_conv.is_owned = (e & 1) || (e == 0);
8276         e_conv = DecodeError_clone(&e_conv);
8277         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8278         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
8279         return (long)ret_conv;
8280 }
8281
8282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8283         if ((_res & 1) != 0) return;
8284         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
8285         FREE((void*)_res);
8286         CResult_SignDecodeErrorZ_free(_res_conv);
8287 }
8288
8289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8290         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
8291         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8292         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
8293         return (long)ret_conv;
8294 }
8295
8296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
8297         LDKCVec_CVec_u8ZZ _res_constr;
8298         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8299         if (_res_constr.datalen > 0)
8300                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
8301         else
8302                 _res_constr.data = NULL;
8303         for (size_t i = 0; i < _res_constr.datalen; i++) {
8304                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
8305                 LDKCVec_u8Z _res_conv_8_ref;
8306                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
8307                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
8308                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
8309                 _res_constr.data[i] = _res_conv_8_ref;
8310         }
8311         CVec_CVec_u8ZZ_free(_res_constr);
8312 }
8313
8314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
8315         LDKCVec_CVec_u8ZZ o_constr;
8316         o_constr.datalen = (*env)->GetArrayLength(env, o);
8317         if (o_constr.datalen > 0)
8318                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
8319         else
8320                 o_constr.data = NULL;
8321         for (size_t i = 0; i < o_constr.datalen; i++) {
8322                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
8323                 LDKCVec_u8Z o_conv_8_ref;
8324                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
8325                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
8326                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
8327                 o_constr.data[i] = o_conv_8_ref;
8328         }
8329         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8330         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
8331         return (long)ret_conv;
8332 }
8333
8334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
8335         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8336         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
8337         return (long)ret_conv;
8338 }
8339
8340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8341         if ((_res & 1) != 0) return;
8342         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
8343         FREE((void*)_res);
8344         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
8345 }
8346
8347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8348         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
8349         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8350         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
8351         return (long)ret_conv;
8352 }
8353
8354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8355         LDKInMemorySigner o_conv;
8356         o_conv.inner = (void*)(o & (~1));
8357         o_conv.is_owned = (o & 1) || (o == 0);
8358         o_conv = InMemorySigner_clone(&o_conv);
8359         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8360         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
8361         return (long)ret_conv;
8362 }
8363
8364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8365         LDKDecodeError e_conv;
8366         e_conv.inner = (void*)(e & (~1));
8367         e_conv.is_owned = (e & 1) || (e == 0);
8368         e_conv = DecodeError_clone(&e_conv);
8369         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8370         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
8371         return (long)ret_conv;
8372 }
8373
8374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8375         if ((_res & 1) != 0) return;
8376         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
8377         FREE((void*)_res);
8378         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
8379 }
8380
8381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8382         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
8383         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8384         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
8385         return (long)ret_conv;
8386 }
8387
8388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8389         LDKCVec_TxOutZ _res_constr;
8390         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8391         if (_res_constr.datalen > 0)
8392                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
8393         else
8394                 _res_constr.data = NULL;
8395         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8396         for (size_t h = 0; h < _res_constr.datalen; h++) {
8397                 int64_t _res_conv_7 = _res_vals[h];
8398                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
8399                 FREE((void*)_res_conv_7);
8400                 _res_constr.data[h] = _res_conv_7_conv;
8401         }
8402         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8403         CVec_TxOutZ_free(_res_constr);
8404 }
8405
8406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8407         LDKTransaction o_ref;
8408         o_ref.datalen = (*env)->GetArrayLength(env, o);
8409         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
8410         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
8411         o_ref.data_is_owned = true;
8412         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8413         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
8414         return (long)ret_conv;
8415 }
8416
8417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
8418         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8419         *ret_conv = CResult_TransactionNoneZ_err();
8420         return (long)ret_conv;
8421 }
8422
8423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8424         if ((_res & 1) != 0) return;
8425         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
8426         FREE((void*)_res);
8427         CResult_TransactionNoneZ_free(_res_conv);
8428 }
8429
8430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8431         LDKCVec_RouteHopZ _res_constr;
8432         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8433         if (_res_constr.datalen > 0)
8434                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8435         else
8436                 _res_constr.data = NULL;
8437         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8438         for (size_t k = 0; k < _res_constr.datalen; k++) {
8439                 int64_t _res_conv_10 = _res_vals[k];
8440                 LDKRouteHop _res_conv_10_conv;
8441                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
8442                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
8443                 _res_constr.data[k] = _res_conv_10_conv;
8444         }
8445         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8446         CVec_RouteHopZ_free(_res_constr);
8447 }
8448
8449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
8450         LDKCVec_CVec_RouteHopZZ _res_constr;
8451         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8452         if (_res_constr.datalen > 0)
8453                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
8454         else
8455                 _res_constr.data = NULL;
8456         for (size_t m = 0; m < _res_constr.datalen; m++) {
8457                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
8458                 LDKCVec_RouteHopZ _res_conv_12_constr;
8459                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
8460                 if (_res_conv_12_constr.datalen > 0)
8461                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8462                 else
8463                         _res_conv_12_constr.data = NULL;
8464                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
8465                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
8466                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
8467                         LDKRouteHop _res_conv_12_conv_10_conv;
8468                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
8469                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
8470                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
8471                 }
8472                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
8473                 _res_constr.data[m] = _res_conv_12_constr;
8474         }
8475         CVec_CVec_RouteHopZZ_free(_res_constr);
8476 }
8477
8478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8479         LDKRoute o_conv;
8480         o_conv.inner = (void*)(o & (~1));
8481         o_conv.is_owned = (o & 1) || (o == 0);
8482         o_conv = Route_clone(&o_conv);
8483         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8484         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
8485         return (long)ret_conv;
8486 }
8487
8488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8489         LDKDecodeError e_conv;
8490         e_conv.inner = (void*)(e & (~1));
8491         e_conv.is_owned = (e & 1) || (e == 0);
8492         e_conv = DecodeError_clone(&e_conv);
8493         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8494         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
8495         return (long)ret_conv;
8496 }
8497
8498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8499         if ((_res & 1) != 0) return;
8500         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
8501         FREE((void*)_res);
8502         CResult_RouteDecodeErrorZ_free(_res_conv);
8503 }
8504
8505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8506         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
8507         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8508         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
8509         return (long)ret_conv;
8510 }
8511
8512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8513         LDKCVec_RouteHintZ _res_constr;
8514         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8515         if (_res_constr.datalen > 0)
8516                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
8517         else
8518                 _res_constr.data = NULL;
8519         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8520         for (size_t l = 0; l < _res_constr.datalen; l++) {
8521                 int64_t _res_conv_11 = _res_vals[l];
8522                 LDKRouteHint _res_conv_11_conv;
8523                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
8524                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
8525                 _res_constr.data[l] = _res_conv_11_conv;
8526         }
8527         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8528         CVec_RouteHintZ_free(_res_constr);
8529 }
8530
8531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8532         LDKRoute o_conv;
8533         o_conv.inner = (void*)(o & (~1));
8534         o_conv.is_owned = (o & 1) || (o == 0);
8535         o_conv = Route_clone(&o_conv);
8536         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8537         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
8538         return (long)ret_conv;
8539 }
8540
8541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8542         LDKLightningError e_conv;
8543         e_conv.inner = (void*)(e & (~1));
8544         e_conv.is_owned = (e & 1) || (e == 0);
8545         e_conv = LightningError_clone(&e_conv);
8546         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8547         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
8548         return (long)ret_conv;
8549 }
8550
8551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8552         if ((_res & 1) != 0) return;
8553         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
8554         FREE((void*)_res);
8555         CResult_RouteLightningErrorZ_free(_res_conv);
8556 }
8557
8558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8559         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
8560         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8561         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
8562         return (long)ret_conv;
8563 }
8564
8565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
8566         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
8567         FREE((void*)o);
8568         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8569         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
8570         return (long)ret_conv;
8571 }
8572
8573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
8574         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8575         *ret_conv = CResult_NetAddressu8Z_err(e);
8576         return (long)ret_conv;
8577 }
8578
8579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
8580         if ((_res & 1) != 0) return;
8581         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
8582         FREE((void*)_res);
8583         CResult_NetAddressu8Z_free(_res_conv);
8584 }
8585
8586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8587         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
8588         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8589         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
8590         return (long)ret_conv;
8591 }
8592
8593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8594         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
8595         FREE((void*)o);
8596         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8597         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
8598         return (long)ret_conv;
8599 }
8600
8601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8602         LDKDecodeError e_conv;
8603         e_conv.inner = (void*)(e & (~1));
8604         e_conv.is_owned = (e & 1) || (e == 0);
8605         e_conv = DecodeError_clone(&e_conv);
8606         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8607         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
8608         return (long)ret_conv;
8609 }
8610
8611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8612         if ((_res & 1) != 0) return;
8613         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8614         FREE((void*)_res);
8615         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
8616 }
8617
8618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8619         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
8620         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8621         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
8622         return (long)ret_conv;
8623 }
8624
8625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8626         LDKCVec_UpdateAddHTLCZ _res_constr;
8627         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8628         if (_res_constr.datalen > 0)
8629                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
8630         else
8631                 _res_constr.data = NULL;
8632         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8633         for (size_t p = 0; p < _res_constr.datalen; p++) {
8634                 int64_t _res_conv_15 = _res_vals[p];
8635                 LDKUpdateAddHTLC _res_conv_15_conv;
8636                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
8637                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
8638                 _res_constr.data[p] = _res_conv_15_conv;
8639         }
8640         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8641         CVec_UpdateAddHTLCZ_free(_res_constr);
8642 }
8643
8644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8645         LDKCVec_UpdateFulfillHTLCZ _res_constr;
8646         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8647         if (_res_constr.datalen > 0)
8648                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
8649         else
8650                 _res_constr.data = NULL;
8651         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8652         for (size_t t = 0; t < _res_constr.datalen; t++) {
8653                 int64_t _res_conv_19 = _res_vals[t];
8654                 LDKUpdateFulfillHTLC _res_conv_19_conv;
8655                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
8656                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
8657                 _res_constr.data[t] = _res_conv_19_conv;
8658         }
8659         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8660         CVec_UpdateFulfillHTLCZ_free(_res_constr);
8661 }
8662
8663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8664         LDKCVec_UpdateFailHTLCZ _res_constr;
8665         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8666         if (_res_constr.datalen > 0)
8667                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
8668         else
8669                 _res_constr.data = NULL;
8670         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8671         for (size_t q = 0; q < _res_constr.datalen; q++) {
8672                 int64_t _res_conv_16 = _res_vals[q];
8673                 LDKUpdateFailHTLC _res_conv_16_conv;
8674                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8675                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8676                 _res_constr.data[q] = _res_conv_16_conv;
8677         }
8678         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8679         CVec_UpdateFailHTLCZ_free(_res_constr);
8680 }
8681
8682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8683         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
8684         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8685         if (_res_constr.datalen > 0)
8686                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
8687         else
8688                 _res_constr.data = NULL;
8689         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8690         for (size_t z = 0; z < _res_constr.datalen; z++) {
8691                 int64_t _res_conv_25 = _res_vals[z];
8692                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
8693                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
8694                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
8695                 _res_constr.data[z] = _res_conv_25_conv;
8696         }
8697         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8698         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
8699 }
8700
8701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8702         LDKAcceptChannel o_conv;
8703         o_conv.inner = (void*)(o & (~1));
8704         o_conv.is_owned = (o & 1) || (o == 0);
8705         o_conv = AcceptChannel_clone(&o_conv);
8706         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
8707         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
8708         return (long)ret_conv;
8709 }
8710
8711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8712         LDKDecodeError e_conv;
8713         e_conv.inner = (void*)(e & (~1));
8714         e_conv.is_owned = (e & 1) || (e == 0);
8715         e_conv = DecodeError_clone(&e_conv);
8716         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
8717         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
8718         return (long)ret_conv;
8719 }
8720
8721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8722         if ((_res & 1) != 0) return;
8723         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
8724         FREE((void*)_res);
8725         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
8726 }
8727
8728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8729         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
8730         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
8731         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
8732         return (long)ret_conv;
8733 }
8734
8735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8736         LDKAnnouncementSignatures o_conv;
8737         o_conv.inner = (void*)(o & (~1));
8738         o_conv.is_owned = (o & 1) || (o == 0);
8739         o_conv = AnnouncementSignatures_clone(&o_conv);
8740         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
8741         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
8742         return (long)ret_conv;
8743 }
8744
8745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8746         LDKDecodeError e_conv;
8747         e_conv.inner = (void*)(e & (~1));
8748         e_conv.is_owned = (e & 1) || (e == 0);
8749         e_conv = DecodeError_clone(&e_conv);
8750         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
8751         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
8752         return (long)ret_conv;
8753 }
8754
8755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8756         if ((_res & 1) != 0) return;
8757         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8758         FREE((void*)_res);
8759         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
8760 }
8761
8762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8763         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
8764         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
8765         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
8766         return (long)ret_conv;
8767 }
8768
8769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8770         LDKChannelReestablish o_conv;
8771         o_conv.inner = (void*)(o & (~1));
8772         o_conv.is_owned = (o & 1) || (o == 0);
8773         o_conv = ChannelReestablish_clone(&o_conv);
8774         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
8775         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
8776         return (long)ret_conv;
8777 }
8778
8779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8780         LDKDecodeError e_conv;
8781         e_conv.inner = (void*)(e & (~1));
8782         e_conv.is_owned = (e & 1) || (e == 0);
8783         e_conv = DecodeError_clone(&e_conv);
8784         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
8785         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
8786         return (long)ret_conv;
8787 }
8788
8789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8790         if ((_res & 1) != 0) return;
8791         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
8792         FREE((void*)_res);
8793         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
8794 }
8795
8796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8797         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
8798         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
8799         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
8800         return (long)ret_conv;
8801 }
8802
8803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8804         LDKClosingSigned o_conv;
8805         o_conv.inner = (void*)(o & (~1));
8806         o_conv.is_owned = (o & 1) || (o == 0);
8807         o_conv = ClosingSigned_clone(&o_conv);
8808         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
8809         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
8810         return (long)ret_conv;
8811 }
8812
8813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8814         LDKDecodeError e_conv;
8815         e_conv.inner = (void*)(e & (~1));
8816         e_conv.is_owned = (e & 1) || (e == 0);
8817         e_conv = DecodeError_clone(&e_conv);
8818         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
8819         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
8820         return (long)ret_conv;
8821 }
8822
8823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8824         if ((_res & 1) != 0) return;
8825         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8826         FREE((void*)_res);
8827         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
8828 }
8829
8830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8831         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
8832         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
8833         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
8834         return (long)ret_conv;
8835 }
8836
8837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8838         LDKCommitmentSigned o_conv;
8839         o_conv.inner = (void*)(o & (~1));
8840         o_conv.is_owned = (o & 1) || (o == 0);
8841         o_conv = CommitmentSigned_clone(&o_conv);
8842         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8843         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
8844         return (long)ret_conv;
8845 }
8846
8847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8848         LDKDecodeError e_conv;
8849         e_conv.inner = (void*)(e & (~1));
8850         e_conv.is_owned = (e & 1) || (e == 0);
8851         e_conv = DecodeError_clone(&e_conv);
8852         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8853         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
8854         return (long)ret_conv;
8855 }
8856
8857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8858         if ((_res & 1) != 0) return;
8859         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8860         FREE((void*)_res);
8861         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
8862 }
8863
8864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8865         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
8866         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8867         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
8868         return (long)ret_conv;
8869 }
8870
8871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8872         LDKFundingCreated o_conv;
8873         o_conv.inner = (void*)(o & (~1));
8874         o_conv.is_owned = (o & 1) || (o == 0);
8875         o_conv = FundingCreated_clone(&o_conv);
8876         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8877         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
8878         return (long)ret_conv;
8879 }
8880
8881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8882         LDKDecodeError e_conv;
8883         e_conv.inner = (void*)(e & (~1));
8884         e_conv.is_owned = (e & 1) || (e == 0);
8885         e_conv = DecodeError_clone(&e_conv);
8886         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8887         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
8888         return (long)ret_conv;
8889 }
8890
8891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8892         if ((_res & 1) != 0) return;
8893         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8894         FREE((void*)_res);
8895         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
8896 }
8897
8898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8899         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
8900         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8901         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
8902         return (long)ret_conv;
8903 }
8904
8905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8906         LDKFundingSigned o_conv;
8907         o_conv.inner = (void*)(o & (~1));
8908         o_conv.is_owned = (o & 1) || (o == 0);
8909         o_conv = FundingSigned_clone(&o_conv);
8910         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8911         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
8912         return (long)ret_conv;
8913 }
8914
8915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8916         LDKDecodeError e_conv;
8917         e_conv.inner = (void*)(e & (~1));
8918         e_conv.is_owned = (e & 1) || (e == 0);
8919         e_conv = DecodeError_clone(&e_conv);
8920         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8921         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
8922         return (long)ret_conv;
8923 }
8924
8925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8926         if ((_res & 1) != 0) return;
8927         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8928         FREE((void*)_res);
8929         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
8930 }
8931
8932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8933         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
8934         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8935         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
8936         return (long)ret_conv;
8937 }
8938
8939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8940         LDKFundingLocked o_conv;
8941         o_conv.inner = (void*)(o & (~1));
8942         o_conv.is_owned = (o & 1) || (o == 0);
8943         o_conv = FundingLocked_clone(&o_conv);
8944         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
8945         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
8946         return (long)ret_conv;
8947 }
8948
8949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8950         LDKDecodeError e_conv;
8951         e_conv.inner = (void*)(e & (~1));
8952         e_conv.is_owned = (e & 1) || (e == 0);
8953         e_conv = DecodeError_clone(&e_conv);
8954         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
8955         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
8956         return (long)ret_conv;
8957 }
8958
8959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8960         if ((_res & 1) != 0) return;
8961         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8962         FREE((void*)_res);
8963         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
8964 }
8965
8966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8967         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
8968         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
8969         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
8970         return (long)ret_conv;
8971 }
8972
8973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8974         LDKInit o_conv;
8975         o_conv.inner = (void*)(o & (~1));
8976         o_conv.is_owned = (o & 1) || (o == 0);
8977         o_conv = Init_clone(&o_conv);
8978         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
8979         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
8980         return (long)ret_conv;
8981 }
8982
8983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8984         LDKDecodeError e_conv;
8985         e_conv.inner = (void*)(e & (~1));
8986         e_conv.is_owned = (e & 1) || (e == 0);
8987         e_conv = DecodeError_clone(&e_conv);
8988         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
8989         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
8990         return (long)ret_conv;
8991 }
8992
8993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8994         if ((_res & 1) != 0) return;
8995         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
8996         FREE((void*)_res);
8997         CResult_InitDecodeErrorZ_free(_res_conv);
8998 }
8999
9000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9001         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
9002         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9003         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
9004         return (long)ret_conv;
9005 }
9006
9007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9008         LDKOpenChannel o_conv;
9009         o_conv.inner = (void*)(o & (~1));
9010         o_conv.is_owned = (o & 1) || (o == 0);
9011         o_conv = OpenChannel_clone(&o_conv);
9012         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9013         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
9014         return (long)ret_conv;
9015 }
9016
9017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9018         LDKDecodeError e_conv;
9019         e_conv.inner = (void*)(e & (~1));
9020         e_conv.is_owned = (e & 1) || (e == 0);
9021         e_conv = DecodeError_clone(&e_conv);
9022         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9023         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
9024         return (long)ret_conv;
9025 }
9026
9027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9028         if ((_res & 1) != 0) return;
9029         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
9030         FREE((void*)_res);
9031         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
9032 }
9033
9034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9035         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
9036         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9037         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
9038         return (long)ret_conv;
9039 }
9040
9041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9042         LDKRevokeAndACK o_conv;
9043         o_conv.inner = (void*)(o & (~1));
9044         o_conv.is_owned = (o & 1) || (o == 0);
9045         o_conv = RevokeAndACK_clone(&o_conv);
9046         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9047         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
9048         return (long)ret_conv;
9049 }
9050
9051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9052         LDKDecodeError e_conv;
9053         e_conv.inner = (void*)(e & (~1));
9054         e_conv.is_owned = (e & 1) || (e == 0);
9055         e_conv = DecodeError_clone(&e_conv);
9056         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9057         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
9058         return (long)ret_conv;
9059 }
9060
9061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9062         if ((_res & 1) != 0) return;
9063         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
9064         FREE((void*)_res);
9065         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
9066 }
9067
9068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9069         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
9070         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9071         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
9072         return (long)ret_conv;
9073 }
9074
9075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9076         LDKShutdown o_conv;
9077         o_conv.inner = (void*)(o & (~1));
9078         o_conv.is_owned = (o & 1) || (o == 0);
9079         o_conv = Shutdown_clone(&o_conv);
9080         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9081         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
9082         return (long)ret_conv;
9083 }
9084
9085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9086         LDKDecodeError e_conv;
9087         e_conv.inner = (void*)(e & (~1));
9088         e_conv.is_owned = (e & 1) || (e == 0);
9089         e_conv = DecodeError_clone(&e_conv);
9090         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9091         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
9092         return (long)ret_conv;
9093 }
9094
9095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9096         if ((_res & 1) != 0) return;
9097         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
9098         FREE((void*)_res);
9099         CResult_ShutdownDecodeErrorZ_free(_res_conv);
9100 }
9101
9102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9103         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
9104         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9105         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
9106         return (long)ret_conv;
9107 }
9108
9109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9110         LDKUpdateFailHTLC o_conv;
9111         o_conv.inner = (void*)(o & (~1));
9112         o_conv.is_owned = (o & 1) || (o == 0);
9113         o_conv = UpdateFailHTLC_clone(&o_conv);
9114         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9115         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
9116         return (long)ret_conv;
9117 }
9118
9119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9120         LDKDecodeError e_conv;
9121         e_conv.inner = (void*)(e & (~1));
9122         e_conv.is_owned = (e & 1) || (e == 0);
9123         e_conv = DecodeError_clone(&e_conv);
9124         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9125         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
9126         return (long)ret_conv;
9127 }
9128
9129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9130         if ((_res & 1) != 0) return;
9131         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9132         FREE((void*)_res);
9133         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
9134 }
9135
9136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9137         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
9138         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9139         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
9140         return (long)ret_conv;
9141 }
9142
9143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9144         LDKUpdateFailMalformedHTLC o_conv;
9145         o_conv.inner = (void*)(o & (~1));
9146         o_conv.is_owned = (o & 1) || (o == 0);
9147         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
9148         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
9149         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
9150         return (long)ret_conv;
9151 }
9152
9153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9154         LDKDecodeError e_conv;
9155         e_conv.inner = (void*)(e & (~1));
9156         e_conv.is_owned = (e & 1) || (e == 0);
9157         e_conv = DecodeError_clone(&e_conv);
9158         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
9159         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
9160         return (long)ret_conv;
9161 }
9162
9163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9164         if ((_res & 1) != 0) return;
9165         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9166         FREE((void*)_res);
9167         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
9168 }
9169
9170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9171         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
9172         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
9173         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
9174         return (long)ret_conv;
9175 }
9176
9177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9178         LDKUpdateFee o_conv;
9179         o_conv.inner = (void*)(o & (~1));
9180         o_conv.is_owned = (o & 1) || (o == 0);
9181         o_conv = UpdateFee_clone(&o_conv);
9182         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
9183         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
9184         return (long)ret_conv;
9185 }
9186
9187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9188         LDKDecodeError e_conv;
9189         e_conv.inner = (void*)(e & (~1));
9190         e_conv.is_owned = (e & 1) || (e == 0);
9191         e_conv = DecodeError_clone(&e_conv);
9192         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
9193         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
9194         return (long)ret_conv;
9195 }
9196
9197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9198         if ((_res & 1) != 0) return;
9199         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9200         FREE((void*)_res);
9201         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
9202 }
9203
9204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9205         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
9206         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
9207         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
9208         return (long)ret_conv;
9209 }
9210
9211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9212         LDKUpdateFulfillHTLC o_conv;
9213         o_conv.inner = (void*)(o & (~1));
9214         o_conv.is_owned = (o & 1) || (o == 0);
9215         o_conv = UpdateFulfillHTLC_clone(&o_conv);
9216         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
9217         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
9218         return (long)ret_conv;
9219 }
9220
9221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9222         LDKDecodeError e_conv;
9223         e_conv.inner = (void*)(e & (~1));
9224         e_conv.is_owned = (e & 1) || (e == 0);
9225         e_conv = DecodeError_clone(&e_conv);
9226         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
9227         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
9228         return (long)ret_conv;
9229 }
9230
9231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9232         if ((_res & 1) != 0) return;
9233         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9234         FREE((void*)_res);
9235         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
9236 }
9237
9238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9239         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
9240         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
9241         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
9242         return (long)ret_conv;
9243 }
9244
9245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9246         LDKUpdateAddHTLC o_conv;
9247         o_conv.inner = (void*)(o & (~1));
9248         o_conv.is_owned = (o & 1) || (o == 0);
9249         o_conv = UpdateAddHTLC_clone(&o_conv);
9250         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
9251         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
9252         return (long)ret_conv;
9253 }
9254
9255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9256         LDKDecodeError e_conv;
9257         e_conv.inner = (void*)(e & (~1));
9258         e_conv.is_owned = (e & 1) || (e == 0);
9259         e_conv = DecodeError_clone(&e_conv);
9260         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
9261         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
9262         return (long)ret_conv;
9263 }
9264
9265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9266         if ((_res & 1) != 0) return;
9267         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9268         FREE((void*)_res);
9269         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
9270 }
9271
9272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9273         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
9274         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
9275         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
9276         return (long)ret_conv;
9277 }
9278
9279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9280         LDKPing o_conv;
9281         o_conv.inner = (void*)(o & (~1));
9282         o_conv.is_owned = (o & 1) || (o == 0);
9283         o_conv = Ping_clone(&o_conv);
9284         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
9285         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
9286         return (long)ret_conv;
9287 }
9288
9289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9290         LDKDecodeError e_conv;
9291         e_conv.inner = (void*)(e & (~1));
9292         e_conv.is_owned = (e & 1) || (e == 0);
9293         e_conv = DecodeError_clone(&e_conv);
9294         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
9295         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
9296         return (long)ret_conv;
9297 }
9298
9299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9300         if ((_res & 1) != 0) return;
9301         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
9302         FREE((void*)_res);
9303         CResult_PingDecodeErrorZ_free(_res_conv);
9304 }
9305
9306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9307         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
9308         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
9309         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
9310         return (long)ret_conv;
9311 }
9312
9313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9314         LDKPong o_conv;
9315         o_conv.inner = (void*)(o & (~1));
9316         o_conv.is_owned = (o & 1) || (o == 0);
9317         o_conv = Pong_clone(&o_conv);
9318         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
9319         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
9320         return (long)ret_conv;
9321 }
9322
9323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9324         LDKDecodeError e_conv;
9325         e_conv.inner = (void*)(e & (~1));
9326         e_conv.is_owned = (e & 1) || (e == 0);
9327         e_conv = DecodeError_clone(&e_conv);
9328         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
9329         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
9330         return (long)ret_conv;
9331 }
9332
9333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9334         if ((_res & 1) != 0) return;
9335         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
9336         FREE((void*)_res);
9337         CResult_PongDecodeErrorZ_free(_res_conv);
9338 }
9339
9340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9341         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
9342         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
9343         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
9344         return (long)ret_conv;
9345 }
9346
9347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9348         LDKUnsignedChannelAnnouncement o_conv;
9349         o_conv.inner = (void*)(o & (~1));
9350         o_conv.is_owned = (o & 1) || (o == 0);
9351         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
9352         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
9353         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
9354         return (long)ret_conv;
9355 }
9356
9357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9358         LDKDecodeError e_conv;
9359         e_conv.inner = (void*)(e & (~1));
9360         e_conv.is_owned = (e & 1) || (e == 0);
9361         e_conv = DecodeError_clone(&e_conv);
9362         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
9363         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
9364         return (long)ret_conv;
9365 }
9366
9367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9368         if ((_res & 1) != 0) return;
9369         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9370         FREE((void*)_res);
9371         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
9372 }
9373
9374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9375         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
9376         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
9377         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
9378         return (long)ret_conv;
9379 }
9380
9381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9382         LDKChannelAnnouncement o_conv;
9383         o_conv.inner = (void*)(o & (~1));
9384         o_conv.is_owned = (o & 1) || (o == 0);
9385         o_conv = ChannelAnnouncement_clone(&o_conv);
9386         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
9387         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
9388         return (long)ret_conv;
9389 }
9390
9391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9392         LDKDecodeError e_conv;
9393         e_conv.inner = (void*)(e & (~1));
9394         e_conv.is_owned = (e & 1) || (e == 0);
9395         e_conv = DecodeError_clone(&e_conv);
9396         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
9397         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
9398         return (long)ret_conv;
9399 }
9400
9401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9402         if ((_res & 1) != 0) return;
9403         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9404         FREE((void*)_res);
9405         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
9406 }
9407
9408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9409         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
9410         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
9411         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
9412         return (long)ret_conv;
9413 }
9414
9415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9416         LDKUnsignedChannelUpdate o_conv;
9417         o_conv.inner = (void*)(o & (~1));
9418         o_conv.is_owned = (o & 1) || (o == 0);
9419         o_conv = UnsignedChannelUpdate_clone(&o_conv);
9420         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
9421         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
9422         return (long)ret_conv;
9423 }
9424
9425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9426         LDKDecodeError e_conv;
9427         e_conv.inner = (void*)(e & (~1));
9428         e_conv.is_owned = (e & 1) || (e == 0);
9429         e_conv = DecodeError_clone(&e_conv);
9430         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
9431         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
9432         return (long)ret_conv;
9433 }
9434
9435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9436         if ((_res & 1) != 0) return;
9437         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
9438         FREE((void*)_res);
9439         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
9440 }
9441
9442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9443         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
9444         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
9445         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
9446         return (long)ret_conv;
9447 }
9448
9449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9450         LDKChannelUpdate o_conv;
9451         o_conv.inner = (void*)(o & (~1));
9452         o_conv.is_owned = (o & 1) || (o == 0);
9453         o_conv = ChannelUpdate_clone(&o_conv);
9454         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
9455         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
9456         return (long)ret_conv;
9457 }
9458
9459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9460         LDKDecodeError e_conv;
9461         e_conv.inner = (void*)(e & (~1));
9462         e_conv.is_owned = (e & 1) || (e == 0);
9463         e_conv = DecodeError_clone(&e_conv);
9464         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
9465         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
9466         return (long)ret_conv;
9467 }
9468
9469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9470         if ((_res & 1) != 0) return;
9471         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
9472         FREE((void*)_res);
9473         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
9474 }
9475
9476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9477         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
9478         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
9479         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
9480         return (long)ret_conv;
9481 }
9482
9483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9484         LDKErrorMessage o_conv;
9485         o_conv.inner = (void*)(o & (~1));
9486         o_conv.is_owned = (o & 1) || (o == 0);
9487         o_conv = ErrorMessage_clone(&o_conv);
9488         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
9489         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
9490         return (long)ret_conv;
9491 }
9492
9493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9494         LDKDecodeError e_conv;
9495         e_conv.inner = (void*)(e & (~1));
9496         e_conv.is_owned = (e & 1) || (e == 0);
9497         e_conv = DecodeError_clone(&e_conv);
9498         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
9499         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
9500         return (long)ret_conv;
9501 }
9502
9503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9504         if ((_res & 1) != 0) return;
9505         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
9506         FREE((void*)_res);
9507         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
9508 }
9509
9510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9511         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
9512         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
9513         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
9514         return (long)ret_conv;
9515 }
9516
9517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9518         LDKUnsignedNodeAnnouncement o_conv;
9519         o_conv.inner = (void*)(o & (~1));
9520         o_conv.is_owned = (o & 1) || (o == 0);
9521         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
9522         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
9523         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
9524         return (long)ret_conv;
9525 }
9526
9527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9528         LDKDecodeError e_conv;
9529         e_conv.inner = (void*)(e & (~1));
9530         e_conv.is_owned = (e & 1) || (e == 0);
9531         e_conv = DecodeError_clone(&e_conv);
9532         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
9533         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
9534         return (long)ret_conv;
9535 }
9536
9537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9538         if ((_res & 1) != 0) return;
9539         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9540         FREE((void*)_res);
9541         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
9542 }
9543
9544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9545         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
9546         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
9547         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
9548         return (long)ret_conv;
9549 }
9550
9551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9552         LDKNodeAnnouncement o_conv;
9553         o_conv.inner = (void*)(o & (~1));
9554         o_conv.is_owned = (o & 1) || (o == 0);
9555         o_conv = NodeAnnouncement_clone(&o_conv);
9556         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9557         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
9558         return (long)ret_conv;
9559 }
9560
9561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9562         LDKDecodeError e_conv;
9563         e_conv.inner = (void*)(e & (~1));
9564         e_conv.is_owned = (e & 1) || (e == 0);
9565         e_conv = DecodeError_clone(&e_conv);
9566         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9567         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
9568         return (long)ret_conv;
9569 }
9570
9571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9572         if ((_res & 1) != 0) return;
9573         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9574         FREE((void*)_res);
9575         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
9576 }
9577
9578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9579         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
9580         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9581         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
9582         return (long)ret_conv;
9583 }
9584
9585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9586         LDKQueryShortChannelIds o_conv;
9587         o_conv.inner = (void*)(o & (~1));
9588         o_conv.is_owned = (o & 1) || (o == 0);
9589         o_conv = QueryShortChannelIds_clone(&o_conv);
9590         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9591         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
9592         return (long)ret_conv;
9593 }
9594
9595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9596         LDKDecodeError e_conv;
9597         e_conv.inner = (void*)(e & (~1));
9598         e_conv.is_owned = (e & 1) || (e == 0);
9599         e_conv = DecodeError_clone(&e_conv);
9600         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9601         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
9602         return (long)ret_conv;
9603 }
9604
9605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9606         if ((_res & 1) != 0) return;
9607         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
9608         FREE((void*)_res);
9609         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
9610 }
9611
9612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9613         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
9614         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9615         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
9616         return (long)ret_conv;
9617 }
9618
9619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9620         LDKReplyShortChannelIdsEnd o_conv;
9621         o_conv.inner = (void*)(o & (~1));
9622         o_conv.is_owned = (o & 1) || (o == 0);
9623         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
9624         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9625         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
9626         return (long)ret_conv;
9627 }
9628
9629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9630         LDKDecodeError e_conv;
9631         e_conv.inner = (void*)(e & (~1));
9632         e_conv.is_owned = (e & 1) || (e == 0);
9633         e_conv = DecodeError_clone(&e_conv);
9634         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9635         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
9636         return (long)ret_conv;
9637 }
9638
9639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9640         if ((_res & 1) != 0) return;
9641         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
9642         FREE((void*)_res);
9643         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
9644 }
9645
9646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9647         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
9648         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9649         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
9650         return (long)ret_conv;
9651 }
9652
9653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9654         LDKQueryChannelRange o_conv;
9655         o_conv.inner = (void*)(o & (~1));
9656         o_conv.is_owned = (o & 1) || (o == 0);
9657         o_conv = QueryChannelRange_clone(&o_conv);
9658         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9659         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
9660         return (long)ret_conv;
9661 }
9662
9663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9664         LDKDecodeError e_conv;
9665         e_conv.inner = (void*)(e & (~1));
9666         e_conv.is_owned = (e & 1) || (e == 0);
9667         e_conv = DecodeError_clone(&e_conv);
9668         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9669         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
9670         return (long)ret_conv;
9671 }
9672
9673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9674         if ((_res & 1) != 0) return;
9675         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9676         FREE((void*)_res);
9677         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
9678 }
9679
9680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9681         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
9682         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9683         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
9684         return (long)ret_conv;
9685 }
9686
9687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9688         LDKReplyChannelRange o_conv;
9689         o_conv.inner = (void*)(o & (~1));
9690         o_conv.is_owned = (o & 1) || (o == 0);
9691         o_conv = ReplyChannelRange_clone(&o_conv);
9692         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
9693         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
9694         return (long)ret_conv;
9695 }
9696
9697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9698         LDKDecodeError e_conv;
9699         e_conv.inner = (void*)(e & (~1));
9700         e_conv.is_owned = (e & 1) || (e == 0);
9701         e_conv = DecodeError_clone(&e_conv);
9702         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
9703         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
9704         return (long)ret_conv;
9705 }
9706
9707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9708         if ((_res & 1) != 0) return;
9709         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9710         FREE((void*)_res);
9711         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
9712 }
9713
9714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9715         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
9716         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
9717         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
9718         return (long)ret_conv;
9719 }
9720
9721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9722         LDKGossipTimestampFilter o_conv;
9723         o_conv.inner = (void*)(o & (~1));
9724         o_conv.is_owned = (o & 1) || (o == 0);
9725         o_conv = GossipTimestampFilter_clone(&o_conv);
9726         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
9727         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
9728         return (long)ret_conv;
9729 }
9730
9731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9732         LDKDecodeError e_conv;
9733         e_conv.inner = (void*)(e & (~1));
9734         e_conv.is_owned = (e & 1) || (e == 0);
9735         e_conv = DecodeError_clone(&e_conv);
9736         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
9737         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
9738         return (long)ret_conv;
9739 }
9740
9741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9742         if ((_res & 1) != 0) return;
9743         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
9744         FREE((void*)_res);
9745         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
9746 }
9747
9748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9749         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
9750         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
9751         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
9752         return (long)ret_conv;
9753 }
9754
9755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9756         if ((this_ptr & 1) != 0) return;
9757         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
9758         FREE((void*)this_ptr);
9759         Event_free(this_ptr_conv);
9760 }
9761
9762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9763         LDKEvent* orig_conv = (LDKEvent*)orig;
9764         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
9765         *ret_copy = Event_clone(orig_conv);
9766         long ret_ref = (long)ret_copy;
9767         return ret_ref;
9768 }
9769
9770 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
9771         LDKEvent* obj_conv = (LDKEvent*)obj;
9772         LDKCVec_u8Z ret_var = Event_write(obj_conv);
9773         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9774         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9775         CVec_u8Z_free(ret_var);
9776         return ret_arr;
9777 }
9778
9779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9780         if ((this_ptr & 1) != 0) return;
9781         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
9782         FREE((void*)this_ptr);
9783         MessageSendEvent_free(this_ptr_conv);
9784 }
9785
9786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9787         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
9788         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
9789         *ret_copy = MessageSendEvent_clone(orig_conv);
9790         long ret_ref = (long)ret_copy;
9791         return ret_ref;
9792 }
9793
9794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9795         if ((this_ptr & 1) != 0) return;
9796         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
9797         FREE((void*)this_ptr);
9798         MessageSendEventsProvider_free(this_ptr_conv);
9799 }
9800
9801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9802         if ((this_ptr & 1) != 0) return;
9803         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
9804         FREE((void*)this_ptr);
9805         EventsProvider_free(this_ptr_conv);
9806 }
9807
9808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9809         if ((this_ptr & 1) != 0) return;
9810         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
9811         FREE((void*)this_ptr);
9812         APIError_free(this_ptr_conv);
9813 }
9814
9815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9816         LDKAPIError* orig_conv = (LDKAPIError*)orig;
9817         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
9818         *ret_copy = APIError_clone(orig_conv);
9819         long ret_ref = (long)ret_copy;
9820         return ret_ref;
9821 }
9822
9823 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9824         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
9825         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
9826         return ret_conv;
9827 }
9828
9829 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
9830         jclass ret_conv = LDKLevel_to_java(env, Level_max());
9831         return ret_conv;
9832 }
9833
9834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9835         if ((this_ptr & 1) != 0) return;
9836         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
9837         FREE((void*)this_ptr);
9838         Logger_free(this_ptr_conv);
9839 }
9840
9841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
9842         LDKChannelHandshakeConfig this_obj_conv;
9843         this_obj_conv.inner = (void*)(this_obj & (~1));
9844         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9845         ChannelHandshakeConfig_free(this_obj_conv);
9846 }
9847
9848 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
9849         LDKChannelHandshakeConfig this_ptr_conv;
9850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9851         this_ptr_conv.is_owned = false;
9852         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
9853         return ret_val;
9854 }
9855
9856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
9857         LDKChannelHandshakeConfig this_ptr_conv;
9858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9859         this_ptr_conv.is_owned = false;
9860         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
9861 }
9862
9863 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
9864         LDKChannelHandshakeConfig this_ptr_conv;
9865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9866         this_ptr_conv.is_owned = false;
9867         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
9868         return ret_val;
9869 }
9870
9871 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) {
9872         LDKChannelHandshakeConfig this_ptr_conv;
9873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9874         this_ptr_conv.is_owned = false;
9875         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
9876 }
9877
9878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
9879         LDKChannelHandshakeConfig this_ptr_conv;
9880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9881         this_ptr_conv.is_owned = false;
9882         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
9883         return ret_val;
9884 }
9885
9886 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) {
9887         LDKChannelHandshakeConfig this_ptr_conv;
9888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9889         this_ptr_conv.is_owned = false;
9890         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
9891 }
9892
9893 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) {
9894         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
9895         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9896         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9897         long ret_ref = (long)ret_var.inner;
9898         if (ret_var.is_owned) {
9899                 ret_ref |= 1;
9900         }
9901         return ret_ref;
9902 }
9903
9904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9905         LDKChannelHandshakeConfig orig_conv;
9906         orig_conv.inner = (void*)(orig & (~1));
9907         orig_conv.is_owned = false;
9908         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
9909         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9910         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9911         long ret_ref = (long)ret_var.inner;
9912         if (ret_var.is_owned) {
9913                 ret_ref |= 1;
9914         }
9915         return ret_ref;
9916 }
9917
9918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
9919         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
9920         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9921         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9922         long ret_ref = (long)ret_var.inner;
9923         if (ret_var.is_owned) {
9924                 ret_ref |= 1;
9925         }
9926         return ret_ref;
9927 }
9928
9929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
9930         LDKChannelHandshakeLimits this_obj_conv;
9931         this_obj_conv.inner = (void*)(this_obj & (~1));
9932         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9933         ChannelHandshakeLimits_free(this_obj_conv);
9934 }
9935
9936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
9937         LDKChannelHandshakeLimits this_ptr_conv;
9938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9939         this_ptr_conv.is_owned = false;
9940         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
9941         return ret_val;
9942 }
9943
9944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
9945         LDKChannelHandshakeLimits this_ptr_conv;
9946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9947         this_ptr_conv.is_owned = false;
9948         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
9949 }
9950
9951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
9952         LDKChannelHandshakeLimits this_ptr_conv;
9953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9954         this_ptr_conv.is_owned = false;
9955         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
9956         return ret_val;
9957 }
9958
9959 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) {
9960         LDKChannelHandshakeLimits this_ptr_conv;
9961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9962         this_ptr_conv.is_owned = false;
9963         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
9964 }
9965
9966 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) {
9967         LDKChannelHandshakeLimits this_ptr_conv;
9968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9969         this_ptr_conv.is_owned = false;
9970         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
9971         return ret_val;
9972 }
9973
9974 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) {
9975         LDKChannelHandshakeLimits this_ptr_conv;
9976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9977         this_ptr_conv.is_owned = false;
9978         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
9979 }
9980
9981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
9982         LDKChannelHandshakeLimits this_ptr_conv;
9983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9984         this_ptr_conv.is_owned = false;
9985         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
9986         return ret_val;
9987 }
9988
9989 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) {
9990         LDKChannelHandshakeLimits this_ptr_conv;
9991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9992         this_ptr_conv.is_owned = false;
9993         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
9994 }
9995
9996 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
9997         LDKChannelHandshakeLimits this_ptr_conv;
9998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9999         this_ptr_conv.is_owned = false;
10000         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
10001         return ret_val;
10002 }
10003
10004 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) {
10005         LDKChannelHandshakeLimits this_ptr_conv;
10006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10007         this_ptr_conv.is_owned = false;
10008         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
10009 }
10010
10011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10012         LDKChannelHandshakeLimits this_ptr_conv;
10013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10014         this_ptr_conv.is_owned = false;
10015         int64_t ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
10016         return ret_val;
10017 }
10018
10019 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) {
10020         LDKChannelHandshakeLimits this_ptr_conv;
10021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10022         this_ptr_conv.is_owned = false;
10023         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
10024 }
10025
10026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10027         LDKChannelHandshakeLimits this_ptr_conv;
10028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10029         this_ptr_conv.is_owned = false;
10030         int64_t ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
10031         return ret_val;
10032 }
10033
10034 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) {
10035         LDKChannelHandshakeLimits this_ptr_conv;
10036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10037         this_ptr_conv.is_owned = false;
10038         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
10039 }
10040
10041 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
10042         LDKChannelHandshakeLimits this_ptr_conv;
10043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10044         this_ptr_conv.is_owned = false;
10045         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
10046         return ret_val;
10047 }
10048
10049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
10050         LDKChannelHandshakeLimits this_ptr_conv;
10051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10052         this_ptr_conv.is_owned = false;
10053         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
10054 }
10055
10056 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
10057         LDKChannelHandshakeLimits this_ptr_conv;
10058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10059         this_ptr_conv.is_owned = false;
10060         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
10061         return ret_val;
10062 }
10063
10064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
10065         LDKChannelHandshakeLimits this_ptr_conv;
10066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10067         this_ptr_conv.is_owned = false;
10068         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
10069 }
10070
10071 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
10072         LDKChannelHandshakeLimits this_ptr_conv;
10073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10074         this_ptr_conv.is_owned = false;
10075         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
10076         return ret_val;
10077 }
10078
10079 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) {
10080         LDKChannelHandshakeLimits this_ptr_conv;
10081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10082         this_ptr_conv.is_owned = false;
10083         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
10084 }
10085
10086 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) {
10087         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);
10088         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10089         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10090         long ret_ref = (long)ret_var.inner;
10091         if (ret_var.is_owned) {
10092                 ret_ref |= 1;
10093         }
10094         return ret_ref;
10095 }
10096
10097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10098         LDKChannelHandshakeLimits orig_conv;
10099         orig_conv.inner = (void*)(orig & (~1));
10100         orig_conv.is_owned = false;
10101         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
10102         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10103         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10104         long ret_ref = (long)ret_var.inner;
10105         if (ret_var.is_owned) {
10106                 ret_ref |= 1;
10107         }
10108         return ret_ref;
10109 }
10110
10111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
10112         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
10113         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10114         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10115         long ret_ref = (long)ret_var.inner;
10116         if (ret_var.is_owned) {
10117                 ret_ref |= 1;
10118         }
10119         return ret_ref;
10120 }
10121
10122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10123         LDKChannelConfig this_obj_conv;
10124         this_obj_conv.inner = (void*)(this_obj & (~1));
10125         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10126         ChannelConfig_free(this_obj_conv);
10127 }
10128
10129 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
10130         LDKChannelConfig this_ptr_conv;
10131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10132         this_ptr_conv.is_owned = false;
10133         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
10134         return ret_val;
10135 }
10136
10137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
10138         LDKChannelConfig this_ptr_conv;
10139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10140         this_ptr_conv.is_owned = false;
10141         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
10142 }
10143
10144 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
10145         LDKChannelConfig this_ptr_conv;
10146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10147         this_ptr_conv.is_owned = false;
10148         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
10149         return ret_val;
10150 }
10151
10152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
10153         LDKChannelConfig this_ptr_conv;
10154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10155         this_ptr_conv.is_owned = false;
10156         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
10157 }
10158
10159 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
10160         LDKChannelConfig this_ptr_conv;
10161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10162         this_ptr_conv.is_owned = false;
10163         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
10164         return ret_val;
10165 }
10166
10167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
10168         LDKChannelConfig this_ptr_conv;
10169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10170         this_ptr_conv.is_owned = false;
10171         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
10172 }
10173
10174 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) {
10175         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
10176         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10177         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10178         long ret_ref = (long)ret_var.inner;
10179         if (ret_var.is_owned) {
10180                 ret_ref |= 1;
10181         }
10182         return ret_ref;
10183 }
10184
10185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10186         LDKChannelConfig orig_conv;
10187         orig_conv.inner = (void*)(orig & (~1));
10188         orig_conv.is_owned = false;
10189         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
10190         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10191         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10192         long ret_ref = (long)ret_var.inner;
10193         if (ret_var.is_owned) {
10194                 ret_ref |= 1;
10195         }
10196         return ret_ref;
10197 }
10198
10199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
10200         LDKChannelConfig ret_var = ChannelConfig_default();
10201         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10202         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10203         long ret_ref = (long)ret_var.inner;
10204         if (ret_var.is_owned) {
10205                 ret_ref |= 1;
10206         }
10207         return ret_ref;
10208 }
10209
10210 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
10211         LDKChannelConfig obj_conv;
10212         obj_conv.inner = (void*)(obj & (~1));
10213         obj_conv.is_owned = false;
10214         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
10215         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10216         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10217         CVec_u8Z_free(ret_var);
10218         return ret_arr;
10219 }
10220
10221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10222         LDKu8slice ser_ref;
10223         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10224         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10225         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10226         *ret_conv = ChannelConfig_read(ser_ref);
10227         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10228         return (long)ret_conv;
10229 }
10230
10231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10232         LDKUserConfig this_obj_conv;
10233         this_obj_conv.inner = (void*)(this_obj & (~1));
10234         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10235         UserConfig_free(this_obj_conv);
10236 }
10237
10238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
10239         LDKUserConfig this_ptr_conv;
10240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10241         this_ptr_conv.is_owned = false;
10242         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
10243         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10244         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10245         long ret_ref = (long)ret_var.inner;
10246         if (ret_var.is_owned) {
10247                 ret_ref |= 1;
10248         }
10249         return ret_ref;
10250 }
10251
10252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10253         LDKUserConfig this_ptr_conv;
10254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10255         this_ptr_conv.is_owned = false;
10256         LDKChannelHandshakeConfig val_conv;
10257         val_conv.inner = (void*)(val & (~1));
10258         val_conv.is_owned = (val & 1) || (val == 0);
10259         val_conv = ChannelHandshakeConfig_clone(&val_conv);
10260         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
10261 }
10262
10263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
10264         LDKUserConfig this_ptr_conv;
10265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10266         this_ptr_conv.is_owned = false;
10267         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
10268         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10269         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10270         long ret_ref = (long)ret_var.inner;
10271         if (ret_var.is_owned) {
10272                 ret_ref |= 1;
10273         }
10274         return ret_ref;
10275 }
10276
10277 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) {
10278         LDKUserConfig this_ptr_conv;
10279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10280         this_ptr_conv.is_owned = false;
10281         LDKChannelHandshakeLimits val_conv;
10282         val_conv.inner = (void*)(val & (~1));
10283         val_conv.is_owned = (val & 1) || (val == 0);
10284         val_conv = ChannelHandshakeLimits_clone(&val_conv);
10285         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
10286 }
10287
10288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
10289         LDKUserConfig this_ptr_conv;
10290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10291         this_ptr_conv.is_owned = false;
10292         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
10293         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10294         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10295         long ret_ref = (long)ret_var.inner;
10296         if (ret_var.is_owned) {
10297                 ret_ref |= 1;
10298         }
10299         return ret_ref;
10300 }
10301
10302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10303         LDKUserConfig this_ptr_conv;
10304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10305         this_ptr_conv.is_owned = false;
10306         LDKChannelConfig val_conv;
10307         val_conv.inner = (void*)(val & (~1));
10308         val_conv.is_owned = (val & 1) || (val == 0);
10309         val_conv = ChannelConfig_clone(&val_conv);
10310         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
10311 }
10312
10313 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) {
10314         LDKChannelHandshakeConfig own_channel_config_arg_conv;
10315         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
10316         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
10317         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
10318         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
10319         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
10320         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
10321         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
10322         LDKChannelConfig channel_options_arg_conv;
10323         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
10324         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
10325         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
10326         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
10327         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10328         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10329         long ret_ref = (long)ret_var.inner;
10330         if (ret_var.is_owned) {
10331                 ret_ref |= 1;
10332         }
10333         return ret_ref;
10334 }
10335
10336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10337         LDKUserConfig orig_conv;
10338         orig_conv.inner = (void*)(orig & (~1));
10339         orig_conv.is_owned = false;
10340         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
10341         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10342         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10343         long ret_ref = (long)ret_var.inner;
10344         if (ret_var.is_owned) {
10345                 ret_ref |= 1;
10346         }
10347         return ret_ref;
10348 }
10349
10350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
10351         LDKUserConfig ret_var = UserConfig_default();
10352         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10353         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10354         long ret_ref = (long)ret_var.inner;
10355         if (ret_var.is_owned) {
10356                 ret_ref |= 1;
10357         }
10358         return ret_ref;
10359 }
10360
10361 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10362         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
10363         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
10364         return ret_conv;
10365 }
10366
10367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10368         if ((this_ptr & 1) != 0) return;
10369         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
10370         FREE((void*)this_ptr);
10371         Access_free(this_ptr_conv);
10372 }
10373
10374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10375         if ((this_ptr & 1) != 0) return;
10376         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
10377         FREE((void*)this_ptr);
10378         Listen_free(this_ptr_conv);
10379 }
10380
10381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10382         if ((this_ptr & 1) != 0) return;
10383         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
10384         FREE((void*)this_ptr);
10385         Watch_free(this_ptr_conv);
10386 }
10387
10388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10389         if ((this_ptr & 1) != 0) return;
10390         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
10391         FREE((void*)this_ptr);
10392         Filter_free(this_ptr_conv);
10393 }
10394
10395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10396         if ((this_ptr & 1) != 0) return;
10397         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
10398         FREE((void*)this_ptr);
10399         BroadcasterInterface_free(this_ptr_conv);
10400 }
10401
10402 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10403         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
10404         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
10405         return ret_conv;
10406 }
10407
10408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10409         if ((this_ptr & 1) != 0) return;
10410         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
10411         FREE((void*)this_ptr);
10412         FeeEstimator_free(this_ptr_conv);
10413 }
10414
10415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10416         LDKChainMonitor this_obj_conv;
10417         this_obj_conv.inner = (void*)(this_obj & (~1));
10418         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10419         ChainMonitor_free(this_obj_conv);
10420 }
10421
10422 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) {
10423         LDKChainMonitor this_arg_conv;
10424         this_arg_conv.inner = (void*)(this_arg & (~1));
10425         this_arg_conv.is_owned = false;
10426         unsigned char header_arr[80];
10427         CHECK((*env)->GetArrayLength(env, header) == 80);
10428         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10429         unsigned char (*header_ref)[80] = &header_arr;
10430         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10431         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
10432         if (txdata_constr.datalen > 0)
10433                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10434         else
10435                 txdata_constr.data = NULL;
10436         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
10437         for (size_t y = 0; y < txdata_constr.datalen; y++) {
10438                 int64_t txdata_conv_24 = txdata_vals[y];
10439                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
10440                 FREE((void*)txdata_conv_24);
10441                 txdata_constr.data[y] = txdata_conv_24_conv;
10442         }
10443         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
10444         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
10445 }
10446
10447 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) {
10448         LDKChainMonitor this_arg_conv;
10449         this_arg_conv.inner = (void*)(this_arg & (~1));
10450         this_arg_conv.is_owned = false;
10451         unsigned char header_arr[80];
10452         CHECK((*env)->GetArrayLength(env, header) == 80);
10453         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10454         unsigned char (*header_ref)[80] = &header_arr;
10455         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
10456 }
10457
10458 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) {
10459         LDKFilter *chain_source_conv_ptr = NULL;
10460         if (chain_source != 0) {
10461                 LDKFilter chain_source_conv;
10462                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
10463                 if (chain_source_conv.free == LDKFilter_JCalls_free) {
10464                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10465                         LDKFilter_JCalls_clone(chain_source_conv.this_arg);
10466                 }
10467                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
10468                 *chain_source_conv_ptr = chain_source_conv;
10469         }
10470         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10471         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
10472                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10473                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
10474         }
10475         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10476         if (logger_conv.free == LDKLogger_JCalls_free) {
10477                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10478                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10479         }
10480         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
10481         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
10482                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10483                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
10484         }
10485         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
10486         if (persister_conv.free == LDKPersist_JCalls_free) {
10487                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10488                 LDKPersist_JCalls_clone(persister_conv.this_arg);
10489         }
10490         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
10491         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10492         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10493         long ret_ref = (long)ret_var.inner;
10494         if (ret_var.is_owned) {
10495                 ret_ref |= 1;
10496         }
10497         return ret_ref;
10498 }
10499
10500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
10501         LDKChainMonitor this_arg_conv;
10502         this_arg_conv.inner = (void*)(this_arg & (~1));
10503         this_arg_conv.is_owned = false;
10504         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
10505         *ret = ChainMonitor_as_Watch(&this_arg_conv);
10506         return (long)ret;
10507 }
10508
10509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
10510         LDKChainMonitor this_arg_conv;
10511         this_arg_conv.inner = (void*)(this_arg & (~1));
10512         this_arg_conv.is_owned = false;
10513         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10514         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
10515         return (long)ret;
10516 }
10517
10518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10519         LDKChannelMonitorUpdate this_obj_conv;
10520         this_obj_conv.inner = (void*)(this_obj & (~1));
10521         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10522         ChannelMonitorUpdate_free(this_obj_conv);
10523 }
10524
10525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
10526         LDKChannelMonitorUpdate this_ptr_conv;
10527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10528         this_ptr_conv.is_owned = false;
10529         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
10530         return ret_val;
10531 }
10532
10533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10534         LDKChannelMonitorUpdate this_ptr_conv;
10535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10536         this_ptr_conv.is_owned = false;
10537         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
10538 }
10539
10540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10541         LDKChannelMonitorUpdate orig_conv;
10542         orig_conv.inner = (void*)(orig & (~1));
10543         orig_conv.is_owned = false;
10544         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
10545         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10546         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10547         long ret_ref = (long)ret_var.inner;
10548         if (ret_var.is_owned) {
10549                 ret_ref |= 1;
10550         }
10551         return ret_ref;
10552 }
10553
10554 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
10555         LDKChannelMonitorUpdate obj_conv;
10556         obj_conv.inner = (void*)(obj & (~1));
10557         obj_conv.is_owned = false;
10558         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
10559         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10560         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10561         CVec_u8Z_free(ret_var);
10562         return ret_arr;
10563 }
10564
10565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10566         LDKu8slice ser_ref;
10567         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10568         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10569         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10570         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
10571         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10572         return (long)ret_conv;
10573 }
10574
10575 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10576         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
10577         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
10578         return ret_conv;
10579 }
10580
10581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10582         LDKMonitorUpdateError this_obj_conv;
10583         this_obj_conv.inner = (void*)(this_obj & (~1));
10584         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10585         MonitorUpdateError_free(this_obj_conv);
10586 }
10587
10588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10589         LDKMonitorUpdateError orig_conv;
10590         orig_conv.inner = (void*)(orig & (~1));
10591         orig_conv.is_owned = false;
10592         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
10593         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10594         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10595         long ret_ref = (long)ret_var.inner;
10596         if (ret_var.is_owned) {
10597                 ret_ref |= 1;
10598         }
10599         return ret_ref;
10600 }
10601
10602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10603         if ((this_ptr & 1) != 0) return;
10604         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
10605         FREE((void*)this_ptr);
10606         MonitorEvent_free(this_ptr_conv);
10607 }
10608
10609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10610         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
10611         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
10612         *ret_copy = MonitorEvent_clone(orig_conv);
10613         long ret_ref = (long)ret_copy;
10614         return ret_ref;
10615 }
10616
10617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10618         LDKHTLCUpdate this_obj_conv;
10619         this_obj_conv.inner = (void*)(this_obj & (~1));
10620         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10621         HTLCUpdate_free(this_obj_conv);
10622 }
10623
10624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10625         LDKHTLCUpdate orig_conv;
10626         orig_conv.inner = (void*)(orig & (~1));
10627         orig_conv.is_owned = false;
10628         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
10629         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10630         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10631         long ret_ref = (long)ret_var.inner;
10632         if (ret_var.is_owned) {
10633                 ret_ref |= 1;
10634         }
10635         return ret_ref;
10636 }
10637
10638 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
10639         LDKHTLCUpdate obj_conv;
10640         obj_conv.inner = (void*)(obj & (~1));
10641         obj_conv.is_owned = false;
10642         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
10643         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10644         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10645         CVec_u8Z_free(ret_var);
10646         return ret_arr;
10647 }
10648
10649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10650         LDKu8slice ser_ref;
10651         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10652         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10653         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10654         *ret_conv = HTLCUpdate_read(ser_ref);
10655         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10656         return (long)ret_conv;
10657 }
10658
10659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10660         LDKChannelMonitor this_obj_conv;
10661         this_obj_conv.inner = (void*)(this_obj & (~1));
10662         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10663         ChannelMonitor_free(this_obj_conv);
10664 }
10665
10666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10667         LDKChannelMonitor orig_conv;
10668         orig_conv.inner = (void*)(orig & (~1));
10669         orig_conv.is_owned = false;
10670         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
10671         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10672         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10673         long ret_ref = (long)ret_var.inner;
10674         if (ret_var.is_owned) {
10675                 ret_ref |= 1;
10676         }
10677         return ret_ref;
10678 }
10679
10680 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
10681         LDKChannelMonitor obj_conv;
10682         obj_conv.inner = (void*)(obj & (~1));
10683         obj_conv.is_owned = false;
10684         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
10685         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10686         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10687         CVec_u8Z_free(ret_var);
10688         return ret_arr;
10689 }
10690
10691 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) {
10692         LDKChannelMonitor this_arg_conv;
10693         this_arg_conv.inner = (void*)(this_arg & (~1));
10694         this_arg_conv.is_owned = false;
10695         LDKChannelMonitorUpdate updates_conv;
10696         updates_conv.inner = (void*)(updates & (~1));
10697         updates_conv.is_owned = false;
10698         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10699         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
10700         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
10701         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10702         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
10703         return (long)ret_conv;
10704 }
10705
10706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
10707         LDKChannelMonitor this_arg_conv;
10708         this_arg_conv.inner = (void*)(this_arg & (~1));
10709         this_arg_conv.is_owned = false;
10710         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
10711         return ret_val;
10712 }
10713
10714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
10715         LDKChannelMonitor this_arg_conv;
10716         this_arg_conv.inner = (void*)(this_arg & (~1));
10717         this_arg_conv.is_owned = false;
10718         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
10719         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
10720         return (long)ret_ref;
10721 }
10722
10723 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
10724         LDKChannelMonitor this_arg_conv;
10725         this_arg_conv.inner = (void*)(this_arg & (~1));
10726         this_arg_conv.is_owned = false;
10727         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
10728         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10729         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10730         for (size_t v = 0; v < ret_var.datalen; v++) {
10731                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_47_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
10732                 *ret_conv_47_ref = ret_var.data[v];
10733                 ret_arr_ptr[v] = (long)ret_conv_47_ref;
10734         }
10735         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10736         FREE(ret_var.data);
10737         return ret_arr;
10738 }
10739
10740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
10741         LDKChannelMonitor this_arg_conv;
10742         this_arg_conv.inner = (void*)(this_arg & (~1));
10743         this_arg_conv.is_owned = false;
10744         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
10745         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
10746 }
10747
10748 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10749         LDKChannelMonitor this_arg_conv;
10750         this_arg_conv.inner = (void*)(this_arg & (~1));
10751         this_arg_conv.is_owned = false;
10752         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
10753         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10754         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10755         for (size_t o = 0; o < ret_var.datalen; o++) {
10756                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
10757                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
10758                 long ret_conv_14_ref = (long)ret_conv_14_copy;
10759                 ret_arr_ptr[o] = ret_conv_14_ref;
10760         }
10761         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10762         FREE(ret_var.data);
10763         return ret_arr;
10764 }
10765
10766 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10767         LDKChannelMonitor this_arg_conv;
10768         this_arg_conv.inner = (void*)(this_arg & (~1));
10769         this_arg_conv.is_owned = false;
10770         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
10771         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10772         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10773         for (size_t h = 0; h < ret_var.datalen; h++) {
10774                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
10775                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
10776                 long ret_conv_7_ref = (long)ret_conv_7_copy;
10777                 ret_arr_ptr[h] = ret_conv_7_ref;
10778         }
10779         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10780         FREE(ret_var.data);
10781         return ret_arr;
10782 }
10783
10784 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) {
10785         LDKChannelMonitor this_arg_conv;
10786         this_arg_conv.inner = (void*)(this_arg & (~1));
10787         this_arg_conv.is_owned = false;
10788         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
10789         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
10790         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
10791         ;
10792         for (size_t i = 0; i < ret_var.datalen; i++) {
10793                 LDKTransaction ret_conv_8_var = ret_var.data[i];
10794                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
10795                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
10796                 Transaction_free(ret_conv_8_var);
10797                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
10798         }
10799         FREE(ret_var.data);
10800         return ret_arr;
10801 }
10802
10803 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) {
10804         LDKChannelMonitor this_arg_conv;
10805         this_arg_conv.inner = (void*)(this_arg & (~1));
10806         this_arg_conv.is_owned = false;
10807         unsigned char header_arr[80];
10808         CHECK((*env)->GetArrayLength(env, header) == 80);
10809         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10810         unsigned char (*header_ref)[80] = &header_arr;
10811         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10812         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
10813         if (txdata_constr.datalen > 0)
10814                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10815         else
10816                 txdata_constr.data = NULL;
10817         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
10818         for (size_t y = 0; y < txdata_constr.datalen; y++) {
10819                 int64_t txdata_conv_24 = txdata_vals[y];
10820                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
10821                 FREE((void*)txdata_conv_24);
10822                 txdata_constr.data[y] = txdata_conv_24_conv;
10823         }
10824         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
10825         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10826         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
10827                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10828                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
10829         }
10830         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
10831         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
10832                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10833                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
10834         }
10835         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10836         if (logger_conv.free == LDKLogger_JCalls_free) {
10837                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10838                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10839         }
10840         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);
10841         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10842         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10843         for (size_t u = 0; u < ret_var.datalen; u++) {
10844                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10845                 *ret_conv_46_ref = ret_var.data[u];
10846                 ret_arr_ptr[u] = (long)ret_conv_46_ref;
10847         }
10848         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10849         FREE(ret_var.data);
10850         return ret_arr;
10851 }
10852
10853 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) {
10854         LDKChannelMonitor this_arg_conv;
10855         this_arg_conv.inner = (void*)(this_arg & (~1));
10856         this_arg_conv.is_owned = false;
10857         unsigned char header_arr[80];
10858         CHECK((*env)->GetArrayLength(env, header) == 80);
10859         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10860         unsigned char (*header_ref)[80] = &header_arr;
10861         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10862         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
10863                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10864                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
10865         }
10866         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
10867         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
10868                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10869                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
10870         }
10871         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10872         if (logger_conv.free == LDKLogger_JCalls_free) {
10873                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10874                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10875         }
10876         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
10877 }
10878
10879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10880         if ((this_ptr & 1) != 0) return;
10881         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
10882         FREE((void*)this_ptr);
10883         Persist_free(this_ptr_conv);
10884 }
10885
10886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
10887         LDKu8slice ser_ref;
10888         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10889         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10890         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
10891         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10892         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
10893         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10894         return (long)ret_conv;
10895 }
10896
10897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10898         LDKOutPoint this_obj_conv;
10899         this_obj_conv.inner = (void*)(this_obj & (~1));
10900         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10901         OutPoint_free(this_obj_conv);
10902 }
10903
10904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
10905         LDKOutPoint this_ptr_conv;
10906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10907         this_ptr_conv.is_owned = false;
10908         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10909         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
10910         return ret_arr;
10911 }
10912
10913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10914         LDKOutPoint this_ptr_conv;
10915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10916         this_ptr_conv.is_owned = false;
10917         LDKThirtyTwoBytes val_ref;
10918         CHECK((*env)->GetArrayLength(env, val) == 32);
10919         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
10920         OutPoint_set_txid(&this_ptr_conv, val_ref);
10921 }
10922
10923 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
10924         LDKOutPoint this_ptr_conv;
10925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10926         this_ptr_conv.is_owned = false;
10927         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
10928         return ret_val;
10929 }
10930
10931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
10932         LDKOutPoint this_ptr_conv;
10933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10934         this_ptr_conv.is_owned = false;
10935         OutPoint_set_index(&this_ptr_conv, val);
10936 }
10937
10938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
10939         LDKThirtyTwoBytes txid_arg_ref;
10940         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
10941         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
10942         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
10943         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10944         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10945         long ret_ref = (long)ret_var.inner;
10946         if (ret_var.is_owned) {
10947                 ret_ref |= 1;
10948         }
10949         return ret_ref;
10950 }
10951
10952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10953         LDKOutPoint orig_conv;
10954         orig_conv.inner = (void*)(orig & (~1));
10955         orig_conv.is_owned = false;
10956         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
10957         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10958         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10959         long ret_ref = (long)ret_var.inner;
10960         if (ret_var.is_owned) {
10961                 ret_ref |= 1;
10962         }
10963         return ret_ref;
10964 }
10965
10966 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
10967         LDKOutPoint this_arg_conv;
10968         this_arg_conv.inner = (void*)(this_arg & (~1));
10969         this_arg_conv.is_owned = false;
10970         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10971         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
10972         return ret_arr;
10973 }
10974
10975 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
10976         LDKOutPoint obj_conv;
10977         obj_conv.inner = (void*)(obj & (~1));
10978         obj_conv.is_owned = false;
10979         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
10980         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10981         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10982         CVec_u8Z_free(ret_var);
10983         return ret_arr;
10984 }
10985
10986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10987         LDKu8slice ser_ref;
10988         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10989         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10990         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10991         *ret_conv = OutPoint_read(ser_ref);
10992         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10993         return (long)ret_conv;
10994 }
10995
10996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10997         LDKDelayedPaymentOutputDescriptor this_obj_conv;
10998         this_obj_conv.inner = (void*)(this_obj & (~1));
10999         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11000         DelayedPaymentOutputDescriptor_free(this_obj_conv);
11001 }
11002
11003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
11004         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11006         this_ptr_conv.is_owned = false;
11007         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
11008         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11009         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11010         long ret_ref = (long)ret_var.inner;
11011         if (ret_var.is_owned) {
11012                 ret_ref |= 1;
11013         }
11014         return ret_ref;
11015 }
11016
11017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11018         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11020         this_ptr_conv.is_owned = false;
11021         LDKOutPoint val_conv;
11022         val_conv.inner = (void*)(val & (~1));
11023         val_conv.is_owned = (val & 1) || (val == 0);
11024         val_conv = OutPoint_clone(&val_conv);
11025         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
11026 }
11027
11028 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
11029         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11031         this_ptr_conv.is_owned = false;
11032         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
11033         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
11034         return ret_arr;
11035 }
11036
11037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11038         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11040         this_ptr_conv.is_owned = false;
11041         LDKPublicKey val_ref;
11042         CHECK((*env)->GetArrayLength(env, val) == 33);
11043         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11044         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
11045 }
11046
11047 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
11048         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11050         this_ptr_conv.is_owned = false;
11051         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
11052         return ret_val;
11053 }
11054
11055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
11056         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11058         this_ptr_conv.is_owned = false;
11059         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
11060 }
11061
11062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11063         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11065         this_ptr_conv.is_owned = false;
11066         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
11067         FREE((void*)val);
11068         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
11069 }
11070
11071 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
11072         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11074         this_ptr_conv.is_owned = false;
11075         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
11076         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
11077         return ret_arr;
11078 }
11079
11080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11081         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11083         this_ptr_conv.is_owned = false;
11084         LDKPublicKey val_ref;
11085         CHECK((*env)->GetArrayLength(env, val) == 33);
11086         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11087         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
11088 }
11089
11090 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11091         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11093         this_ptr_conv.is_owned = false;
11094         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11095         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
11096         return ret_arr;
11097 }
11098
11099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11100         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11102         this_ptr_conv.is_owned = false;
11103         LDKThirtyTwoBytes val_ref;
11104         CHECK((*env)->GetArrayLength(env, val) == 32);
11105         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11106         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
11107 }
11108
11109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
11110         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11112         this_ptr_conv.is_owned = false;
11113         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
11114         return ret_val;
11115 }
11116
11117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11118         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11120         this_ptr_conv.is_owned = false;
11121         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
11122 }
11123
11124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1new(JNIEnv *env, jclass clz, int64_t outpoint_arg, int8_tArray per_commitment_point_arg, int16_t to_self_delay_arg, int64_t output_arg, int8_tArray revocation_pubkey_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
11125         LDKOutPoint outpoint_arg_conv;
11126         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
11127         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
11128         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
11129         LDKPublicKey per_commitment_point_arg_ref;
11130         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
11131         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
11132         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
11133         FREE((void*)output_arg);
11134         LDKPublicKey revocation_pubkey_arg_ref;
11135         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
11136         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
11137         LDKThirtyTwoBytes channel_keys_id_arg_ref;
11138         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
11139         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
11140         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_new(outpoint_arg_conv, per_commitment_point_arg_ref, to_self_delay_arg, output_arg_conv, revocation_pubkey_arg_ref, channel_keys_id_arg_ref, channel_value_satoshis_arg);
11141         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11142         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11143         long ret_ref = (long)ret_var.inner;
11144         if (ret_var.is_owned) {
11145                 ret_ref |= 1;
11146         }
11147         return ret_ref;
11148 }
11149
11150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11151         LDKDelayedPaymentOutputDescriptor orig_conv;
11152         orig_conv.inner = (void*)(orig & (~1));
11153         orig_conv.is_owned = false;
11154         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
11155         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11156         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11157         long ret_ref = (long)ret_var.inner;
11158         if (ret_var.is_owned) {
11159                 ret_ref |= 1;
11160         }
11161         return ret_ref;
11162 }
11163
11164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11165         LDKStaticPaymentOutputDescriptor this_obj_conv;
11166         this_obj_conv.inner = (void*)(this_obj & (~1));
11167         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11168         StaticPaymentOutputDescriptor_free(this_obj_conv);
11169 }
11170
11171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
11172         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11174         this_ptr_conv.is_owned = false;
11175         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
11176         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11177         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11178         long ret_ref = (long)ret_var.inner;
11179         if (ret_var.is_owned) {
11180                 ret_ref |= 1;
11181         }
11182         return ret_ref;
11183 }
11184
11185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11186         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11188         this_ptr_conv.is_owned = false;
11189         LDKOutPoint val_conv;
11190         val_conv.inner = (void*)(val & (~1));
11191         val_conv.is_owned = (val & 1) || (val == 0);
11192         val_conv = OutPoint_clone(&val_conv);
11193         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
11194 }
11195
11196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11197         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11199         this_ptr_conv.is_owned = false;
11200         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
11201         FREE((void*)val);
11202         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
11203 }
11204
11205 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11206         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11208         this_ptr_conv.is_owned = false;
11209         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11210         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
11211         return ret_arr;
11212 }
11213
11214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11215         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11217         this_ptr_conv.is_owned = false;
11218         LDKThirtyTwoBytes val_ref;
11219         CHECK((*env)->GetArrayLength(env, val) == 32);
11220         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11221         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
11222 }
11223
11224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
11225         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11227         this_ptr_conv.is_owned = false;
11228         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
11229         return ret_val;
11230 }
11231
11232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11233         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11235         this_ptr_conv.is_owned = false;
11236         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
11237 }
11238
11239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1new(JNIEnv *env, jclass clz, int64_t outpoint_arg, int64_t output_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
11240         LDKOutPoint outpoint_arg_conv;
11241         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
11242         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
11243         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
11244         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
11245         FREE((void*)output_arg);
11246         LDKThirtyTwoBytes channel_keys_id_arg_ref;
11247         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
11248         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
11249         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
11250         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11251         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11252         long ret_ref = (long)ret_var.inner;
11253         if (ret_var.is_owned) {
11254                 ret_ref |= 1;
11255         }
11256         return ret_ref;
11257 }
11258
11259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11260         LDKStaticPaymentOutputDescriptor orig_conv;
11261         orig_conv.inner = (void*)(orig & (~1));
11262         orig_conv.is_owned = false;
11263         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
11264         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11265         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11266         long ret_ref = (long)ret_var.inner;
11267         if (ret_var.is_owned) {
11268                 ret_ref |= 1;
11269         }
11270         return ret_ref;
11271 }
11272
11273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11274         if ((this_ptr & 1) != 0) return;
11275         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
11276         FREE((void*)this_ptr);
11277         SpendableOutputDescriptor_free(this_ptr_conv);
11278 }
11279
11280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11281         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
11282         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
11283         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
11284         long ret_ref = (long)ret_copy;
11285         return ret_ref;
11286 }
11287
11288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
11289         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
11290         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
11291         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11292         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11293         CVec_u8Z_free(ret_var);
11294         return ret_arr;
11295 }
11296
11297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
11298         LDKu8slice ser_ref;
11299         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11300         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11301         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
11302         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
11303         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11304         return (long)ret_conv;
11305 }
11306
11307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11308         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
11309         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
11310         *ret = Sign_clone(orig_conv);
11311         return (long)ret;
11312 }
11313
11314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11315         if ((this_ptr & 1) != 0) return;
11316         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
11317         FREE((void*)this_ptr);
11318         Sign_free(this_ptr_conv);
11319 }
11320
11321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11322         if ((this_ptr & 1) != 0) return;
11323         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
11324         FREE((void*)this_ptr);
11325         KeysInterface_free(this_ptr_conv);
11326 }
11327
11328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11329         LDKInMemorySigner this_obj_conv;
11330         this_obj_conv.inner = (void*)(this_obj & (~1));
11331         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11332         InMemorySigner_free(this_obj_conv);
11333 }
11334
11335 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
11336         LDKInMemorySigner this_ptr_conv;
11337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11338         this_ptr_conv.is_owned = false;
11339         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11340         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
11341         return ret_arr;
11342 }
11343
11344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11345         LDKInMemorySigner this_ptr_conv;
11346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11347         this_ptr_conv.is_owned = false;
11348         LDKSecretKey val_ref;
11349         CHECK((*env)->GetArrayLength(env, val) == 32);
11350         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
11351         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
11352 }
11353
11354 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
11355         LDKInMemorySigner this_ptr_conv;
11356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11357         this_ptr_conv.is_owned = false;
11358         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11359         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
11360         return ret_arr;
11361 }
11362
11363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11364         LDKInMemorySigner this_ptr_conv;
11365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11366         this_ptr_conv.is_owned = false;
11367         LDKSecretKey val_ref;
11368         CHECK((*env)->GetArrayLength(env, val) == 32);
11369         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
11370         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
11371 }
11372
11373 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
11374         LDKInMemorySigner this_ptr_conv;
11375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11376         this_ptr_conv.is_owned = false;
11377         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11378         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
11379         return ret_arr;
11380 }
11381
11382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11383         LDKInMemorySigner this_ptr_conv;
11384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11385         this_ptr_conv.is_owned = false;
11386         LDKSecretKey val_ref;
11387         CHECK((*env)->GetArrayLength(env, val) == 32);
11388         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
11389         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
11390 }
11391
11392 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
11393         LDKInMemorySigner this_ptr_conv;
11394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11395         this_ptr_conv.is_owned = false;
11396         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11397         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
11398         return ret_arr;
11399 }
11400
11401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11402         LDKInMemorySigner this_ptr_conv;
11403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11404         this_ptr_conv.is_owned = false;
11405         LDKSecretKey val_ref;
11406         CHECK((*env)->GetArrayLength(env, val) == 32);
11407         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
11408         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
11409 }
11410
11411 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
11412         LDKInMemorySigner this_ptr_conv;
11413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11414         this_ptr_conv.is_owned = false;
11415         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11416         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
11417         return ret_arr;
11418 }
11419
11420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11421         LDKInMemorySigner this_ptr_conv;
11422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11423         this_ptr_conv.is_owned = false;
11424         LDKSecretKey val_ref;
11425         CHECK((*env)->GetArrayLength(env, val) == 32);
11426         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
11427         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
11428 }
11429
11430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
11431         LDKInMemorySigner this_ptr_conv;
11432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11433         this_ptr_conv.is_owned = false;
11434         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11435         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
11436         return ret_arr;
11437 }
11438
11439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11440         LDKInMemorySigner this_ptr_conv;
11441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11442         this_ptr_conv.is_owned = false;
11443         LDKThirtyTwoBytes val_ref;
11444         CHECK((*env)->GetArrayLength(env, val) == 32);
11445         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11446         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
11447 }
11448
11449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11450         LDKInMemorySigner orig_conv;
11451         orig_conv.inner = (void*)(orig & (~1));
11452         orig_conv.is_owned = false;
11453         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
11454         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11455         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11456         long ret_ref = (long)ret_var.inner;
11457         if (ret_var.is_owned) {
11458                 ret_ref |= 1;
11459         }
11460         return ret_ref;
11461 }
11462
11463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1new(JNIEnv *env, jclass clz, int8_tArray funding_key, int8_tArray revocation_base_key, int8_tArray payment_key, int8_tArray delayed_payment_base_key, int8_tArray htlc_base_key, int8_tArray commitment_seed, int64_t channel_value_satoshis, int8_tArray channel_keys_id) {
11464         LDKSecretKey funding_key_ref;
11465         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
11466         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
11467         LDKSecretKey revocation_base_key_ref;
11468         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
11469         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
11470         LDKSecretKey payment_key_ref;
11471         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
11472         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
11473         LDKSecretKey delayed_payment_base_key_ref;
11474         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
11475         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
11476         LDKSecretKey htlc_base_key_ref;
11477         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
11478         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
11479         LDKThirtyTwoBytes commitment_seed_ref;
11480         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
11481         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
11482         LDKThirtyTwoBytes channel_keys_id_ref;
11483         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
11484         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
11485         LDKInMemorySigner ret_var = InMemorySigner_new(funding_key_ref, revocation_base_key_ref, payment_key_ref, delayed_payment_base_key_ref, htlc_base_key_ref, commitment_seed_ref, channel_value_satoshis, channel_keys_id_ref);
11486         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11487         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11488         long ret_ref = (long)ret_var.inner;
11489         if (ret_var.is_owned) {
11490                 ret_ref |= 1;
11491         }
11492         return ret_ref;
11493 }
11494
11495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
11496         LDKInMemorySigner this_arg_conv;
11497         this_arg_conv.inner = (void*)(this_arg & (~1));
11498         this_arg_conv.is_owned = false;
11499         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
11500         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11501         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11502         long ret_ref = (long)ret_var.inner;
11503         if (ret_var.is_owned) {
11504                 ret_ref |= 1;
11505         }
11506         return ret_ref;
11507 }
11508
11509 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
11510         LDKInMemorySigner this_arg_conv;
11511         this_arg_conv.inner = (void*)(this_arg & (~1));
11512         this_arg_conv.is_owned = false;
11513         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
11514         return ret_val;
11515 }
11516
11517 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
11518         LDKInMemorySigner this_arg_conv;
11519         this_arg_conv.inner = (void*)(this_arg & (~1));
11520         this_arg_conv.is_owned = false;
11521         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
11522         return ret_val;
11523 }
11524
11525 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
11526         LDKInMemorySigner this_arg_conv;
11527         this_arg_conv.inner = (void*)(this_arg & (~1));
11528         this_arg_conv.is_owned = false;
11529         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
11530         return ret_val;
11531 }
11532
11533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
11534         LDKInMemorySigner this_arg_conv;
11535         this_arg_conv.inner = (void*)(this_arg & (~1));
11536         this_arg_conv.is_owned = false;
11537         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
11538         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11539         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11540         long ret_ref = (long)ret_var.inner;
11541         if (ret_var.is_owned) {
11542                 ret_ref |= 1;
11543         }
11544         return ret_ref;
11545 }
11546
11547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
11548         LDKInMemorySigner this_arg_conv;
11549         this_arg_conv.inner = (void*)(this_arg & (~1));
11550         this_arg_conv.is_owned = false;
11551         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
11552         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11553         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11554         long ret_ref = (long)ret_var.inner;
11555         if (ret_var.is_owned) {
11556                 ret_ref |= 1;
11557         }
11558         return ret_ref;
11559 }
11560
11561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1sign_1counterparty_1payment_1input(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray spend_tx, int64_t input_idx, int64_t descriptor) {
11562         LDKInMemorySigner this_arg_conv;
11563         this_arg_conv.inner = (void*)(this_arg & (~1));
11564         this_arg_conv.is_owned = false;
11565         LDKTransaction spend_tx_ref;
11566         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
11567         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
11568         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
11569         spend_tx_ref.data_is_owned = true;
11570         LDKStaticPaymentOutputDescriptor descriptor_conv;
11571         descriptor_conv.inner = (void*)(descriptor & (~1));
11572         descriptor_conv.is_owned = false;
11573         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
11574         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
11575         return (long)ret_conv;
11576 }
11577
11578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1sign_1dynamic_1p2wsh_1input(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray spend_tx, int64_t input_idx, int64_t descriptor) {
11579         LDKInMemorySigner this_arg_conv;
11580         this_arg_conv.inner = (void*)(this_arg & (~1));
11581         this_arg_conv.is_owned = false;
11582         LDKTransaction spend_tx_ref;
11583         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
11584         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
11585         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
11586         spend_tx_ref.data_is_owned = true;
11587         LDKDelayedPaymentOutputDescriptor descriptor_conv;
11588         descriptor_conv.inner = (void*)(descriptor & (~1));
11589         descriptor_conv.is_owned = false;
11590         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
11591         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
11592         return (long)ret_conv;
11593 }
11594
11595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
11596         LDKInMemorySigner this_arg_conv;
11597         this_arg_conv.inner = (void*)(this_arg & (~1));
11598         this_arg_conv.is_owned = false;
11599         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
11600         *ret = InMemorySigner_as_Sign(&this_arg_conv);
11601         return (long)ret;
11602 }
11603
11604 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
11605         LDKInMemorySigner obj_conv;
11606         obj_conv.inner = (void*)(obj & (~1));
11607         obj_conv.is_owned = false;
11608         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
11609         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11610         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11611         CVec_u8Z_free(ret_var);
11612         return ret_arr;
11613 }
11614
11615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
11616         LDKu8slice ser_ref;
11617         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11618         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11619         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
11620         *ret_conv = InMemorySigner_read(ser_ref);
11621         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11622         return (long)ret_conv;
11623 }
11624
11625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11626         LDKKeysManager this_obj_conv;
11627         this_obj_conv.inner = (void*)(this_obj & (~1));
11628         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11629         KeysManager_free(this_obj_conv);
11630 }
11631
11632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1new(JNIEnv *env, jclass clz, int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
11633         unsigned char seed_arr[32];
11634         CHECK((*env)->GetArrayLength(env, seed) == 32);
11635         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
11636         unsigned char (*seed_ref)[32] = &seed_arr;
11637         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
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 int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1derive_1channel_1keys(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
11648         LDKKeysManager this_arg_conv;
11649         this_arg_conv.inner = (void*)(this_arg & (~1));
11650         this_arg_conv.is_owned = false;
11651         unsigned char params_arr[32];
11652         CHECK((*env)->GetArrayLength(env, params) == 32);
11653         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
11654         unsigned char (*params_ref)[32] = &params_arr;
11655         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
11656         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11657         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11658         long ret_ref = (long)ret_var.inner;
11659         if (ret_var.is_owned) {
11660                 ret_ref |= 1;
11661         }
11662         return ret_ref;
11663 }
11664
11665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1spend_1spendable_1outputs(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray descriptors, int64_tArray outputs, int8_tArray change_destination_script, int32_t feerate_sat_per_1000_weight) {
11666         LDKKeysManager this_arg_conv;
11667         this_arg_conv.inner = (void*)(this_arg & (~1));
11668         this_arg_conv.is_owned = false;
11669         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
11670         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
11671         if (descriptors_constr.datalen > 0)
11672                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
11673         else
11674                 descriptors_constr.data = NULL;
11675         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
11676         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
11677                 int64_t descriptors_conv_27 = descriptors_vals[b];
11678                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
11679                 FREE((void*)descriptors_conv_27);
11680                 descriptors_constr.data[b] = descriptors_conv_27_conv;
11681         }
11682         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
11683         LDKCVec_TxOutZ outputs_constr;
11684         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
11685         if (outputs_constr.datalen > 0)
11686                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
11687         else
11688                 outputs_constr.data = NULL;
11689         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
11690         for (size_t h = 0; h < outputs_constr.datalen; h++) {
11691                 int64_t outputs_conv_7 = outputs_vals[h];
11692                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
11693                 FREE((void*)outputs_conv_7);
11694                 outputs_constr.data[h] = outputs_conv_7_conv;
11695         }
11696         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
11697         LDKCVec_u8Z change_destination_script_ref;
11698         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
11699         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
11700         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
11701         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
11702         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
11703         return (long)ret_conv;
11704 }
11705
11706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
11707         LDKKeysManager this_arg_conv;
11708         this_arg_conv.inner = (void*)(this_arg & (~1));
11709         this_arg_conv.is_owned = false;
11710         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
11711         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
11712         return (long)ret;
11713 }
11714
11715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11716         LDKChannelManager this_obj_conv;
11717         this_obj_conv.inner = (void*)(this_obj & (~1));
11718         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11719         ChannelManager_free(this_obj_conv);
11720 }
11721
11722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11723         LDKChainParameters this_obj_conv;
11724         this_obj_conv.inner = (void*)(this_obj & (~1));
11725         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11726         ChainParameters_free(this_obj_conv);
11727 }
11728
11729 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
11730         LDKChainParameters this_ptr_conv;
11731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11732         this_ptr_conv.is_owned = false;
11733         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
11734         return ret_conv;
11735 }
11736
11737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
11738         LDKChainParameters this_ptr_conv;
11739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11740         this_ptr_conv.is_owned = false;
11741         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
11742         ChainParameters_set_network(&this_ptr_conv, val_conv);
11743 }
11744
11745 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1latest_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
11746         LDKChainParameters this_ptr_conv;
11747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11748         this_ptr_conv.is_owned = false;
11749         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11750         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChainParameters_get_latest_hash(&this_ptr_conv));
11751         return ret_arr;
11752 }
11753
11754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1latest_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11755         LDKChainParameters this_ptr_conv;
11756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11757         this_ptr_conv.is_owned = false;
11758         LDKThirtyTwoBytes val_ref;
11759         CHECK((*env)->GetArrayLength(env, val) == 32);
11760         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11761         ChainParameters_set_latest_hash(&this_ptr_conv, val_ref);
11762 }
11763
11764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1latest_1height(JNIEnv *env, jclass clz, int64_t this_ptr) {
11765         LDKChainParameters this_ptr_conv;
11766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11767         this_ptr_conv.is_owned = false;
11768         int64_t ret_val = ChainParameters_get_latest_height(&this_ptr_conv);
11769         return ret_val;
11770 }
11771
11772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1latest_1height(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11773         LDKChainParameters this_ptr_conv;
11774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11775         this_ptr_conv.is_owned = false;
11776         ChainParameters_set_latest_height(&this_ptr_conv, val);
11777 }
11778
11779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int8_tArray latest_hash_arg, int64_t latest_height_arg) {
11780         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
11781         LDKThirtyTwoBytes latest_hash_arg_ref;
11782         CHECK((*env)->GetArrayLength(env, latest_hash_arg) == 32);
11783         (*env)->GetByteArrayRegion(env, latest_hash_arg, 0, 32, latest_hash_arg_ref.data);
11784         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, latest_hash_arg_ref, latest_height_arg);
11785         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11786         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11787         long ret_ref = (long)ret_var.inner;
11788         if (ret_var.is_owned) {
11789                 ret_ref |= 1;
11790         }
11791         return ret_ref;
11792 }
11793
11794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11795         LDKChannelDetails this_obj_conv;
11796         this_obj_conv.inner = (void*)(this_obj & (~1));
11797         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11798         ChannelDetails_free(this_obj_conv);
11799 }
11800
11801 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11802         LDKChannelDetails this_ptr_conv;
11803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11804         this_ptr_conv.is_owned = false;
11805         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11806         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
11807         return ret_arr;
11808 }
11809
11810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11811         LDKChannelDetails this_ptr_conv;
11812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11813         this_ptr_conv.is_owned = false;
11814         LDKThirtyTwoBytes val_ref;
11815         CHECK((*env)->GetArrayLength(env, val) == 32);
11816         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11817         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
11818 }
11819
11820 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11821         LDKChannelDetails this_ptr_conv;
11822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11823         this_ptr_conv.is_owned = false;
11824         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
11825         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form);
11826         return ret_arr;
11827 }
11828
11829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11830         LDKChannelDetails this_ptr_conv;
11831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11832         this_ptr_conv.is_owned = false;
11833         LDKPublicKey val_ref;
11834         CHECK((*env)->GetArrayLength(env, val) == 33);
11835         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11836         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
11837 }
11838
11839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
11840         LDKChannelDetails this_ptr_conv;
11841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11842         this_ptr_conv.is_owned = false;
11843         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
11844         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11845         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11846         long ret_ref = (long)ret_var.inner;
11847         if (ret_var.is_owned) {
11848                 ret_ref |= 1;
11849         }
11850         return ret_ref;
11851 }
11852
11853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11854         LDKChannelDetails this_ptr_conv;
11855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11856         this_ptr_conv.is_owned = false;
11857         LDKInitFeatures val_conv;
11858         val_conv.inner = (void*)(val & (~1));
11859         val_conv.is_owned = (val & 1) || (val == 0);
11860         val_conv = InitFeatures_clone(&val_conv);
11861         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
11862 }
11863
11864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
11865         LDKChannelDetails this_ptr_conv;
11866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11867         this_ptr_conv.is_owned = false;
11868         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
11869         return ret_val;
11870 }
11871
11872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11873         LDKChannelDetails this_ptr_conv;
11874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11875         this_ptr_conv.is_owned = false;
11876         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
11877 }
11878
11879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11880         LDKChannelDetails this_ptr_conv;
11881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11882         this_ptr_conv.is_owned = false;
11883         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
11884         return ret_val;
11885 }
11886
11887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11888         LDKChannelDetails this_ptr_conv;
11889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11890         this_ptr_conv.is_owned = false;
11891         ChannelDetails_set_user_id(&this_ptr_conv, val);
11892 }
11893
11894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
11895         LDKChannelDetails this_ptr_conv;
11896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11897         this_ptr_conv.is_owned = false;
11898         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
11899         return ret_val;
11900 }
11901
11902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11903         LDKChannelDetails this_ptr_conv;
11904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11905         this_ptr_conv.is_owned = false;
11906         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
11907 }
11908
11909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
11910         LDKChannelDetails this_ptr_conv;
11911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11912         this_ptr_conv.is_owned = false;
11913         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
11914         return ret_val;
11915 }
11916
11917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11918         LDKChannelDetails this_ptr_conv;
11919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11920         this_ptr_conv.is_owned = false;
11921         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
11922 }
11923
11924 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1live(JNIEnv *env, jclass clz, int64_t this_ptr) {
11925         LDKChannelDetails this_ptr_conv;
11926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11927         this_ptr_conv.is_owned = false;
11928         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
11929         return ret_val;
11930 }
11931
11932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1live(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
11933         LDKChannelDetails this_ptr_conv;
11934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11935         this_ptr_conv.is_owned = false;
11936         ChannelDetails_set_is_live(&this_ptr_conv, val);
11937 }
11938
11939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11940         LDKChannelDetails orig_conv;
11941         orig_conv.inner = (void*)(orig & (~1));
11942         orig_conv.is_owned = false;
11943         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
11944         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11945         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11946         long ret_ref = (long)ret_var.inner;
11947         if (ret_var.is_owned) {
11948                 ret_ref |= 1;
11949         }
11950         return ret_ref;
11951 }
11952
11953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11954         if ((this_ptr & 1) != 0) return;
11955         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
11956         FREE((void*)this_ptr);
11957         PaymentSendFailure_free(this_ptr_conv);
11958 }
11959
11960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11961         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
11962         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
11963         *ret_copy = PaymentSendFailure_clone(orig_conv);
11964         long ret_ref = (long)ret_copy;
11965         return ret_ref;
11966 }
11967
11968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1new(JNIEnv *env, jclass clz, int64_t fee_est, int64_t chain_monitor, int64_t tx_broadcaster, int64_t logger, int64_t keys_manager, int64_t config, int64_t params) {
11969         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
11970         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
11971                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11972                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
11973         }
11974         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
11975         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
11976                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11977                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
11978         }
11979         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
11980         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11981                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11982                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
11983         }
11984         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11985         if (logger_conv.free == LDKLogger_JCalls_free) {
11986                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11987                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11988         }
11989         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
11990         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
11991                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11992                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
11993         }
11994         LDKUserConfig config_conv;
11995         config_conv.inner = (void*)(config & (~1));
11996         config_conv.is_owned = (config & 1) || (config == 0);
11997         config_conv = UserConfig_clone(&config_conv);
11998         LDKChainParameters params_conv;
11999         params_conv.inner = (void*)(params & (~1));
12000         params_conv.is_owned = (params & 1) || (params == 0);
12001         // Warning: we need a move here but no clone is available for LDKChainParameters
12002         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
12003         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12004         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12005         long ret_ref = (long)ret_var.inner;
12006         if (ret_var.is_owned) {
12007                 ret_ref |= 1;
12008         }
12009         return ret_ref;
12010 }
12011
12012 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) {
12013         LDKChannelManager this_arg_conv;
12014         this_arg_conv.inner = (void*)(this_arg & (~1));
12015         this_arg_conv.is_owned = false;
12016         LDKPublicKey their_network_key_ref;
12017         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
12018         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
12019         LDKUserConfig override_config_conv;
12020         override_config_conv.inner = (void*)(override_config & (~1));
12021         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
12022         override_config_conv = UserConfig_clone(&override_config_conv);
12023         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
12024         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
12025         return (long)ret_conv;
12026 }
12027
12028 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
12029         LDKChannelManager this_arg_conv;
12030         this_arg_conv.inner = (void*)(this_arg & (~1));
12031         this_arg_conv.is_owned = false;
12032         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
12033         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12034         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12035         for (size_t q = 0; q < ret_var.datalen; q++) {
12036                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
12037                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12038                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12039                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
12040                 if (ret_conv_16_var.is_owned) {
12041                         ret_conv_16_ref |= 1;
12042                 }
12043                 ret_arr_ptr[q] = ret_conv_16_ref;
12044         }
12045         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12046         FREE(ret_var.data);
12047         return ret_arr;
12048 }
12049
12050 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
12051         LDKChannelManager this_arg_conv;
12052         this_arg_conv.inner = (void*)(this_arg & (~1));
12053         this_arg_conv.is_owned = false;
12054         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
12055         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12056         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12057         for (size_t q = 0; q < ret_var.datalen; q++) {
12058                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
12059                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12060                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12061                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
12062                 if (ret_conv_16_var.is_owned) {
12063                         ret_conv_16_ref |= 1;
12064                 }
12065                 ret_arr_ptr[q] = ret_conv_16_ref;
12066         }
12067         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12068         FREE(ret_var.data);
12069         return ret_arr;
12070 }
12071
12072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
12073         LDKChannelManager this_arg_conv;
12074         this_arg_conv.inner = (void*)(this_arg & (~1));
12075         this_arg_conv.is_owned = false;
12076         unsigned char channel_id_arr[32];
12077         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
12078         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
12079         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
12080         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
12081         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
12082         return (long)ret_conv;
12083 }
12084
12085 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) {
12086         LDKChannelManager this_arg_conv;
12087         this_arg_conv.inner = (void*)(this_arg & (~1));
12088         this_arg_conv.is_owned = false;
12089         unsigned char channel_id_arr[32];
12090         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
12091         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
12092         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
12093         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
12094         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
12095         return (long)ret_conv;
12096 }
12097
12098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
12099         LDKChannelManager this_arg_conv;
12100         this_arg_conv.inner = (void*)(this_arg & (~1));
12101         this_arg_conv.is_owned = false;
12102         ChannelManager_force_close_all_channels(&this_arg_conv);
12103 }
12104
12105 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) {
12106         LDKChannelManager this_arg_conv;
12107         this_arg_conv.inner = (void*)(this_arg & (~1));
12108         this_arg_conv.is_owned = false;
12109         LDKRoute route_conv;
12110         route_conv.inner = (void*)(route & (~1));
12111         route_conv.is_owned = false;
12112         LDKThirtyTwoBytes payment_hash_ref;
12113         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
12114         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
12115         LDKThirtyTwoBytes payment_secret_ref;
12116         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
12117         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
12118         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
12119         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
12120         return (long)ret_conv;
12121 }
12122
12123 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) {
12124         LDKChannelManager this_arg_conv;
12125         this_arg_conv.inner = (void*)(this_arg & (~1));
12126         this_arg_conv.is_owned = false;
12127         unsigned char temporary_channel_id_arr[32];
12128         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
12129         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
12130         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
12131         LDKOutPoint funding_txo_conv;
12132         funding_txo_conv.inner = (void*)(funding_txo & (~1));
12133         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
12134         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
12135         ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
12136 }
12137
12138 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) {
12139         LDKChannelManager this_arg_conv;
12140         this_arg_conv.inner = (void*)(this_arg & (~1));
12141         this_arg_conv.is_owned = false;
12142         LDKThreeBytes rgb_ref;
12143         CHECK((*env)->GetArrayLength(env, rgb) == 3);
12144         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
12145         LDKThirtyTwoBytes alias_ref;
12146         CHECK((*env)->GetArrayLength(env, alias) == 32);
12147         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
12148         LDKCVec_NetAddressZ addresses_constr;
12149         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
12150         if (addresses_constr.datalen > 0)
12151                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12152         else
12153                 addresses_constr.data = NULL;
12154         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
12155         for (size_t m = 0; m < addresses_constr.datalen; m++) {
12156                 int64_t addresses_conv_12 = addresses_vals[m];
12157                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
12158                 FREE((void*)addresses_conv_12);
12159                 addresses_constr.data[m] = addresses_conv_12_conv;
12160         }
12161         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
12162         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
12163 }
12164
12165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
12166         LDKChannelManager this_arg_conv;
12167         this_arg_conv.inner = (void*)(this_arg & (~1));
12168         this_arg_conv.is_owned = false;
12169         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
12170 }
12171
12172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1chan_1freshness_1every_1min(JNIEnv *env, jclass clz, int64_t this_arg) {
12173         LDKChannelManager this_arg_conv;
12174         this_arg_conv.inner = (void*)(this_arg & (~1));
12175         this_arg_conv.is_owned = false;
12176         ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
12177 }
12178
12179 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) {
12180         LDKChannelManager this_arg_conv;
12181         this_arg_conv.inner = (void*)(this_arg & (~1));
12182         this_arg_conv.is_owned = false;
12183         unsigned char payment_hash_arr[32];
12184         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
12185         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
12186         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
12187         LDKThirtyTwoBytes payment_secret_ref;
12188         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
12189         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
12190         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
12191         return ret_val;
12192 }
12193
12194 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) {
12195         LDKChannelManager this_arg_conv;
12196         this_arg_conv.inner = (void*)(this_arg & (~1));
12197         this_arg_conv.is_owned = false;
12198         LDKThirtyTwoBytes payment_preimage_ref;
12199         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
12200         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
12201         LDKThirtyTwoBytes payment_secret_ref;
12202         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
12203         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
12204         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
12205         return ret_val;
12206 }
12207
12208 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
12209         LDKChannelManager this_arg_conv;
12210         this_arg_conv.inner = (void*)(this_arg & (~1));
12211         this_arg_conv.is_owned = false;
12212         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
12213         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
12214         return ret_arr;
12215 }
12216
12217 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) {
12218         LDKChannelManager this_arg_conv;
12219         this_arg_conv.inner = (void*)(this_arg & (~1));
12220         this_arg_conv.is_owned = false;
12221         LDKOutPoint funding_txo_conv;
12222         funding_txo_conv.inner = (void*)(funding_txo & (~1));
12223         funding_txo_conv.is_owned = false;
12224         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
12225 }
12226
12227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
12228         LDKChannelManager this_arg_conv;
12229         this_arg_conv.inner = (void*)(this_arg & (~1));
12230         this_arg_conv.is_owned = false;
12231         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
12232         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
12233         return (long)ret;
12234 }
12235
12236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
12237         LDKChannelManager this_arg_conv;
12238         this_arg_conv.inner = (void*)(this_arg & (~1));
12239         this_arg_conv.is_owned = false;
12240         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
12241         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
12242         return (long)ret;
12243 }
12244
12245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
12246         LDKChannelManager this_arg_conv;
12247         this_arg_conv.inner = (void*)(this_arg & (~1));
12248         this_arg_conv.is_owned = false;
12249         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
12250         *ret = ChannelManager_as_Listen(&this_arg_conv);
12251         return (long)ret;
12252 }
12253
12254 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) {
12255         LDKChannelManager this_arg_conv;
12256         this_arg_conv.inner = (void*)(this_arg & (~1));
12257         this_arg_conv.is_owned = false;
12258         unsigned char header_arr[80];
12259         CHECK((*env)->GetArrayLength(env, header) == 80);
12260         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12261         unsigned char (*header_ref)[80] = &header_arr;
12262         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12263         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
12264         if (txdata_constr.datalen > 0)
12265                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12266         else
12267                 txdata_constr.data = NULL;
12268         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
12269         for (size_t y = 0; y < txdata_constr.datalen; y++) {
12270                 int64_t txdata_conv_24 = txdata_vals[y];
12271                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
12272                 FREE((void*)txdata_conv_24);
12273                 txdata_constr.data[y] = txdata_conv_24_conv;
12274         }
12275         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
12276         ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
12277 }
12278
12279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header) {
12280         LDKChannelManager this_arg_conv;
12281         this_arg_conv.inner = (void*)(this_arg & (~1));
12282         this_arg_conv.is_owned = false;
12283         unsigned char header_arr[80];
12284         CHECK((*env)->GetArrayLength(env, header) == 80);
12285         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12286         unsigned char (*header_ref)[80] = &header_arr;
12287         ChannelManager_block_disconnected(&this_arg_conv, header_ref);
12288 }
12289
12290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
12291         LDKChannelManager this_arg_conv;
12292         this_arg_conv.inner = (void*)(this_arg & (~1));
12293         this_arg_conv.is_owned = false;
12294         ChannelManager_await_persistable_update(&this_arg_conv);
12295 }
12296
12297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
12298         LDKChannelManager this_arg_conv;
12299         this_arg_conv.inner = (void*)(this_arg & (~1));
12300         this_arg_conv.is_owned = false;
12301         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
12302         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
12303         return (long)ret;
12304 }
12305
12306 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
12307         LDKChannelManager obj_conv;
12308         obj_conv.inner = (void*)(obj & (~1));
12309         obj_conv.is_owned = false;
12310         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
12311         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
12312         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
12313         CVec_u8Z_free(ret_var);
12314         return ret_arr;
12315 }
12316
12317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12318         LDKChannelManagerReadArgs this_obj_conv;
12319         this_obj_conv.inner = (void*)(this_obj & (~1));
12320         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12321         ChannelManagerReadArgs_free(this_obj_conv);
12322 }
12323
12324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
12325         LDKChannelManagerReadArgs this_ptr_conv;
12326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12327         this_ptr_conv.is_owned = false;
12328         long ret_ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
12329         return ret_ret;
12330 }
12331
12332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12333         LDKChannelManagerReadArgs this_ptr_conv;
12334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12335         this_ptr_conv.is_owned = false;
12336         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
12337         if (val_conv.free == LDKKeysInterface_JCalls_free) {
12338                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12339                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
12340         }
12341         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
12342 }
12343
12344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
12345         LDKChannelManagerReadArgs this_ptr_conv;
12346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12347         this_ptr_conv.is_owned = false;
12348         long ret_ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
12349         return ret_ret;
12350 }
12351
12352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12353         LDKChannelManagerReadArgs this_ptr_conv;
12354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12355         this_ptr_conv.is_owned = false;
12356         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
12357         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
12358                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12359                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
12360         }
12361         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
12362 }
12363
12364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
12365         LDKChannelManagerReadArgs this_ptr_conv;
12366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12367         this_ptr_conv.is_owned = false;
12368         long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
12369         return ret_ret;
12370 }
12371
12372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12373         LDKChannelManagerReadArgs this_ptr_conv;
12374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12375         this_ptr_conv.is_owned = false;
12376         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
12377         if (val_conv.free == LDKWatch_JCalls_free) {
12378                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12379                 LDKWatch_JCalls_clone(val_conv.this_arg);
12380         }
12381         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
12382 }
12383
12384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
12385         LDKChannelManagerReadArgs this_ptr_conv;
12386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12387         this_ptr_conv.is_owned = false;
12388         long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
12389         return ret_ret;
12390 }
12391
12392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12393         LDKChannelManagerReadArgs this_ptr_conv;
12394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12395         this_ptr_conv.is_owned = false;
12396         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
12397         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
12398                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12399                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
12400         }
12401         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
12402 }
12403
12404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
12405         LDKChannelManagerReadArgs this_ptr_conv;
12406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12407         this_ptr_conv.is_owned = false;
12408         long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
12409         return ret_ret;
12410 }
12411
12412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12413         LDKChannelManagerReadArgs this_ptr_conv;
12414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12415         this_ptr_conv.is_owned = false;
12416         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
12417         if (val_conv.free == LDKLogger_JCalls_free) {
12418                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12419                 LDKLogger_JCalls_clone(val_conv.this_arg);
12420         }
12421         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
12422 }
12423
12424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
12425         LDKChannelManagerReadArgs this_ptr_conv;
12426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12427         this_ptr_conv.is_owned = false;
12428         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
12429         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12430         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12431         long ret_ref = (long)ret_var.inner;
12432         if (ret_var.is_owned) {
12433                 ret_ref |= 1;
12434         }
12435         return ret_ref;
12436 }
12437
12438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12439         LDKChannelManagerReadArgs this_ptr_conv;
12440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12441         this_ptr_conv.is_owned = false;
12442         LDKUserConfig val_conv;
12443         val_conv.inner = (void*)(val & (~1));
12444         val_conv.is_owned = (val & 1) || (val == 0);
12445         val_conv = UserConfig_clone(&val_conv);
12446         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
12447 }
12448
12449 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) {
12450         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
12451         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
12452                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12453                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
12454         }
12455         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12456         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
12457                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12458                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
12459         }
12460         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
12461         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
12462                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12463                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
12464         }
12465         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
12466         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
12467                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12468                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
12469         }
12470         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12471         if (logger_conv.free == LDKLogger_JCalls_free) {
12472                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12473                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12474         }
12475         LDKUserConfig default_config_conv;
12476         default_config_conv.inner = (void*)(default_config & (~1));
12477         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
12478         default_config_conv = UserConfig_clone(&default_config_conv);
12479         LDKCVec_ChannelMonitorZ channel_monitors_constr;
12480         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
12481         if (channel_monitors_constr.datalen > 0)
12482                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
12483         else
12484                 channel_monitors_constr.data = NULL;
12485         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
12486         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
12487                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
12488                 LDKChannelMonitor channel_monitors_conv_16_conv;
12489                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
12490                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
12491                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
12492         }
12493         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
12494         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);
12495         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12496         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12497         long ret_ref = (long)ret_var.inner;
12498         if (ret_var.is_owned) {
12499                 ret_ref |= 1;
12500         }
12501         return ret_ref;
12502 }
12503
12504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
12505         LDKu8slice ser_ref;
12506         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
12507         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
12508         LDKChannelManagerReadArgs arg_conv;
12509         arg_conv.inner = (void*)(arg & (~1));
12510         arg_conv.is_owned = (arg & 1) || (arg == 0);
12511         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
12512         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
12513         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
12514         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
12515         return (long)ret_conv;
12516 }
12517
12518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12519         LDKDecodeError this_obj_conv;
12520         this_obj_conv.inner = (void*)(this_obj & (~1));
12521         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12522         DecodeError_free(this_obj_conv);
12523 }
12524
12525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12526         LDKDecodeError orig_conv;
12527         orig_conv.inner = (void*)(orig & (~1));
12528         orig_conv.is_owned = false;
12529         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
12530         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12531         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12532         long ret_ref = (long)ret_var.inner;
12533         if (ret_var.is_owned) {
12534                 ret_ref |= 1;
12535         }
12536         return ret_ref;
12537 }
12538
12539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12540         LDKInit this_obj_conv;
12541         this_obj_conv.inner = (void*)(this_obj & (~1));
12542         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12543         Init_free(this_obj_conv);
12544 }
12545
12546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
12547         LDKInit this_ptr_conv;
12548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12549         this_ptr_conv.is_owned = false;
12550         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
12551         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12552         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12553         long ret_ref = (long)ret_var.inner;
12554         if (ret_var.is_owned) {
12555                 ret_ref |= 1;
12556         }
12557         return ret_ref;
12558 }
12559
12560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12561         LDKInit this_ptr_conv;
12562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12563         this_ptr_conv.is_owned = false;
12564         LDKInitFeatures val_conv;
12565         val_conv.inner = (void*)(val & (~1));
12566         val_conv.is_owned = (val & 1) || (val == 0);
12567         val_conv = InitFeatures_clone(&val_conv);
12568         Init_set_features(&this_ptr_conv, val_conv);
12569 }
12570
12571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
12572         LDKInitFeatures features_arg_conv;
12573         features_arg_conv.inner = (void*)(features_arg & (~1));
12574         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
12575         features_arg_conv = InitFeatures_clone(&features_arg_conv);
12576         LDKInit ret_var = Init_new(features_arg_conv);
12577         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12578         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12579         long ret_ref = (long)ret_var.inner;
12580         if (ret_var.is_owned) {
12581                 ret_ref |= 1;
12582         }
12583         return ret_ref;
12584 }
12585
12586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12587         LDKInit orig_conv;
12588         orig_conv.inner = (void*)(orig & (~1));
12589         orig_conv.is_owned = false;
12590         LDKInit ret_var = Init_clone(&orig_conv);
12591         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12592         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12593         long ret_ref = (long)ret_var.inner;
12594         if (ret_var.is_owned) {
12595                 ret_ref |= 1;
12596         }
12597         return ret_ref;
12598 }
12599
12600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12601         LDKErrorMessage this_obj_conv;
12602         this_obj_conv.inner = (void*)(this_obj & (~1));
12603         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12604         ErrorMessage_free(this_obj_conv);
12605 }
12606
12607 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12608         LDKErrorMessage this_ptr_conv;
12609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12610         this_ptr_conv.is_owned = false;
12611         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12612         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
12613         return ret_arr;
12614 }
12615
12616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12617         LDKErrorMessage this_ptr_conv;
12618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12619         this_ptr_conv.is_owned = false;
12620         LDKThirtyTwoBytes val_ref;
12621         CHECK((*env)->GetArrayLength(env, val) == 32);
12622         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12623         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
12624 }
12625
12626 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
12627         LDKErrorMessage this_ptr_conv;
12628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12629         this_ptr_conv.is_owned = false;
12630         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
12631         jstring _conv = str_ref_to_java(env, _str.chars, _str.len);
12632         return _conv;
12633 }
12634
12635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12636         LDKErrorMessage this_ptr_conv;
12637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12638         this_ptr_conv.is_owned = false;
12639         LDKCVec_u8Z val_ref;
12640         val_ref.datalen = (*env)->GetArrayLength(env, val);
12641         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
12642         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
12643         ErrorMessage_set_data(&this_ptr_conv, val_ref);
12644 }
12645
12646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray data_arg) {
12647         LDKThirtyTwoBytes channel_id_arg_ref;
12648         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
12649         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
12650         LDKCVec_u8Z data_arg_ref;
12651         data_arg_ref.datalen = (*env)->GetArrayLength(env, data_arg);
12652         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
12653         (*env)->GetByteArrayRegion(env, data_arg, 0, data_arg_ref.datalen, data_arg_ref.data);
12654         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
12655         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12656         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12657         long ret_ref = (long)ret_var.inner;
12658         if (ret_var.is_owned) {
12659                 ret_ref |= 1;
12660         }
12661         return ret_ref;
12662 }
12663
12664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12665         LDKErrorMessage orig_conv;
12666         orig_conv.inner = (void*)(orig & (~1));
12667         orig_conv.is_owned = false;
12668         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
12669         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12670         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12671         long ret_ref = (long)ret_var.inner;
12672         if (ret_var.is_owned) {
12673                 ret_ref |= 1;
12674         }
12675         return ret_ref;
12676 }
12677
12678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12679         LDKPing this_obj_conv;
12680         this_obj_conv.inner = (void*)(this_obj & (~1));
12681         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12682         Ping_free(this_obj_conv);
12683 }
12684
12685 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
12686         LDKPing this_ptr_conv;
12687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12688         this_ptr_conv.is_owned = false;
12689         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
12690         return ret_val;
12691 }
12692
12693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
12694         LDKPing this_ptr_conv;
12695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12696         this_ptr_conv.is_owned = false;
12697         Ping_set_ponglen(&this_ptr_conv, val);
12698 }
12699
12700 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
12701         LDKPing this_ptr_conv;
12702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12703         this_ptr_conv.is_owned = false;
12704         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
12705         return ret_val;
12706 }
12707
12708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
12709         LDKPing this_ptr_conv;
12710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12711         this_ptr_conv.is_owned = false;
12712         Ping_set_byteslen(&this_ptr_conv, val);
12713 }
12714
12715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
12716         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
12717         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12718         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12719         long ret_ref = (long)ret_var.inner;
12720         if (ret_var.is_owned) {
12721                 ret_ref |= 1;
12722         }
12723         return ret_ref;
12724 }
12725
12726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12727         LDKPing orig_conv;
12728         orig_conv.inner = (void*)(orig & (~1));
12729         orig_conv.is_owned = false;
12730         LDKPing ret_var = Ping_clone(&orig_conv);
12731         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12732         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12733         long ret_ref = (long)ret_var.inner;
12734         if (ret_var.is_owned) {
12735                 ret_ref |= 1;
12736         }
12737         return ret_ref;
12738 }
12739
12740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12741         LDKPong this_obj_conv;
12742         this_obj_conv.inner = (void*)(this_obj & (~1));
12743         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12744         Pong_free(this_obj_conv);
12745 }
12746
12747 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
12748         LDKPong this_ptr_conv;
12749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12750         this_ptr_conv.is_owned = false;
12751         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
12752         return ret_val;
12753 }
12754
12755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
12756         LDKPong this_ptr_conv;
12757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12758         this_ptr_conv.is_owned = false;
12759         Pong_set_byteslen(&this_ptr_conv, val);
12760 }
12761
12762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
12763         LDKPong ret_var = Pong_new(byteslen_arg);
12764         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12765         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12766         long ret_ref = (long)ret_var.inner;
12767         if (ret_var.is_owned) {
12768                 ret_ref |= 1;
12769         }
12770         return ret_ref;
12771 }
12772
12773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12774         LDKPong orig_conv;
12775         orig_conv.inner = (void*)(orig & (~1));
12776         orig_conv.is_owned = false;
12777         LDKPong ret_var = Pong_clone(&orig_conv);
12778         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12779         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12780         long ret_ref = (long)ret_var.inner;
12781         if (ret_var.is_owned) {
12782                 ret_ref |= 1;
12783         }
12784         return ret_ref;
12785 }
12786
12787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12788         LDKOpenChannel this_obj_conv;
12789         this_obj_conv.inner = (void*)(this_obj & (~1));
12790         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12791         OpenChannel_free(this_obj_conv);
12792 }
12793
12794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
12795         LDKOpenChannel this_ptr_conv;
12796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12797         this_ptr_conv.is_owned = false;
12798         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12799         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
12800         return ret_arr;
12801 }
12802
12803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12804         LDKOpenChannel this_ptr_conv;
12805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12806         this_ptr_conv.is_owned = false;
12807         LDKThirtyTwoBytes val_ref;
12808         CHECK((*env)->GetArrayLength(env, val) == 32);
12809         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12810         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
12811 }
12812
12813 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12814         LDKOpenChannel this_ptr_conv;
12815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12816         this_ptr_conv.is_owned = false;
12817         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12818         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
12819         return ret_arr;
12820 }
12821
12822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12823         LDKOpenChannel this_ptr_conv;
12824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12825         this_ptr_conv.is_owned = false;
12826         LDKThirtyTwoBytes val_ref;
12827         CHECK((*env)->GetArrayLength(env, val) == 32);
12828         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12829         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
12830 }
12831
12832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12833         LDKOpenChannel this_ptr_conv;
12834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12835         this_ptr_conv.is_owned = false;
12836         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
12837         return ret_val;
12838 }
12839
12840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12841         LDKOpenChannel this_ptr_conv;
12842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12843         this_ptr_conv.is_owned = false;
12844         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
12845 }
12846
12847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
12848         LDKOpenChannel this_ptr_conv;
12849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12850         this_ptr_conv.is_owned = false;
12851         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
12852         return ret_val;
12853 }
12854
12855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12856         LDKOpenChannel this_ptr_conv;
12857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12858         this_ptr_conv.is_owned = false;
12859         OpenChannel_set_push_msat(&this_ptr_conv, val);
12860 }
12861
12862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12863         LDKOpenChannel this_ptr_conv;
12864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12865         this_ptr_conv.is_owned = false;
12866         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
12867         return ret_val;
12868 }
12869
12870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12871         LDKOpenChannel this_ptr_conv;
12872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12873         this_ptr_conv.is_owned = false;
12874         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
12875 }
12876
12877 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) {
12878         LDKOpenChannel this_ptr_conv;
12879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12880         this_ptr_conv.is_owned = false;
12881         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
12882         return ret_val;
12883 }
12884
12885 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) {
12886         LDKOpenChannel this_ptr_conv;
12887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12888         this_ptr_conv.is_owned = false;
12889         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
12890 }
12891
12892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12893         LDKOpenChannel this_ptr_conv;
12894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12895         this_ptr_conv.is_owned = false;
12896         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
12897         return ret_val;
12898 }
12899
12900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12901         LDKOpenChannel this_ptr_conv;
12902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12903         this_ptr_conv.is_owned = false;
12904         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
12905 }
12906
12907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
12908         LDKOpenChannel this_ptr_conv;
12909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12910         this_ptr_conv.is_owned = false;
12911         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
12912         return ret_val;
12913 }
12914
12915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12916         LDKOpenChannel this_ptr_conv;
12917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12918         this_ptr_conv.is_owned = false;
12919         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
12920 }
12921
12922 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
12923         LDKOpenChannel this_ptr_conv;
12924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12925         this_ptr_conv.is_owned = false;
12926         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
12927         return ret_val;
12928 }
12929
12930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
12931         LDKOpenChannel this_ptr_conv;
12932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12933         this_ptr_conv.is_owned = false;
12934         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
12935 }
12936
12937 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
12938         LDKOpenChannel this_ptr_conv;
12939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12940         this_ptr_conv.is_owned = false;
12941         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
12942         return ret_val;
12943 }
12944
12945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
12946         LDKOpenChannel this_ptr_conv;
12947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12948         this_ptr_conv.is_owned = false;
12949         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
12950 }
12951
12952 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
12953         LDKOpenChannel this_ptr_conv;
12954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12955         this_ptr_conv.is_owned = false;
12956         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
12957         return ret_val;
12958 }
12959
12960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
12961         LDKOpenChannel this_ptr_conv;
12962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12963         this_ptr_conv.is_owned = false;
12964         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
12965 }
12966
12967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
12968         LDKOpenChannel this_ptr_conv;
12969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12970         this_ptr_conv.is_owned = false;
12971         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
12972         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
12973         return ret_arr;
12974 }
12975
12976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12977         LDKOpenChannel this_ptr_conv;
12978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12979         this_ptr_conv.is_owned = false;
12980         LDKPublicKey val_ref;
12981         CHECK((*env)->GetArrayLength(env, val) == 33);
12982         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12983         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
12984 }
12985
12986 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
12987         LDKOpenChannel this_ptr_conv;
12988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12989         this_ptr_conv.is_owned = false;
12990         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
12991         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
12992         return ret_arr;
12993 }
12994
12995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12996         LDKOpenChannel this_ptr_conv;
12997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12998         this_ptr_conv.is_owned = false;
12999         LDKPublicKey val_ref;
13000         CHECK((*env)->GetArrayLength(env, val) == 33);
13001         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13002         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
13003 }
13004
13005 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13006         LDKOpenChannel this_ptr_conv;
13007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13008         this_ptr_conv.is_owned = false;
13009         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13010         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
13011         return ret_arr;
13012 }
13013
13014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13015         LDKOpenChannel this_ptr_conv;
13016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13017         this_ptr_conv.is_owned = false;
13018         LDKPublicKey val_ref;
13019         CHECK((*env)->GetArrayLength(env, val) == 33);
13020         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13021         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
13022 }
13023
13024 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13025         LDKOpenChannel this_ptr_conv;
13026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13027         this_ptr_conv.is_owned = false;
13028         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13029         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
13030         return ret_arr;
13031 }
13032
13033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13034         LDKOpenChannel this_ptr_conv;
13035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13036         this_ptr_conv.is_owned = false;
13037         LDKPublicKey val_ref;
13038         CHECK((*env)->GetArrayLength(env, val) == 33);
13039         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13040         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
13041 }
13042
13043 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13044         LDKOpenChannel this_ptr_conv;
13045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13046         this_ptr_conv.is_owned = false;
13047         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13048         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
13049         return ret_arr;
13050 }
13051
13052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13053         LDKOpenChannel this_ptr_conv;
13054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13055         this_ptr_conv.is_owned = false;
13056         LDKPublicKey val_ref;
13057         CHECK((*env)->GetArrayLength(env, val) == 33);
13058         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13059         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
13060 }
13061
13062 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13063         LDKOpenChannel this_ptr_conv;
13064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13065         this_ptr_conv.is_owned = false;
13066         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13067         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
13068         return ret_arr;
13069 }
13070
13071 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) {
13072         LDKOpenChannel this_ptr_conv;
13073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13074         this_ptr_conv.is_owned = false;
13075         LDKPublicKey val_ref;
13076         CHECK((*env)->GetArrayLength(env, val) == 33);
13077         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13078         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
13079 }
13080
13081 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
13082         LDKOpenChannel this_ptr_conv;
13083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13084         this_ptr_conv.is_owned = false;
13085         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
13086         return ret_val;
13087 }
13088
13089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
13090         LDKOpenChannel this_ptr_conv;
13091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13092         this_ptr_conv.is_owned = false;
13093         OpenChannel_set_channel_flags(&this_ptr_conv, val);
13094 }
13095
13096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13097         LDKOpenChannel orig_conv;
13098         orig_conv.inner = (void*)(orig & (~1));
13099         orig_conv.is_owned = false;
13100         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
13101         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13102         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13103         long ret_ref = (long)ret_var.inner;
13104         if (ret_var.is_owned) {
13105                 ret_ref |= 1;
13106         }
13107         return ret_ref;
13108 }
13109
13110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13111         LDKAcceptChannel this_obj_conv;
13112         this_obj_conv.inner = (void*)(this_obj & (~1));
13113         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13114         AcceptChannel_free(this_obj_conv);
13115 }
13116
13117 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13118         LDKAcceptChannel this_ptr_conv;
13119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13120         this_ptr_conv.is_owned = false;
13121         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13122         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
13123         return ret_arr;
13124 }
13125
13126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13127         LDKAcceptChannel this_ptr_conv;
13128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13129         this_ptr_conv.is_owned = false;
13130         LDKThirtyTwoBytes val_ref;
13131         CHECK((*env)->GetArrayLength(env, val) == 32);
13132         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13133         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
13134 }
13135
13136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13137         LDKAcceptChannel this_ptr_conv;
13138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13139         this_ptr_conv.is_owned = false;
13140         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
13141         return ret_val;
13142 }
13143
13144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13145         LDKAcceptChannel this_ptr_conv;
13146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13147         this_ptr_conv.is_owned = false;
13148         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
13149 }
13150
13151 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) {
13152         LDKAcceptChannel this_ptr_conv;
13153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13154         this_ptr_conv.is_owned = false;
13155         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
13156         return ret_val;
13157 }
13158
13159 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) {
13160         LDKAcceptChannel this_ptr_conv;
13161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13162         this_ptr_conv.is_owned = false;
13163         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13164 }
13165
13166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13167         LDKAcceptChannel this_ptr_conv;
13168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13169         this_ptr_conv.is_owned = false;
13170         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
13171         return ret_val;
13172 }
13173
13174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13175         LDKAcceptChannel this_ptr_conv;
13176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13177         this_ptr_conv.is_owned = false;
13178         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
13179 }
13180
13181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13182         LDKAcceptChannel this_ptr_conv;
13183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13184         this_ptr_conv.is_owned = false;
13185         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
13186         return ret_val;
13187 }
13188
13189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13190         LDKAcceptChannel this_ptr_conv;
13191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13192         this_ptr_conv.is_owned = false;
13193         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
13194 }
13195
13196 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13197         LDKAcceptChannel this_ptr_conv;
13198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13199         this_ptr_conv.is_owned = false;
13200         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
13201         return ret_val;
13202 }
13203
13204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13205         LDKAcceptChannel this_ptr_conv;
13206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13207         this_ptr_conv.is_owned = false;
13208         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
13209 }
13210
13211 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13212         LDKAcceptChannel this_ptr_conv;
13213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13214         this_ptr_conv.is_owned = false;
13215         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
13216         return ret_val;
13217 }
13218
13219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13220         LDKAcceptChannel this_ptr_conv;
13221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13222         this_ptr_conv.is_owned = false;
13223         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
13224 }
13225
13226 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13227         LDKAcceptChannel this_ptr_conv;
13228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13229         this_ptr_conv.is_owned = false;
13230         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
13231         return ret_val;
13232 }
13233
13234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13235         LDKAcceptChannel this_ptr_conv;
13236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13237         this_ptr_conv.is_owned = false;
13238         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
13239 }
13240
13241 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13242         LDKAcceptChannel this_ptr_conv;
13243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13244         this_ptr_conv.is_owned = false;
13245         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13246         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
13247         return ret_arr;
13248 }
13249
13250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13251         LDKAcceptChannel this_ptr_conv;
13252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13253         this_ptr_conv.is_owned = false;
13254         LDKPublicKey val_ref;
13255         CHECK((*env)->GetArrayLength(env, val) == 33);
13256         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13257         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
13258 }
13259
13260 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13261         LDKAcceptChannel this_ptr_conv;
13262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13263         this_ptr_conv.is_owned = false;
13264         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13265         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
13266         return ret_arr;
13267 }
13268
13269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13270         LDKAcceptChannel this_ptr_conv;
13271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13272         this_ptr_conv.is_owned = false;
13273         LDKPublicKey val_ref;
13274         CHECK((*env)->GetArrayLength(env, val) == 33);
13275         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13276         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
13277 }
13278
13279 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13280         LDKAcceptChannel this_ptr_conv;
13281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13282         this_ptr_conv.is_owned = false;
13283         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13284         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
13285         return ret_arr;
13286 }
13287
13288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13289         LDKAcceptChannel this_ptr_conv;
13290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13291         this_ptr_conv.is_owned = false;
13292         LDKPublicKey val_ref;
13293         CHECK((*env)->GetArrayLength(env, val) == 33);
13294         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13295         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
13296 }
13297
13298 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13299         LDKAcceptChannel this_ptr_conv;
13300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13301         this_ptr_conv.is_owned = false;
13302         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13303         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
13304         return ret_arr;
13305 }
13306
13307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13308         LDKAcceptChannel this_ptr_conv;
13309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13310         this_ptr_conv.is_owned = false;
13311         LDKPublicKey val_ref;
13312         CHECK((*env)->GetArrayLength(env, val) == 33);
13313         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13314         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
13315 }
13316
13317 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13318         LDKAcceptChannel this_ptr_conv;
13319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13320         this_ptr_conv.is_owned = false;
13321         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13322         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
13323         return ret_arr;
13324 }
13325
13326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13327         LDKAcceptChannel this_ptr_conv;
13328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13329         this_ptr_conv.is_owned = false;
13330         LDKPublicKey val_ref;
13331         CHECK((*env)->GetArrayLength(env, val) == 33);
13332         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13333         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
13334 }
13335
13336 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13337         LDKAcceptChannel this_ptr_conv;
13338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13339         this_ptr_conv.is_owned = false;
13340         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13341         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
13342         return ret_arr;
13343 }
13344
13345 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) {
13346         LDKAcceptChannel this_ptr_conv;
13347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13348         this_ptr_conv.is_owned = false;
13349         LDKPublicKey val_ref;
13350         CHECK((*env)->GetArrayLength(env, val) == 33);
13351         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13352         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
13353 }
13354
13355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13356         LDKAcceptChannel orig_conv;
13357         orig_conv.inner = (void*)(orig & (~1));
13358         orig_conv.is_owned = false;
13359         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
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 void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13370         LDKFundingCreated this_obj_conv;
13371         this_obj_conv.inner = (void*)(this_obj & (~1));
13372         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13373         FundingCreated_free(this_obj_conv);
13374 }
13375
13376 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13377         LDKFundingCreated this_ptr_conv;
13378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13379         this_ptr_conv.is_owned = false;
13380         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13381         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
13382         return ret_arr;
13383 }
13384
13385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13386         LDKFundingCreated this_ptr_conv;
13387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13388         this_ptr_conv.is_owned = false;
13389         LDKThirtyTwoBytes val_ref;
13390         CHECK((*env)->GetArrayLength(env, val) == 32);
13391         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13392         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
13393 }
13394
13395 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
13396         LDKFundingCreated this_ptr_conv;
13397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13398         this_ptr_conv.is_owned = false;
13399         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13400         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
13401         return ret_arr;
13402 }
13403
13404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13405         LDKFundingCreated this_ptr_conv;
13406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13407         this_ptr_conv.is_owned = false;
13408         LDKThirtyTwoBytes val_ref;
13409         CHECK((*env)->GetArrayLength(env, val) == 32);
13410         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13411         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
13412 }
13413
13414 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
13415         LDKFundingCreated this_ptr_conv;
13416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13417         this_ptr_conv.is_owned = false;
13418         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
13419         return ret_val;
13420 }
13421
13422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13423         LDKFundingCreated this_ptr_conv;
13424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13425         this_ptr_conv.is_owned = false;
13426         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
13427 }
13428
13429 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
13430         LDKFundingCreated this_ptr_conv;
13431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13432         this_ptr_conv.is_owned = false;
13433         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
13434         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
13435         return ret_arr;
13436 }
13437
13438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13439         LDKFundingCreated this_ptr_conv;
13440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13441         this_ptr_conv.is_owned = false;
13442         LDKSignature val_ref;
13443         CHECK((*env)->GetArrayLength(env, val) == 64);
13444         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
13445         FundingCreated_set_signature(&this_ptr_conv, val_ref);
13446 }
13447
13448 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) {
13449         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
13450         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
13451         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
13452         LDKThirtyTwoBytes funding_txid_arg_ref;
13453         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
13454         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
13455         LDKSignature signature_arg_ref;
13456         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
13457         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
13458         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
13459         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13460         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13461         long ret_ref = (long)ret_var.inner;
13462         if (ret_var.is_owned) {
13463                 ret_ref |= 1;
13464         }
13465         return ret_ref;
13466 }
13467
13468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13469         LDKFundingCreated orig_conv;
13470         orig_conv.inner = (void*)(orig & (~1));
13471         orig_conv.is_owned = false;
13472         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
13473         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13474         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13475         long ret_ref = (long)ret_var.inner;
13476         if (ret_var.is_owned) {
13477                 ret_ref |= 1;
13478         }
13479         return ret_ref;
13480 }
13481
13482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13483         LDKFundingSigned this_obj_conv;
13484         this_obj_conv.inner = (void*)(this_obj & (~1));
13485         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13486         FundingSigned_free(this_obj_conv);
13487 }
13488
13489 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13490         LDKFundingSigned this_ptr_conv;
13491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13492         this_ptr_conv.is_owned = false;
13493         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13494         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
13495         return ret_arr;
13496 }
13497
13498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13499         LDKFundingSigned this_ptr_conv;
13500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13501         this_ptr_conv.is_owned = false;
13502         LDKThirtyTwoBytes val_ref;
13503         CHECK((*env)->GetArrayLength(env, val) == 32);
13504         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13505         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
13506 }
13507
13508 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
13509         LDKFundingSigned this_ptr_conv;
13510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13511         this_ptr_conv.is_owned = false;
13512         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
13513         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
13514         return ret_arr;
13515 }
13516
13517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13518         LDKFundingSigned this_ptr_conv;
13519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13520         this_ptr_conv.is_owned = false;
13521         LDKSignature val_ref;
13522         CHECK((*env)->GetArrayLength(env, val) == 64);
13523         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
13524         FundingSigned_set_signature(&this_ptr_conv, val_ref);
13525 }
13526
13527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
13528         LDKThirtyTwoBytes channel_id_arg_ref;
13529         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13530         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13531         LDKSignature signature_arg_ref;
13532         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
13533         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
13534         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
13535         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13536         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13537         long ret_ref = (long)ret_var.inner;
13538         if (ret_var.is_owned) {
13539                 ret_ref |= 1;
13540         }
13541         return ret_ref;
13542 }
13543
13544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13545         LDKFundingSigned orig_conv;
13546         orig_conv.inner = (void*)(orig & (~1));
13547         orig_conv.is_owned = false;
13548         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
13549         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13550         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13551         long ret_ref = (long)ret_var.inner;
13552         if (ret_var.is_owned) {
13553                 ret_ref |= 1;
13554         }
13555         return ret_ref;
13556 }
13557
13558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13559         LDKFundingLocked this_obj_conv;
13560         this_obj_conv.inner = (void*)(this_obj & (~1));
13561         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13562         FundingLocked_free(this_obj_conv);
13563 }
13564
13565 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13566         LDKFundingLocked this_ptr_conv;
13567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13568         this_ptr_conv.is_owned = false;
13569         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13570         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
13571         return ret_arr;
13572 }
13573
13574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13575         LDKFundingLocked this_ptr_conv;
13576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13577         this_ptr_conv.is_owned = false;
13578         LDKThirtyTwoBytes val_ref;
13579         CHECK((*env)->GetArrayLength(env, val) == 32);
13580         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13581         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
13582 }
13583
13584 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13585         LDKFundingLocked this_ptr_conv;
13586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13587         this_ptr_conv.is_owned = false;
13588         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13589         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
13590         return ret_arr;
13591 }
13592
13593 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) {
13594         LDKFundingLocked this_ptr_conv;
13595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13596         this_ptr_conv.is_owned = false;
13597         LDKPublicKey val_ref;
13598         CHECK((*env)->GetArrayLength(env, val) == 33);
13599         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13600         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
13601 }
13602
13603 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) {
13604         LDKThirtyTwoBytes channel_id_arg_ref;
13605         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13606         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13607         LDKPublicKey next_per_commitment_point_arg_ref;
13608         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
13609         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
13610         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
13611         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13612         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13613         long ret_ref = (long)ret_var.inner;
13614         if (ret_var.is_owned) {
13615                 ret_ref |= 1;
13616         }
13617         return ret_ref;
13618 }
13619
13620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13621         LDKFundingLocked orig_conv;
13622         orig_conv.inner = (void*)(orig & (~1));
13623         orig_conv.is_owned = false;
13624         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
13625         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13626         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13627         long ret_ref = (long)ret_var.inner;
13628         if (ret_var.is_owned) {
13629                 ret_ref |= 1;
13630         }
13631         return ret_ref;
13632 }
13633
13634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13635         LDKShutdown this_obj_conv;
13636         this_obj_conv.inner = (void*)(this_obj & (~1));
13637         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13638         Shutdown_free(this_obj_conv);
13639 }
13640
13641 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13642         LDKShutdown this_ptr_conv;
13643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13644         this_ptr_conv.is_owned = false;
13645         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13646         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
13647         return ret_arr;
13648 }
13649
13650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13651         LDKShutdown this_ptr_conv;
13652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13653         this_ptr_conv.is_owned = false;
13654         LDKThirtyTwoBytes val_ref;
13655         CHECK((*env)->GetArrayLength(env, val) == 32);
13656         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13657         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
13658 }
13659
13660 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13661         LDKShutdown this_ptr_conv;
13662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13663         this_ptr_conv.is_owned = false;
13664         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
13665         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13666         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13667         return ret_arr;
13668 }
13669
13670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13671         LDKShutdown this_ptr_conv;
13672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13673         this_ptr_conv.is_owned = false;
13674         LDKCVec_u8Z val_ref;
13675         val_ref.datalen = (*env)->GetArrayLength(env, val);
13676         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
13677         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
13678         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
13679 }
13680
13681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
13682         LDKThirtyTwoBytes channel_id_arg_ref;
13683         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13684         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13685         LDKCVec_u8Z scriptpubkey_arg_ref;
13686         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
13687         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
13688         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
13689         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
13690         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13691         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13692         long ret_ref = (long)ret_var.inner;
13693         if (ret_var.is_owned) {
13694                 ret_ref |= 1;
13695         }
13696         return ret_ref;
13697 }
13698
13699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13700         LDKShutdown orig_conv;
13701         orig_conv.inner = (void*)(orig & (~1));
13702         orig_conv.is_owned = false;
13703         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
13704         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13705         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13706         long ret_ref = (long)ret_var.inner;
13707         if (ret_var.is_owned) {
13708                 ret_ref |= 1;
13709         }
13710         return ret_ref;
13711 }
13712
13713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13714         LDKClosingSigned this_obj_conv;
13715         this_obj_conv.inner = (void*)(this_obj & (~1));
13716         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13717         ClosingSigned_free(this_obj_conv);
13718 }
13719
13720 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13721         LDKClosingSigned this_ptr_conv;
13722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13723         this_ptr_conv.is_owned = false;
13724         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13725         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
13726         return ret_arr;
13727 }
13728
13729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13730         LDKClosingSigned this_ptr_conv;
13731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13732         this_ptr_conv.is_owned = false;
13733         LDKThirtyTwoBytes val_ref;
13734         CHECK((*env)->GetArrayLength(env, val) == 32);
13735         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13736         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
13737 }
13738
13739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13740         LDKClosingSigned this_ptr_conv;
13741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13742         this_ptr_conv.is_owned = false;
13743         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
13744         return ret_val;
13745 }
13746
13747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13748         LDKClosingSigned this_ptr_conv;
13749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13750         this_ptr_conv.is_owned = false;
13751         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
13752 }
13753
13754 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
13755         LDKClosingSigned this_ptr_conv;
13756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13757         this_ptr_conv.is_owned = false;
13758         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
13759         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
13760         return ret_arr;
13761 }
13762
13763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13764         LDKClosingSigned this_ptr_conv;
13765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13766         this_ptr_conv.is_owned = false;
13767         LDKSignature val_ref;
13768         CHECK((*env)->GetArrayLength(env, val) == 64);
13769         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
13770         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
13771 }
13772
13773 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) {
13774         LDKThirtyTwoBytes channel_id_arg_ref;
13775         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13776         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13777         LDKSignature signature_arg_ref;
13778         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
13779         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
13780         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
13781         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13782         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13783         long ret_ref = (long)ret_var.inner;
13784         if (ret_var.is_owned) {
13785                 ret_ref |= 1;
13786         }
13787         return ret_ref;
13788 }
13789
13790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13791         LDKClosingSigned orig_conv;
13792         orig_conv.inner = (void*)(orig & (~1));
13793         orig_conv.is_owned = false;
13794         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
13795         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13796         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13797         long ret_ref = (long)ret_var.inner;
13798         if (ret_var.is_owned) {
13799                 ret_ref |= 1;
13800         }
13801         return ret_ref;
13802 }
13803
13804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13805         LDKUpdateAddHTLC this_obj_conv;
13806         this_obj_conv.inner = (void*)(this_obj & (~1));
13807         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13808         UpdateAddHTLC_free(this_obj_conv);
13809 }
13810
13811 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13812         LDKUpdateAddHTLC this_ptr_conv;
13813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13814         this_ptr_conv.is_owned = false;
13815         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13816         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
13817         return ret_arr;
13818 }
13819
13820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13821         LDKUpdateAddHTLC this_ptr_conv;
13822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13823         this_ptr_conv.is_owned = false;
13824         LDKThirtyTwoBytes val_ref;
13825         CHECK((*env)->GetArrayLength(env, val) == 32);
13826         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13827         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
13828 }
13829
13830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13831         LDKUpdateAddHTLC this_ptr_conv;
13832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13833         this_ptr_conv.is_owned = false;
13834         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
13835         return ret_val;
13836 }
13837
13838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13839         LDKUpdateAddHTLC this_ptr_conv;
13840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13841         this_ptr_conv.is_owned = false;
13842         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
13843 }
13844
13845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13846         LDKUpdateAddHTLC this_ptr_conv;
13847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13848         this_ptr_conv.is_owned = false;
13849         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
13850         return ret_val;
13851 }
13852
13853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13854         LDKUpdateAddHTLC this_ptr_conv;
13855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13856         this_ptr_conv.is_owned = false;
13857         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
13858 }
13859
13860 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
13861         LDKUpdateAddHTLC this_ptr_conv;
13862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13863         this_ptr_conv.is_owned = false;
13864         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13865         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
13866         return ret_arr;
13867 }
13868
13869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13870         LDKUpdateAddHTLC this_ptr_conv;
13871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13872         this_ptr_conv.is_owned = false;
13873         LDKThirtyTwoBytes val_ref;
13874         CHECK((*env)->GetArrayLength(env, val) == 32);
13875         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13876         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
13877 }
13878
13879 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
13880         LDKUpdateAddHTLC this_ptr_conv;
13881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13882         this_ptr_conv.is_owned = false;
13883         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
13884         return ret_val;
13885 }
13886
13887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13888         LDKUpdateAddHTLC this_ptr_conv;
13889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13890         this_ptr_conv.is_owned = false;
13891         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
13892 }
13893
13894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13895         LDKUpdateAddHTLC orig_conv;
13896         orig_conv.inner = (void*)(orig & (~1));
13897         orig_conv.is_owned = false;
13898         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
13899         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13900         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13901         long ret_ref = (long)ret_var.inner;
13902         if (ret_var.is_owned) {
13903                 ret_ref |= 1;
13904         }
13905         return ret_ref;
13906 }
13907
13908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13909         LDKUpdateFulfillHTLC this_obj_conv;
13910         this_obj_conv.inner = (void*)(this_obj & (~1));
13911         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13912         UpdateFulfillHTLC_free(this_obj_conv);
13913 }
13914
13915 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13916         LDKUpdateFulfillHTLC this_ptr_conv;
13917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13918         this_ptr_conv.is_owned = false;
13919         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13920         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
13921         return ret_arr;
13922 }
13923
13924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13925         LDKUpdateFulfillHTLC this_ptr_conv;
13926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13927         this_ptr_conv.is_owned = false;
13928         LDKThirtyTwoBytes val_ref;
13929         CHECK((*env)->GetArrayLength(env, val) == 32);
13930         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13931         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
13932 }
13933
13934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13935         LDKUpdateFulfillHTLC this_ptr_conv;
13936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13937         this_ptr_conv.is_owned = false;
13938         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
13939         return ret_val;
13940 }
13941
13942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13943         LDKUpdateFulfillHTLC this_ptr_conv;
13944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13945         this_ptr_conv.is_owned = false;
13946         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
13947 }
13948
13949 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
13950         LDKUpdateFulfillHTLC this_ptr_conv;
13951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13952         this_ptr_conv.is_owned = false;
13953         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13954         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
13955         return ret_arr;
13956 }
13957
13958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13959         LDKUpdateFulfillHTLC this_ptr_conv;
13960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13961         this_ptr_conv.is_owned = false;
13962         LDKThirtyTwoBytes val_ref;
13963         CHECK((*env)->GetArrayLength(env, val) == 32);
13964         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13965         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
13966 }
13967
13968 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) {
13969         LDKThirtyTwoBytes channel_id_arg_ref;
13970         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13971         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13972         LDKThirtyTwoBytes payment_preimage_arg_ref;
13973         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
13974         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
13975         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
13976         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13977         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13978         long ret_ref = (long)ret_var.inner;
13979         if (ret_var.is_owned) {
13980                 ret_ref |= 1;
13981         }
13982         return ret_ref;
13983 }
13984
13985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13986         LDKUpdateFulfillHTLC orig_conv;
13987         orig_conv.inner = (void*)(orig & (~1));
13988         orig_conv.is_owned = false;
13989         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
13990         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13991         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13992         long ret_ref = (long)ret_var.inner;
13993         if (ret_var.is_owned) {
13994                 ret_ref |= 1;
13995         }
13996         return ret_ref;
13997 }
13998
13999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14000         LDKUpdateFailHTLC this_obj_conv;
14001         this_obj_conv.inner = (void*)(this_obj & (~1));
14002         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14003         UpdateFailHTLC_free(this_obj_conv);
14004 }
14005
14006 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14007         LDKUpdateFailHTLC this_ptr_conv;
14008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14009         this_ptr_conv.is_owned = false;
14010         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14011         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
14012         return ret_arr;
14013 }
14014
14015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14016         LDKUpdateFailHTLC this_ptr_conv;
14017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14018         this_ptr_conv.is_owned = false;
14019         LDKThirtyTwoBytes val_ref;
14020         CHECK((*env)->GetArrayLength(env, val) == 32);
14021         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14022         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
14023 }
14024
14025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14026         LDKUpdateFailHTLC this_ptr_conv;
14027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14028         this_ptr_conv.is_owned = false;
14029         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
14030         return ret_val;
14031 }
14032
14033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14034         LDKUpdateFailHTLC this_ptr_conv;
14035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14036         this_ptr_conv.is_owned = false;
14037         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
14038 }
14039
14040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14041         LDKUpdateFailHTLC orig_conv;
14042         orig_conv.inner = (void*)(orig & (~1));
14043         orig_conv.is_owned = false;
14044         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
14045         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14046         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14047         long ret_ref = (long)ret_var.inner;
14048         if (ret_var.is_owned) {
14049                 ret_ref |= 1;
14050         }
14051         return ret_ref;
14052 }
14053
14054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14055         LDKUpdateFailMalformedHTLC this_obj_conv;
14056         this_obj_conv.inner = (void*)(this_obj & (~1));
14057         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14058         UpdateFailMalformedHTLC_free(this_obj_conv);
14059 }
14060
14061 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14062         LDKUpdateFailMalformedHTLC this_ptr_conv;
14063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14064         this_ptr_conv.is_owned = false;
14065         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14066         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
14067         return ret_arr;
14068 }
14069
14070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14071         LDKUpdateFailMalformedHTLC this_ptr_conv;
14072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14073         this_ptr_conv.is_owned = false;
14074         LDKThirtyTwoBytes val_ref;
14075         CHECK((*env)->GetArrayLength(env, val) == 32);
14076         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14077         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
14078 }
14079
14080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14081         LDKUpdateFailMalformedHTLC this_ptr_conv;
14082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14083         this_ptr_conv.is_owned = false;
14084         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
14085         return ret_val;
14086 }
14087
14088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14089         LDKUpdateFailMalformedHTLC this_ptr_conv;
14090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14091         this_ptr_conv.is_owned = false;
14092         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
14093 }
14094
14095 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
14096         LDKUpdateFailMalformedHTLC this_ptr_conv;
14097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14098         this_ptr_conv.is_owned = false;
14099         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
14100         return ret_val;
14101 }
14102
14103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14104         LDKUpdateFailMalformedHTLC this_ptr_conv;
14105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14106         this_ptr_conv.is_owned = false;
14107         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
14108 }
14109
14110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14111         LDKUpdateFailMalformedHTLC orig_conv;
14112         orig_conv.inner = (void*)(orig & (~1));
14113         orig_conv.is_owned = false;
14114         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
14115         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14116         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14117         long ret_ref = (long)ret_var.inner;
14118         if (ret_var.is_owned) {
14119                 ret_ref |= 1;
14120         }
14121         return ret_ref;
14122 }
14123
14124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14125         LDKCommitmentSigned this_obj_conv;
14126         this_obj_conv.inner = (void*)(this_obj & (~1));
14127         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14128         CommitmentSigned_free(this_obj_conv);
14129 }
14130
14131 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14132         LDKCommitmentSigned this_ptr_conv;
14133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14134         this_ptr_conv.is_owned = false;
14135         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14136         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
14137         return ret_arr;
14138 }
14139
14140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14141         LDKCommitmentSigned this_ptr_conv;
14142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14143         this_ptr_conv.is_owned = false;
14144         LDKThirtyTwoBytes val_ref;
14145         CHECK((*env)->GetArrayLength(env, val) == 32);
14146         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14147         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
14148 }
14149
14150 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14151         LDKCommitmentSigned this_ptr_conv;
14152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14153         this_ptr_conv.is_owned = false;
14154         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14155         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
14156         return ret_arr;
14157 }
14158
14159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14160         LDKCommitmentSigned this_ptr_conv;
14161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14162         this_ptr_conv.is_owned = false;
14163         LDKSignature val_ref;
14164         CHECK((*env)->GetArrayLength(env, val) == 64);
14165         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14166         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
14167 }
14168
14169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
14170         LDKCommitmentSigned this_ptr_conv;
14171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14172         this_ptr_conv.is_owned = false;
14173         LDKCVec_SignatureZ val_constr;
14174         val_constr.datalen = (*env)->GetArrayLength(env, val);
14175         if (val_constr.datalen > 0)
14176                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14177         else
14178                 val_constr.data = NULL;
14179         for (size_t i = 0; i < val_constr.datalen; i++) {
14180                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
14181                 LDKSignature val_conv_8_ref;
14182                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
14183                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
14184                 val_constr.data[i] = val_conv_8_ref;
14185         }
14186         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
14187 }
14188
14189 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) {
14190         LDKThirtyTwoBytes channel_id_arg_ref;
14191         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14192         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14193         LDKSignature signature_arg_ref;
14194         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
14195         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
14196         LDKCVec_SignatureZ htlc_signatures_arg_constr;
14197         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
14198         if (htlc_signatures_arg_constr.datalen > 0)
14199                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14200         else
14201                 htlc_signatures_arg_constr.data = NULL;
14202         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
14203                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
14204                 LDKSignature htlc_signatures_arg_conv_8_ref;
14205                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
14206                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
14207                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
14208         }
14209         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
14210         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14211         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14212         long ret_ref = (long)ret_var.inner;
14213         if (ret_var.is_owned) {
14214                 ret_ref |= 1;
14215         }
14216         return ret_ref;
14217 }
14218
14219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14220         LDKCommitmentSigned orig_conv;
14221         orig_conv.inner = (void*)(orig & (~1));
14222         orig_conv.is_owned = false;
14223         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
14224         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14225         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14226         long ret_ref = (long)ret_var.inner;
14227         if (ret_var.is_owned) {
14228                 ret_ref |= 1;
14229         }
14230         return ret_ref;
14231 }
14232
14233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14234         LDKRevokeAndACK this_obj_conv;
14235         this_obj_conv.inner = (void*)(this_obj & (~1));
14236         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14237         RevokeAndACK_free(this_obj_conv);
14238 }
14239
14240 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14241         LDKRevokeAndACK this_ptr_conv;
14242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14243         this_ptr_conv.is_owned = false;
14244         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14245         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
14246         return ret_arr;
14247 }
14248
14249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14250         LDKRevokeAndACK this_ptr_conv;
14251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14252         this_ptr_conv.is_owned = false;
14253         LDKThirtyTwoBytes val_ref;
14254         CHECK((*env)->GetArrayLength(env, val) == 32);
14255         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14256         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
14257 }
14258
14259 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
14260         LDKRevokeAndACK this_ptr_conv;
14261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14262         this_ptr_conv.is_owned = false;
14263         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14264         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
14265         return ret_arr;
14266 }
14267
14268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14269         LDKRevokeAndACK this_ptr_conv;
14270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14271         this_ptr_conv.is_owned = false;
14272         LDKThirtyTwoBytes val_ref;
14273         CHECK((*env)->GetArrayLength(env, val) == 32);
14274         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14275         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
14276 }
14277
14278 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14279         LDKRevokeAndACK this_ptr_conv;
14280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14281         this_ptr_conv.is_owned = false;
14282         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14283         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
14284         return ret_arr;
14285 }
14286
14287 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) {
14288         LDKRevokeAndACK this_ptr_conv;
14289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14290         this_ptr_conv.is_owned = false;
14291         LDKPublicKey val_ref;
14292         CHECK((*env)->GetArrayLength(env, val) == 33);
14293         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14294         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
14295 }
14296
14297 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) {
14298         LDKThirtyTwoBytes channel_id_arg_ref;
14299         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14300         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14301         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
14302         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
14303         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
14304         LDKPublicKey next_per_commitment_point_arg_ref;
14305         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
14306         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
14307         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
14308         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14309         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14310         long ret_ref = (long)ret_var.inner;
14311         if (ret_var.is_owned) {
14312                 ret_ref |= 1;
14313         }
14314         return ret_ref;
14315 }
14316
14317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14318         LDKRevokeAndACK orig_conv;
14319         orig_conv.inner = (void*)(orig & (~1));
14320         orig_conv.is_owned = false;
14321         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
14322         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14323         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14324         long ret_ref = (long)ret_var.inner;
14325         if (ret_var.is_owned) {
14326                 ret_ref |= 1;
14327         }
14328         return ret_ref;
14329 }
14330
14331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14332         LDKUpdateFee this_obj_conv;
14333         this_obj_conv.inner = (void*)(this_obj & (~1));
14334         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14335         UpdateFee_free(this_obj_conv);
14336 }
14337
14338 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14339         LDKUpdateFee this_ptr_conv;
14340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14341         this_ptr_conv.is_owned = false;
14342         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14343         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
14344         return ret_arr;
14345 }
14346
14347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14348         LDKUpdateFee this_ptr_conv;
14349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14350         this_ptr_conv.is_owned = false;
14351         LDKThirtyTwoBytes val_ref;
14352         CHECK((*env)->GetArrayLength(env, val) == 32);
14353         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14354         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
14355 }
14356
14357 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
14358         LDKUpdateFee this_ptr_conv;
14359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14360         this_ptr_conv.is_owned = false;
14361         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
14362         return ret_val;
14363 }
14364
14365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14366         LDKUpdateFee this_ptr_conv;
14367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14368         this_ptr_conv.is_owned = false;
14369         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
14370 }
14371
14372 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) {
14373         LDKThirtyTwoBytes channel_id_arg_ref;
14374         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14375         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14376         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
14377         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14378         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14379         long ret_ref = (long)ret_var.inner;
14380         if (ret_var.is_owned) {
14381                 ret_ref |= 1;
14382         }
14383         return ret_ref;
14384 }
14385
14386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14387         LDKUpdateFee orig_conv;
14388         orig_conv.inner = (void*)(orig & (~1));
14389         orig_conv.is_owned = false;
14390         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
14391         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14392         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14393         long ret_ref = (long)ret_var.inner;
14394         if (ret_var.is_owned) {
14395                 ret_ref |= 1;
14396         }
14397         return ret_ref;
14398 }
14399
14400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14401         LDKDataLossProtect this_obj_conv;
14402         this_obj_conv.inner = (void*)(this_obj & (~1));
14403         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14404         DataLossProtect_free(this_obj_conv);
14405 }
14406
14407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
14408         LDKDataLossProtect this_ptr_conv;
14409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14410         this_ptr_conv.is_owned = false;
14411         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14412         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
14413         return ret_arr;
14414 }
14415
14416 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) {
14417         LDKDataLossProtect this_ptr_conv;
14418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14419         this_ptr_conv.is_owned = false;
14420         LDKThirtyTwoBytes val_ref;
14421         CHECK((*env)->GetArrayLength(env, val) == 32);
14422         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14423         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
14424 }
14425
14426 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14427         LDKDataLossProtect this_ptr_conv;
14428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14429         this_ptr_conv.is_owned = false;
14430         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14431         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
14432         return ret_arr;
14433 }
14434
14435 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) {
14436         LDKDataLossProtect this_ptr_conv;
14437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14438         this_ptr_conv.is_owned = false;
14439         LDKPublicKey val_ref;
14440         CHECK((*env)->GetArrayLength(env, val) == 33);
14441         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14442         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
14443 }
14444
14445 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) {
14446         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
14447         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
14448         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
14449         LDKPublicKey my_current_per_commitment_point_arg_ref;
14450         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
14451         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
14452         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
14453         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14454         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14455         long ret_ref = (long)ret_var.inner;
14456         if (ret_var.is_owned) {
14457                 ret_ref |= 1;
14458         }
14459         return ret_ref;
14460 }
14461
14462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14463         LDKDataLossProtect orig_conv;
14464         orig_conv.inner = (void*)(orig & (~1));
14465         orig_conv.is_owned = false;
14466         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
14467         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14468         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14469         long ret_ref = (long)ret_var.inner;
14470         if (ret_var.is_owned) {
14471                 ret_ref |= 1;
14472         }
14473         return ret_ref;
14474 }
14475
14476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14477         LDKChannelReestablish this_obj_conv;
14478         this_obj_conv.inner = (void*)(this_obj & (~1));
14479         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14480         ChannelReestablish_free(this_obj_conv);
14481 }
14482
14483 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14484         LDKChannelReestablish this_ptr_conv;
14485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14486         this_ptr_conv.is_owned = false;
14487         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14488         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
14489         return ret_arr;
14490 }
14491
14492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14493         LDKChannelReestablish this_ptr_conv;
14494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14495         this_ptr_conv.is_owned = false;
14496         LDKThirtyTwoBytes val_ref;
14497         CHECK((*env)->GetArrayLength(env, val) == 32);
14498         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14499         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
14500 }
14501
14502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
14503         LDKChannelReestablish this_ptr_conv;
14504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14505         this_ptr_conv.is_owned = false;
14506         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
14507         return ret_val;
14508 }
14509
14510 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) {
14511         LDKChannelReestablish this_ptr_conv;
14512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14513         this_ptr_conv.is_owned = false;
14514         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
14515 }
14516
14517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
14518         LDKChannelReestablish this_ptr_conv;
14519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14520         this_ptr_conv.is_owned = false;
14521         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
14522         return ret_val;
14523 }
14524
14525 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) {
14526         LDKChannelReestablish this_ptr_conv;
14527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14528         this_ptr_conv.is_owned = false;
14529         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
14530 }
14531
14532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14533         LDKChannelReestablish orig_conv;
14534         orig_conv.inner = (void*)(orig & (~1));
14535         orig_conv.is_owned = false;
14536         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
14537         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14538         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14539         long ret_ref = (long)ret_var.inner;
14540         if (ret_var.is_owned) {
14541                 ret_ref |= 1;
14542         }
14543         return ret_ref;
14544 }
14545
14546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14547         LDKAnnouncementSignatures this_obj_conv;
14548         this_obj_conv.inner = (void*)(this_obj & (~1));
14549         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14550         AnnouncementSignatures_free(this_obj_conv);
14551 }
14552
14553 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14554         LDKAnnouncementSignatures this_ptr_conv;
14555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14556         this_ptr_conv.is_owned = false;
14557         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14558         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
14559         return ret_arr;
14560 }
14561
14562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14563         LDKAnnouncementSignatures this_ptr_conv;
14564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14565         this_ptr_conv.is_owned = false;
14566         LDKThirtyTwoBytes val_ref;
14567         CHECK((*env)->GetArrayLength(env, val) == 32);
14568         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14569         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
14570 }
14571
14572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14573         LDKAnnouncementSignatures this_ptr_conv;
14574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14575         this_ptr_conv.is_owned = false;
14576         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
14577         return ret_val;
14578 }
14579
14580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14581         LDKAnnouncementSignatures this_ptr_conv;
14582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14583         this_ptr_conv.is_owned = false;
14584         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
14585 }
14586
14587 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14588         LDKAnnouncementSignatures this_ptr_conv;
14589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14590         this_ptr_conv.is_owned = false;
14591         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14592         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
14593         return ret_arr;
14594 }
14595
14596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14597         LDKAnnouncementSignatures this_ptr_conv;
14598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14599         this_ptr_conv.is_owned = false;
14600         LDKSignature val_ref;
14601         CHECK((*env)->GetArrayLength(env, val) == 64);
14602         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14603         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
14604 }
14605
14606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14607         LDKAnnouncementSignatures this_ptr_conv;
14608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14609         this_ptr_conv.is_owned = false;
14610         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14611         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
14612         return ret_arr;
14613 }
14614
14615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14616         LDKAnnouncementSignatures this_ptr_conv;
14617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14618         this_ptr_conv.is_owned = false;
14619         LDKSignature val_ref;
14620         CHECK((*env)->GetArrayLength(env, val) == 64);
14621         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14622         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
14623 }
14624
14625 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) {
14626         LDKThirtyTwoBytes channel_id_arg_ref;
14627         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14628         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14629         LDKSignature node_signature_arg_ref;
14630         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
14631         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
14632         LDKSignature bitcoin_signature_arg_ref;
14633         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
14634         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
14635         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
14636         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14637         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14638         long ret_ref = (long)ret_var.inner;
14639         if (ret_var.is_owned) {
14640                 ret_ref |= 1;
14641         }
14642         return ret_ref;
14643 }
14644
14645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14646         LDKAnnouncementSignatures orig_conv;
14647         orig_conv.inner = (void*)(orig & (~1));
14648         orig_conv.is_owned = false;
14649         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
14650         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14651         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14652         long ret_ref = (long)ret_var.inner;
14653         if (ret_var.is_owned) {
14654                 ret_ref |= 1;
14655         }
14656         return ret_ref;
14657 }
14658
14659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14660         if ((this_ptr & 1) != 0) return;
14661         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
14662         FREE((void*)this_ptr);
14663         NetAddress_free(this_ptr_conv);
14664 }
14665
14666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14667         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
14668         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
14669         *ret_copy = NetAddress_clone(orig_conv);
14670         long ret_ref = (long)ret_copy;
14671         return ret_ref;
14672 }
14673
14674 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
14675         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
14676         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
14677         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14678         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14679         CVec_u8Z_free(ret_var);
14680         return ret_arr;
14681 }
14682
14683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14684         LDKu8slice ser_ref;
14685         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14686         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14687         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
14688         *ret_conv = Result_read(ser_ref);
14689         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14690         return (long)ret_conv;
14691 }
14692
14693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14694         LDKUnsignedNodeAnnouncement this_obj_conv;
14695         this_obj_conv.inner = (void*)(this_obj & (~1));
14696         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14697         UnsignedNodeAnnouncement_free(this_obj_conv);
14698 }
14699
14700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
14701         LDKUnsignedNodeAnnouncement this_ptr_conv;
14702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14703         this_ptr_conv.is_owned = false;
14704         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
14705         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14706         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14707         long ret_ref = (long)ret_var.inner;
14708         if (ret_var.is_owned) {
14709                 ret_ref |= 1;
14710         }
14711         return ret_ref;
14712 }
14713
14714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14715         LDKUnsignedNodeAnnouncement this_ptr_conv;
14716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14717         this_ptr_conv.is_owned = false;
14718         LDKNodeFeatures val_conv;
14719         val_conv.inner = (void*)(val & (~1));
14720         val_conv.is_owned = (val & 1) || (val == 0);
14721         val_conv = NodeFeatures_clone(&val_conv);
14722         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
14723 }
14724
14725 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
14726         LDKUnsignedNodeAnnouncement this_ptr_conv;
14727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14728         this_ptr_conv.is_owned = false;
14729         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
14730         return ret_val;
14731 }
14732
14733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14734         LDKUnsignedNodeAnnouncement this_ptr_conv;
14735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14736         this_ptr_conv.is_owned = false;
14737         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
14738 }
14739
14740 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14741         LDKUnsignedNodeAnnouncement this_ptr_conv;
14742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14743         this_ptr_conv.is_owned = false;
14744         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14745         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
14746         return ret_arr;
14747 }
14748
14749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14750         LDKUnsignedNodeAnnouncement this_ptr_conv;
14751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14752         this_ptr_conv.is_owned = false;
14753         LDKPublicKey val_ref;
14754         CHECK((*env)->GetArrayLength(env, val) == 33);
14755         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14756         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
14757 }
14758
14759 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
14760         LDKUnsignedNodeAnnouncement this_ptr_conv;
14761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14762         this_ptr_conv.is_owned = false;
14763         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
14764         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
14765         return ret_arr;
14766 }
14767
14768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14769         LDKUnsignedNodeAnnouncement this_ptr_conv;
14770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14771         this_ptr_conv.is_owned = false;
14772         LDKThreeBytes val_ref;
14773         CHECK((*env)->GetArrayLength(env, val) == 3);
14774         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
14775         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
14776 }
14777
14778 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
14779         LDKUnsignedNodeAnnouncement this_ptr_conv;
14780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14781         this_ptr_conv.is_owned = false;
14782         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14783         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
14784         return ret_arr;
14785 }
14786
14787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14788         LDKUnsignedNodeAnnouncement this_ptr_conv;
14789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14790         this_ptr_conv.is_owned = false;
14791         LDKThirtyTwoBytes val_ref;
14792         CHECK((*env)->GetArrayLength(env, val) == 32);
14793         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14794         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
14795 }
14796
14797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
14798         LDKUnsignedNodeAnnouncement this_ptr_conv;
14799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14800         this_ptr_conv.is_owned = false;
14801         LDKCVec_NetAddressZ val_constr;
14802         val_constr.datalen = (*env)->GetArrayLength(env, val);
14803         if (val_constr.datalen > 0)
14804                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14805         else
14806                 val_constr.data = NULL;
14807         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
14808         for (size_t m = 0; m < val_constr.datalen; m++) {
14809                 int64_t val_conv_12 = val_vals[m];
14810                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
14811                 FREE((void*)val_conv_12);
14812                 val_constr.data[m] = val_conv_12_conv;
14813         }
14814         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
14815         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
14816 }
14817
14818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14819         LDKUnsignedNodeAnnouncement orig_conv;
14820         orig_conv.inner = (void*)(orig & (~1));
14821         orig_conv.is_owned = false;
14822         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
14823         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14824         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14825         long ret_ref = (long)ret_var.inner;
14826         if (ret_var.is_owned) {
14827                 ret_ref |= 1;
14828         }
14829         return ret_ref;
14830 }
14831
14832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14833         LDKNodeAnnouncement this_obj_conv;
14834         this_obj_conv.inner = (void*)(this_obj & (~1));
14835         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14836         NodeAnnouncement_free(this_obj_conv);
14837 }
14838
14839 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14840         LDKNodeAnnouncement this_ptr_conv;
14841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14842         this_ptr_conv.is_owned = false;
14843         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14844         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
14845         return ret_arr;
14846 }
14847
14848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14849         LDKNodeAnnouncement this_ptr_conv;
14850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14851         this_ptr_conv.is_owned = false;
14852         LDKSignature val_ref;
14853         CHECK((*env)->GetArrayLength(env, val) == 64);
14854         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14855         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
14856 }
14857
14858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
14859         LDKNodeAnnouncement this_ptr_conv;
14860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14861         this_ptr_conv.is_owned = false;
14862         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
14863         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14864         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14865         long ret_ref = (long)ret_var.inner;
14866         if (ret_var.is_owned) {
14867                 ret_ref |= 1;
14868         }
14869         return ret_ref;
14870 }
14871
14872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14873         LDKNodeAnnouncement this_ptr_conv;
14874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14875         this_ptr_conv.is_owned = false;
14876         LDKUnsignedNodeAnnouncement val_conv;
14877         val_conv.inner = (void*)(val & (~1));
14878         val_conv.is_owned = (val & 1) || (val == 0);
14879         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
14880         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
14881 }
14882
14883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
14884         LDKSignature signature_arg_ref;
14885         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
14886         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
14887         LDKUnsignedNodeAnnouncement contents_arg_conv;
14888         contents_arg_conv.inner = (void*)(contents_arg & (~1));
14889         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
14890         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
14891         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
14892         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14893         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14894         long ret_ref = (long)ret_var.inner;
14895         if (ret_var.is_owned) {
14896                 ret_ref |= 1;
14897         }
14898         return ret_ref;
14899 }
14900
14901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14902         LDKNodeAnnouncement orig_conv;
14903         orig_conv.inner = (void*)(orig & (~1));
14904         orig_conv.is_owned = false;
14905         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
14906         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14907         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14908         long ret_ref = (long)ret_var.inner;
14909         if (ret_var.is_owned) {
14910                 ret_ref |= 1;
14911         }
14912         return ret_ref;
14913 }
14914
14915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14916         LDKUnsignedChannelAnnouncement this_obj_conv;
14917         this_obj_conv.inner = (void*)(this_obj & (~1));
14918         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14919         UnsignedChannelAnnouncement_free(this_obj_conv);
14920 }
14921
14922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
14923         LDKUnsignedChannelAnnouncement this_ptr_conv;
14924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14925         this_ptr_conv.is_owned = false;
14926         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
14927         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14928         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14929         long ret_ref = (long)ret_var.inner;
14930         if (ret_var.is_owned) {
14931                 ret_ref |= 1;
14932         }
14933         return ret_ref;
14934 }
14935
14936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14937         LDKUnsignedChannelAnnouncement this_ptr_conv;
14938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14939         this_ptr_conv.is_owned = false;
14940         LDKChannelFeatures val_conv;
14941         val_conv.inner = (void*)(val & (~1));
14942         val_conv.is_owned = (val & 1) || (val == 0);
14943         val_conv = ChannelFeatures_clone(&val_conv);
14944         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
14945 }
14946
14947 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14948         LDKUnsignedChannelAnnouncement this_ptr_conv;
14949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14950         this_ptr_conv.is_owned = false;
14951         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14952         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
14953         return ret_arr;
14954 }
14955
14956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14957         LDKUnsignedChannelAnnouncement this_ptr_conv;
14958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14959         this_ptr_conv.is_owned = false;
14960         LDKThirtyTwoBytes val_ref;
14961         CHECK((*env)->GetArrayLength(env, val) == 32);
14962         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14963         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
14964 }
14965
14966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14967         LDKUnsignedChannelAnnouncement this_ptr_conv;
14968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14969         this_ptr_conv.is_owned = false;
14970         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
14971         return ret_val;
14972 }
14973
14974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14975         LDKUnsignedChannelAnnouncement this_ptr_conv;
14976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14977         this_ptr_conv.is_owned = false;
14978         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
14979 }
14980
14981 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
14982         LDKUnsignedChannelAnnouncement this_ptr_conv;
14983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14984         this_ptr_conv.is_owned = false;
14985         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14986         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
14987         return ret_arr;
14988 }
14989
14990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14991         LDKUnsignedChannelAnnouncement this_ptr_conv;
14992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14993         this_ptr_conv.is_owned = false;
14994         LDKPublicKey val_ref;
14995         CHECK((*env)->GetArrayLength(env, val) == 33);
14996         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14997         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
14998 }
14999
15000 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
15001         LDKUnsignedChannelAnnouncement this_ptr_conv;
15002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15003         this_ptr_conv.is_owned = false;
15004         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15005         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
15006         return ret_arr;
15007 }
15008
15009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15010         LDKUnsignedChannelAnnouncement this_ptr_conv;
15011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15012         this_ptr_conv.is_owned = false;
15013         LDKPublicKey val_ref;
15014         CHECK((*env)->GetArrayLength(env, val) == 33);
15015         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15016         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
15017 }
15018
15019 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
15020         LDKUnsignedChannelAnnouncement this_ptr_conv;
15021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15022         this_ptr_conv.is_owned = false;
15023         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15024         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
15025         return ret_arr;
15026 }
15027
15028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15029         LDKUnsignedChannelAnnouncement this_ptr_conv;
15030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15031         this_ptr_conv.is_owned = false;
15032         LDKPublicKey val_ref;
15033         CHECK((*env)->GetArrayLength(env, val) == 33);
15034         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15035         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
15036 }
15037
15038 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
15039         LDKUnsignedChannelAnnouncement this_ptr_conv;
15040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15041         this_ptr_conv.is_owned = false;
15042         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15043         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
15044         return ret_arr;
15045 }
15046
15047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15048         LDKUnsignedChannelAnnouncement this_ptr_conv;
15049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15050         this_ptr_conv.is_owned = false;
15051         LDKPublicKey val_ref;
15052         CHECK((*env)->GetArrayLength(env, val) == 33);
15053         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15054         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
15055 }
15056
15057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15058         LDKUnsignedChannelAnnouncement orig_conv;
15059         orig_conv.inner = (void*)(orig & (~1));
15060         orig_conv.is_owned = false;
15061         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
15062         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15063         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15064         long ret_ref = (long)ret_var.inner;
15065         if (ret_var.is_owned) {
15066                 ret_ref |= 1;
15067         }
15068         return ret_ref;
15069 }
15070
15071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15072         LDKChannelAnnouncement this_obj_conv;
15073         this_obj_conv.inner = (void*)(this_obj & (~1));
15074         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15075         ChannelAnnouncement_free(this_obj_conv);
15076 }
15077
15078 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
15079         LDKChannelAnnouncement this_ptr_conv;
15080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15081         this_ptr_conv.is_owned = false;
15082         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15083         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
15084         return ret_arr;
15085 }
15086
15087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15088         LDKChannelAnnouncement this_ptr_conv;
15089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15090         this_ptr_conv.is_owned = false;
15091         LDKSignature val_ref;
15092         CHECK((*env)->GetArrayLength(env, val) == 64);
15093         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15094         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
15095 }
15096
15097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
15098         LDKChannelAnnouncement this_ptr_conv;
15099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15100         this_ptr_conv.is_owned = false;
15101         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15102         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
15103         return ret_arr;
15104 }
15105
15106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15107         LDKChannelAnnouncement this_ptr_conv;
15108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15109         this_ptr_conv.is_owned = false;
15110         LDKSignature val_ref;
15111         CHECK((*env)->GetArrayLength(env, val) == 64);
15112         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15113         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
15114 }
15115
15116 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
15117         LDKChannelAnnouncement this_ptr_conv;
15118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15119         this_ptr_conv.is_owned = false;
15120         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15121         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
15122         return ret_arr;
15123 }
15124
15125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15126         LDKChannelAnnouncement this_ptr_conv;
15127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15128         this_ptr_conv.is_owned = false;
15129         LDKSignature val_ref;
15130         CHECK((*env)->GetArrayLength(env, val) == 64);
15131         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15132         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
15133 }
15134
15135 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
15136         LDKChannelAnnouncement this_ptr_conv;
15137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15138         this_ptr_conv.is_owned = false;
15139         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15140         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
15141         return ret_arr;
15142 }
15143
15144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15145         LDKChannelAnnouncement this_ptr_conv;
15146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15147         this_ptr_conv.is_owned = false;
15148         LDKSignature val_ref;
15149         CHECK((*env)->GetArrayLength(env, val) == 64);
15150         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15151         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
15152 }
15153
15154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
15155         LDKChannelAnnouncement this_ptr_conv;
15156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15157         this_ptr_conv.is_owned = false;
15158         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
15159         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15160         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15161         long ret_ref = (long)ret_var.inner;
15162         if (ret_var.is_owned) {
15163                 ret_ref |= 1;
15164         }
15165         return ret_ref;
15166 }
15167
15168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15169         LDKChannelAnnouncement this_ptr_conv;
15170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15171         this_ptr_conv.is_owned = false;
15172         LDKUnsignedChannelAnnouncement val_conv;
15173         val_conv.inner = (void*)(val & (~1));
15174         val_conv.is_owned = (val & 1) || (val == 0);
15175         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
15176         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
15177 }
15178
15179 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) {
15180         LDKSignature node_signature_1_arg_ref;
15181         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
15182         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
15183         LDKSignature node_signature_2_arg_ref;
15184         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
15185         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
15186         LDKSignature bitcoin_signature_1_arg_ref;
15187         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
15188         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
15189         LDKSignature bitcoin_signature_2_arg_ref;
15190         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
15191         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
15192         LDKUnsignedChannelAnnouncement contents_arg_conv;
15193         contents_arg_conv.inner = (void*)(contents_arg & (~1));
15194         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
15195         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
15196         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);
15197         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15198         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15199         long ret_ref = (long)ret_var.inner;
15200         if (ret_var.is_owned) {
15201                 ret_ref |= 1;
15202         }
15203         return ret_ref;
15204 }
15205
15206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15207         LDKChannelAnnouncement orig_conv;
15208         orig_conv.inner = (void*)(orig & (~1));
15209         orig_conv.is_owned = false;
15210         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
15211         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15212         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15213         long ret_ref = (long)ret_var.inner;
15214         if (ret_var.is_owned) {
15215                 ret_ref |= 1;
15216         }
15217         return ret_ref;
15218 }
15219
15220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15221         LDKUnsignedChannelUpdate this_obj_conv;
15222         this_obj_conv.inner = (void*)(this_obj & (~1));
15223         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15224         UnsignedChannelUpdate_free(this_obj_conv);
15225 }
15226
15227 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15228         LDKUnsignedChannelUpdate this_ptr_conv;
15229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15230         this_ptr_conv.is_owned = false;
15231         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15232         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
15233         return ret_arr;
15234 }
15235
15236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15237         LDKUnsignedChannelUpdate this_ptr_conv;
15238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15239         this_ptr_conv.is_owned = false;
15240         LDKThirtyTwoBytes val_ref;
15241         CHECK((*env)->GetArrayLength(env, val) == 32);
15242         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15243         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
15244 }
15245
15246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15247         LDKUnsignedChannelUpdate this_ptr_conv;
15248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15249         this_ptr_conv.is_owned = false;
15250         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
15251         return ret_val;
15252 }
15253
15254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15255         LDKUnsignedChannelUpdate this_ptr_conv;
15256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15257         this_ptr_conv.is_owned = false;
15258         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
15259 }
15260
15261 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
15262         LDKUnsignedChannelUpdate this_ptr_conv;
15263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15264         this_ptr_conv.is_owned = false;
15265         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
15266         return ret_val;
15267 }
15268
15269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15270         LDKUnsignedChannelUpdate this_ptr_conv;
15271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15272         this_ptr_conv.is_owned = false;
15273         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
15274 }
15275
15276 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
15277         LDKUnsignedChannelUpdate this_ptr_conv;
15278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15279         this_ptr_conv.is_owned = false;
15280         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
15281         return ret_val;
15282 }
15283
15284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
15285         LDKUnsignedChannelUpdate this_ptr_conv;
15286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15287         this_ptr_conv.is_owned = false;
15288         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
15289 }
15290
15291 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
15292         LDKUnsignedChannelUpdate this_ptr_conv;
15293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15294         this_ptr_conv.is_owned = false;
15295         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
15296         return ret_val;
15297 }
15298
15299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15300         LDKUnsignedChannelUpdate this_ptr_conv;
15301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15302         this_ptr_conv.is_owned = false;
15303         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
15304 }
15305
15306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15307         LDKUnsignedChannelUpdate this_ptr_conv;
15308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15309         this_ptr_conv.is_owned = false;
15310         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
15311         return ret_val;
15312 }
15313
15314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15315         LDKUnsignedChannelUpdate this_ptr_conv;
15316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15317         this_ptr_conv.is_owned = false;
15318         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
15319 }
15320
15321 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15322         LDKUnsignedChannelUpdate this_ptr_conv;
15323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15324         this_ptr_conv.is_owned = false;
15325         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
15326         return ret_val;
15327 }
15328
15329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15330         LDKUnsignedChannelUpdate this_ptr_conv;
15331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15332         this_ptr_conv.is_owned = false;
15333         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
15334 }
15335
15336 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
15337         LDKUnsignedChannelUpdate this_ptr_conv;
15338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15339         this_ptr_conv.is_owned = false;
15340         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
15341         return ret_val;
15342 }
15343
15344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15345         LDKUnsignedChannelUpdate this_ptr_conv;
15346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15347         this_ptr_conv.is_owned = false;
15348         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
15349 }
15350
15351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15352         LDKUnsignedChannelUpdate orig_conv;
15353         orig_conv.inner = (void*)(orig & (~1));
15354         orig_conv.is_owned = false;
15355         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
15356         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15357         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15358         long ret_ref = (long)ret_var.inner;
15359         if (ret_var.is_owned) {
15360                 ret_ref |= 1;
15361         }
15362         return ret_ref;
15363 }
15364
15365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15366         LDKChannelUpdate this_obj_conv;
15367         this_obj_conv.inner = (void*)(this_obj & (~1));
15368         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15369         ChannelUpdate_free(this_obj_conv);
15370 }
15371
15372 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15373         LDKChannelUpdate this_ptr_conv;
15374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15375         this_ptr_conv.is_owned = false;
15376         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15377         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
15378         return ret_arr;
15379 }
15380
15381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15382         LDKChannelUpdate this_ptr_conv;
15383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15384         this_ptr_conv.is_owned = false;
15385         LDKSignature val_ref;
15386         CHECK((*env)->GetArrayLength(env, val) == 64);
15387         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15388         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
15389 }
15390
15391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
15392         LDKChannelUpdate this_ptr_conv;
15393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15394         this_ptr_conv.is_owned = false;
15395         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
15396         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15397         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15398         long ret_ref = (long)ret_var.inner;
15399         if (ret_var.is_owned) {
15400                 ret_ref |= 1;
15401         }
15402         return ret_ref;
15403 }
15404
15405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15406         LDKChannelUpdate this_ptr_conv;
15407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15408         this_ptr_conv.is_owned = false;
15409         LDKUnsignedChannelUpdate val_conv;
15410         val_conv.inner = (void*)(val & (~1));
15411         val_conv.is_owned = (val & 1) || (val == 0);
15412         val_conv = UnsignedChannelUpdate_clone(&val_conv);
15413         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
15414 }
15415
15416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
15417         LDKSignature signature_arg_ref;
15418         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
15419         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
15420         LDKUnsignedChannelUpdate contents_arg_conv;
15421         contents_arg_conv.inner = (void*)(contents_arg & (~1));
15422         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
15423         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
15424         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
15425         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15426         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15427         long ret_ref = (long)ret_var.inner;
15428         if (ret_var.is_owned) {
15429                 ret_ref |= 1;
15430         }
15431         return ret_ref;
15432 }
15433
15434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15435         LDKChannelUpdate orig_conv;
15436         orig_conv.inner = (void*)(orig & (~1));
15437         orig_conv.is_owned = false;
15438         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
15439         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15440         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15441         long ret_ref = (long)ret_var.inner;
15442         if (ret_var.is_owned) {
15443                 ret_ref |= 1;
15444         }
15445         return ret_ref;
15446 }
15447
15448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15449         LDKQueryChannelRange this_obj_conv;
15450         this_obj_conv.inner = (void*)(this_obj & (~1));
15451         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15452         QueryChannelRange_free(this_obj_conv);
15453 }
15454
15455 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15456         LDKQueryChannelRange this_ptr_conv;
15457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15458         this_ptr_conv.is_owned = false;
15459         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15460         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
15461         return ret_arr;
15462 }
15463
15464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15465         LDKQueryChannelRange this_ptr_conv;
15466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15467         this_ptr_conv.is_owned = false;
15468         LDKThirtyTwoBytes val_ref;
15469         CHECK((*env)->GetArrayLength(env, val) == 32);
15470         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15471         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
15472 }
15473
15474 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
15475         LDKQueryChannelRange this_ptr_conv;
15476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15477         this_ptr_conv.is_owned = false;
15478         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
15479         return ret_val;
15480 }
15481
15482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15483         LDKQueryChannelRange this_ptr_conv;
15484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15485         this_ptr_conv.is_owned = false;
15486         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
15487 }
15488
15489 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
15490         LDKQueryChannelRange this_ptr_conv;
15491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15492         this_ptr_conv.is_owned = false;
15493         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
15494         return ret_val;
15495 }
15496
15497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15498         LDKQueryChannelRange this_ptr_conv;
15499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15500         this_ptr_conv.is_owned = false;
15501         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
15502 }
15503
15504 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) {
15505         LDKThirtyTwoBytes chain_hash_arg_ref;
15506         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
15507         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
15508         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
15509         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15510         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15511         long ret_ref = (long)ret_var.inner;
15512         if (ret_var.is_owned) {
15513                 ret_ref |= 1;
15514         }
15515         return ret_ref;
15516 }
15517
15518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15519         LDKQueryChannelRange orig_conv;
15520         orig_conv.inner = (void*)(orig & (~1));
15521         orig_conv.is_owned = false;
15522         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
15523         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15524         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15525         long ret_ref = (long)ret_var.inner;
15526         if (ret_var.is_owned) {
15527                 ret_ref |= 1;
15528         }
15529         return ret_ref;
15530 }
15531
15532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15533         LDKReplyChannelRange this_obj_conv;
15534         this_obj_conv.inner = (void*)(this_obj & (~1));
15535         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15536         ReplyChannelRange_free(this_obj_conv);
15537 }
15538
15539 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15540         LDKReplyChannelRange this_ptr_conv;
15541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15542         this_ptr_conv.is_owned = false;
15543         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15544         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
15545         return ret_arr;
15546 }
15547
15548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15549         LDKReplyChannelRange this_ptr_conv;
15550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15551         this_ptr_conv.is_owned = false;
15552         LDKThirtyTwoBytes val_ref;
15553         CHECK((*env)->GetArrayLength(env, val) == 32);
15554         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15555         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
15556 }
15557
15558 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
15559         LDKReplyChannelRange this_ptr_conv;
15560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15561         this_ptr_conv.is_owned = false;
15562         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
15563         return ret_val;
15564 }
15565
15566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15567         LDKReplyChannelRange this_ptr_conv;
15568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15569         this_ptr_conv.is_owned = false;
15570         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
15571 }
15572
15573 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
15574         LDKReplyChannelRange this_ptr_conv;
15575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15576         this_ptr_conv.is_owned = false;
15577         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
15578         return ret_val;
15579 }
15580
15581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15582         LDKReplyChannelRange this_ptr_conv;
15583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15584         this_ptr_conv.is_owned = false;
15585         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
15586 }
15587
15588 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
15589         LDKReplyChannelRange this_ptr_conv;
15590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15591         this_ptr_conv.is_owned = false;
15592         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
15593         return ret_val;
15594 }
15595
15596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15597         LDKReplyChannelRange this_ptr_conv;
15598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15599         this_ptr_conv.is_owned = false;
15600         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
15601 }
15602
15603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
15604         LDKReplyChannelRange this_ptr_conv;
15605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15606         this_ptr_conv.is_owned = false;
15607         LDKCVec_u64Z val_constr;
15608         val_constr.datalen = (*env)->GetArrayLength(env, val);
15609         if (val_constr.datalen > 0)
15610                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15611         else
15612                 val_constr.data = NULL;
15613         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
15614         for (size_t g = 0; g < val_constr.datalen; g++) {
15615                 int64_t val_conv_6 = val_vals[g];
15616                 val_constr.data[g] = val_conv_6;
15617         }
15618         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
15619         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
15620 }
15621
15622 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) {
15623         LDKThirtyTwoBytes chain_hash_arg_ref;
15624         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
15625         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
15626         LDKCVec_u64Z short_channel_ids_arg_constr;
15627         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
15628         if (short_channel_ids_arg_constr.datalen > 0)
15629                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15630         else
15631                 short_channel_ids_arg_constr.data = NULL;
15632         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
15633         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
15634                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
15635                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
15636         }
15637         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
15638         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
15639         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15640         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15641         long ret_ref = (long)ret_var.inner;
15642         if (ret_var.is_owned) {
15643                 ret_ref |= 1;
15644         }
15645         return ret_ref;
15646 }
15647
15648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15649         LDKReplyChannelRange orig_conv;
15650         orig_conv.inner = (void*)(orig & (~1));
15651         orig_conv.is_owned = false;
15652         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
15653         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15654         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15655         long ret_ref = (long)ret_var.inner;
15656         if (ret_var.is_owned) {
15657                 ret_ref |= 1;
15658         }
15659         return ret_ref;
15660 }
15661
15662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15663         LDKQueryShortChannelIds this_obj_conv;
15664         this_obj_conv.inner = (void*)(this_obj & (~1));
15665         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15666         QueryShortChannelIds_free(this_obj_conv);
15667 }
15668
15669 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15670         LDKQueryShortChannelIds this_ptr_conv;
15671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15672         this_ptr_conv.is_owned = false;
15673         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15674         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
15675         return ret_arr;
15676 }
15677
15678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15679         LDKQueryShortChannelIds this_ptr_conv;
15680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15681         this_ptr_conv.is_owned = false;
15682         LDKThirtyTwoBytes val_ref;
15683         CHECK((*env)->GetArrayLength(env, val) == 32);
15684         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15685         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
15686 }
15687
15688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
15689         LDKQueryShortChannelIds this_ptr_conv;
15690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15691         this_ptr_conv.is_owned = false;
15692         LDKCVec_u64Z val_constr;
15693         val_constr.datalen = (*env)->GetArrayLength(env, val);
15694         if (val_constr.datalen > 0)
15695                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15696         else
15697                 val_constr.data = NULL;
15698         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
15699         for (size_t g = 0; g < val_constr.datalen; g++) {
15700                 int64_t val_conv_6 = val_vals[g];
15701                 val_constr.data[g] = val_conv_6;
15702         }
15703         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
15704         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
15705 }
15706
15707 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) {
15708         LDKThirtyTwoBytes chain_hash_arg_ref;
15709         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
15710         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
15711         LDKCVec_u64Z short_channel_ids_arg_constr;
15712         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
15713         if (short_channel_ids_arg_constr.datalen > 0)
15714                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15715         else
15716                 short_channel_ids_arg_constr.data = NULL;
15717         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
15718         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
15719                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
15720                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
15721         }
15722         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
15723         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
15724         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15725         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15726         long ret_ref = (long)ret_var.inner;
15727         if (ret_var.is_owned) {
15728                 ret_ref |= 1;
15729         }
15730         return ret_ref;
15731 }
15732
15733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15734         LDKQueryShortChannelIds orig_conv;
15735         orig_conv.inner = (void*)(orig & (~1));
15736         orig_conv.is_owned = false;
15737         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
15738         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15739         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15740         long ret_ref = (long)ret_var.inner;
15741         if (ret_var.is_owned) {
15742                 ret_ref |= 1;
15743         }
15744         return ret_ref;
15745 }
15746
15747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15748         LDKReplyShortChannelIdsEnd this_obj_conv;
15749         this_obj_conv.inner = (void*)(this_obj & (~1));
15750         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15751         ReplyShortChannelIdsEnd_free(this_obj_conv);
15752 }
15753
15754 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15755         LDKReplyShortChannelIdsEnd this_ptr_conv;
15756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15757         this_ptr_conv.is_owned = false;
15758         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15759         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
15760         return ret_arr;
15761 }
15762
15763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15764         LDKReplyShortChannelIdsEnd this_ptr_conv;
15765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15766         this_ptr_conv.is_owned = false;
15767         LDKThirtyTwoBytes val_ref;
15768         CHECK((*env)->GetArrayLength(env, val) == 32);
15769         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15770         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
15771 }
15772
15773 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
15774         LDKReplyShortChannelIdsEnd this_ptr_conv;
15775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15776         this_ptr_conv.is_owned = false;
15777         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
15778         return ret_val;
15779 }
15780
15781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15782         LDKReplyShortChannelIdsEnd this_ptr_conv;
15783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15784         this_ptr_conv.is_owned = false;
15785         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
15786 }
15787
15788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
15789         LDKThirtyTwoBytes chain_hash_arg_ref;
15790         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
15791         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
15792         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
15793         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15794         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15795         long ret_ref = (long)ret_var.inner;
15796         if (ret_var.is_owned) {
15797                 ret_ref |= 1;
15798         }
15799         return ret_ref;
15800 }
15801
15802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15803         LDKReplyShortChannelIdsEnd orig_conv;
15804         orig_conv.inner = (void*)(orig & (~1));
15805         orig_conv.is_owned = false;
15806         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
15807         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15808         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15809         long ret_ref = (long)ret_var.inner;
15810         if (ret_var.is_owned) {
15811                 ret_ref |= 1;
15812         }
15813         return ret_ref;
15814 }
15815
15816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15817         LDKGossipTimestampFilter this_obj_conv;
15818         this_obj_conv.inner = (void*)(this_obj & (~1));
15819         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15820         GossipTimestampFilter_free(this_obj_conv);
15821 }
15822
15823 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15824         LDKGossipTimestampFilter this_ptr_conv;
15825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15826         this_ptr_conv.is_owned = false;
15827         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15828         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
15829         return ret_arr;
15830 }
15831
15832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15833         LDKGossipTimestampFilter this_ptr_conv;
15834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15835         this_ptr_conv.is_owned = false;
15836         LDKThirtyTwoBytes val_ref;
15837         CHECK((*env)->GetArrayLength(env, val) == 32);
15838         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15839         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
15840 }
15841
15842 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
15843         LDKGossipTimestampFilter this_ptr_conv;
15844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15845         this_ptr_conv.is_owned = false;
15846         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
15847         return ret_val;
15848 }
15849
15850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15851         LDKGossipTimestampFilter this_ptr_conv;
15852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15853         this_ptr_conv.is_owned = false;
15854         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
15855 }
15856
15857 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
15858         LDKGossipTimestampFilter this_ptr_conv;
15859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15860         this_ptr_conv.is_owned = false;
15861         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
15862         return ret_val;
15863 }
15864
15865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15866         LDKGossipTimestampFilter this_ptr_conv;
15867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15868         this_ptr_conv.is_owned = false;
15869         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
15870 }
15871
15872 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) {
15873         LDKThirtyTwoBytes chain_hash_arg_ref;
15874         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
15875         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
15876         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
15877         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15878         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15879         long ret_ref = (long)ret_var.inner;
15880         if (ret_var.is_owned) {
15881                 ret_ref |= 1;
15882         }
15883         return ret_ref;
15884 }
15885
15886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15887         LDKGossipTimestampFilter orig_conv;
15888         orig_conv.inner = (void*)(orig & (~1));
15889         orig_conv.is_owned = false;
15890         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
15891         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15892         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15893         long ret_ref = (long)ret_var.inner;
15894         if (ret_var.is_owned) {
15895                 ret_ref |= 1;
15896         }
15897         return ret_ref;
15898 }
15899
15900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15901         if ((this_ptr & 1) != 0) return;
15902         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
15903         FREE((void*)this_ptr);
15904         ErrorAction_free(this_ptr_conv);
15905 }
15906
15907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15908         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
15909         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
15910         *ret_copy = ErrorAction_clone(orig_conv);
15911         long ret_ref = (long)ret_copy;
15912         return ret_ref;
15913 }
15914
15915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15916         LDKLightningError this_obj_conv;
15917         this_obj_conv.inner = (void*)(this_obj & (~1));
15918         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15919         LightningError_free(this_obj_conv);
15920 }
15921
15922 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
15923         LDKLightningError this_ptr_conv;
15924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15925         this_ptr_conv.is_owned = false;
15926         LDKStr _str = LightningError_get_err(&this_ptr_conv);
15927         jstring _conv = str_ref_to_java(env, _str.chars, _str.len);
15928         return _conv;
15929 }
15930
15931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15932         LDKLightningError this_ptr_conv;
15933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15934         this_ptr_conv.is_owned = false;
15935         LDKCVec_u8Z val_ref;
15936         val_ref.datalen = (*env)->GetArrayLength(env, val);
15937         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
15938         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
15939         LightningError_set_err(&this_ptr_conv, val_ref);
15940 }
15941
15942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
15943         LDKLightningError this_ptr_conv;
15944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15945         this_ptr_conv.is_owned = false;
15946         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
15947         *ret_copy = LightningError_get_action(&this_ptr_conv);
15948         long ret_ref = (long)ret_copy;
15949         return ret_ref;
15950 }
15951
15952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15953         LDKLightningError this_ptr_conv;
15954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15955         this_ptr_conv.is_owned = false;
15956         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
15957         FREE((void*)val);
15958         LightningError_set_action(&this_ptr_conv, val_conv);
15959 }
15960
15961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, int8_tArray err_arg, int64_t action_arg) {
15962         LDKCVec_u8Z err_arg_ref;
15963         err_arg_ref.datalen = (*env)->GetArrayLength(env, err_arg);
15964         err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
15965         (*env)->GetByteArrayRegion(env, err_arg, 0, err_arg_ref.datalen, err_arg_ref.data);
15966         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
15967         FREE((void*)action_arg);
15968         LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
15969         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15970         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15971         long ret_ref = (long)ret_var.inner;
15972         if (ret_var.is_owned) {
15973                 ret_ref |= 1;
15974         }
15975         return ret_ref;
15976 }
15977
15978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15979         LDKLightningError orig_conv;
15980         orig_conv.inner = (void*)(orig & (~1));
15981         orig_conv.is_owned = false;
15982         LDKLightningError ret_var = LightningError_clone(&orig_conv);
15983         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15984         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15985         long ret_ref = (long)ret_var.inner;
15986         if (ret_var.is_owned) {
15987                 ret_ref |= 1;
15988         }
15989         return ret_ref;
15990 }
15991
15992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15993         LDKCommitmentUpdate this_obj_conv;
15994         this_obj_conv.inner = (void*)(this_obj & (~1));
15995         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15996         CommitmentUpdate_free(this_obj_conv);
15997 }
15998
15999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16000         LDKCommitmentUpdate this_ptr_conv;
16001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16002         this_ptr_conv.is_owned = false;
16003         LDKCVec_UpdateAddHTLCZ val_constr;
16004         val_constr.datalen = (*env)->GetArrayLength(env, val);
16005         if (val_constr.datalen > 0)
16006                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
16007         else
16008                 val_constr.data = NULL;
16009         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16010         for (size_t p = 0; p < val_constr.datalen; p++) {
16011                 int64_t val_conv_15 = val_vals[p];
16012                 LDKUpdateAddHTLC val_conv_15_conv;
16013                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
16014                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
16015                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
16016                 val_constr.data[p] = val_conv_15_conv;
16017         }
16018         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16019         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
16020 }
16021
16022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16023         LDKCommitmentUpdate this_ptr_conv;
16024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16025         this_ptr_conv.is_owned = false;
16026         LDKCVec_UpdateFulfillHTLCZ val_constr;
16027         val_constr.datalen = (*env)->GetArrayLength(env, val);
16028         if (val_constr.datalen > 0)
16029                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
16030         else
16031                 val_constr.data = NULL;
16032         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16033         for (size_t t = 0; t < val_constr.datalen; t++) {
16034                 int64_t val_conv_19 = val_vals[t];
16035                 LDKUpdateFulfillHTLC val_conv_19_conv;
16036                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
16037                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
16038                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
16039                 val_constr.data[t] = val_conv_19_conv;
16040         }
16041         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16042         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
16043 }
16044
16045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16046         LDKCommitmentUpdate this_ptr_conv;
16047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16048         this_ptr_conv.is_owned = false;
16049         LDKCVec_UpdateFailHTLCZ val_constr;
16050         val_constr.datalen = (*env)->GetArrayLength(env, val);
16051         if (val_constr.datalen > 0)
16052                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
16053         else
16054                 val_constr.data = NULL;
16055         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16056         for (size_t q = 0; q < val_constr.datalen; q++) {
16057                 int64_t val_conv_16 = val_vals[q];
16058                 LDKUpdateFailHTLC val_conv_16_conv;
16059                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
16060                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
16061                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
16062                 val_constr.data[q] = val_conv_16_conv;
16063         }
16064         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16065         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
16066 }
16067
16068 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) {
16069         LDKCommitmentUpdate this_ptr_conv;
16070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16071         this_ptr_conv.is_owned = false;
16072         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
16073         val_constr.datalen = (*env)->GetArrayLength(env, val);
16074         if (val_constr.datalen > 0)
16075                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
16076         else
16077                 val_constr.data = NULL;
16078         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16079         for (size_t z = 0; z < val_constr.datalen; z++) {
16080                 int64_t val_conv_25 = val_vals[z];
16081                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
16082                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
16083                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
16084                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
16085                 val_constr.data[z] = val_conv_25_conv;
16086         }
16087         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16088         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
16089 }
16090
16091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
16092         LDKCommitmentUpdate this_ptr_conv;
16093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16094         this_ptr_conv.is_owned = false;
16095         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
16096         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16097         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16098         long ret_ref = (long)ret_var.inner;
16099         if (ret_var.is_owned) {
16100                 ret_ref |= 1;
16101         }
16102         return ret_ref;
16103 }
16104
16105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16106         LDKCommitmentUpdate this_ptr_conv;
16107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16108         this_ptr_conv.is_owned = false;
16109         LDKUpdateFee val_conv;
16110         val_conv.inner = (void*)(val & (~1));
16111         val_conv.is_owned = (val & 1) || (val == 0);
16112         val_conv = UpdateFee_clone(&val_conv);
16113         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
16114 }
16115
16116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
16117         LDKCommitmentUpdate this_ptr_conv;
16118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16119         this_ptr_conv.is_owned = false;
16120         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
16121         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16122         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16123         long ret_ref = (long)ret_var.inner;
16124         if (ret_var.is_owned) {
16125                 ret_ref |= 1;
16126         }
16127         return ret_ref;
16128 }
16129
16130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16131         LDKCommitmentUpdate this_ptr_conv;
16132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16133         this_ptr_conv.is_owned = false;
16134         LDKCommitmentSigned val_conv;
16135         val_conv.inner = (void*)(val & (~1));
16136         val_conv.is_owned = (val & 1) || (val == 0);
16137         val_conv = CommitmentSigned_clone(&val_conv);
16138         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
16139 }
16140
16141 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) {
16142         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
16143         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
16144         if (update_add_htlcs_arg_constr.datalen > 0)
16145                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
16146         else
16147                 update_add_htlcs_arg_constr.data = NULL;
16148         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
16149         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
16150                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
16151                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
16152                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
16153                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
16154                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
16155                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
16156         }
16157         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
16158         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
16159         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
16160         if (update_fulfill_htlcs_arg_constr.datalen > 0)
16161                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
16162         else
16163                 update_fulfill_htlcs_arg_constr.data = NULL;
16164         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
16165         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
16166                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
16167                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
16168                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
16169                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
16170                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
16171                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
16172         }
16173         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
16174         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
16175         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
16176         if (update_fail_htlcs_arg_constr.datalen > 0)
16177                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
16178         else
16179                 update_fail_htlcs_arg_constr.data = NULL;
16180         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
16181         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
16182                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
16183                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
16184                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
16185                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
16186                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
16187                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
16188         }
16189         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
16190         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
16191         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
16192         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
16193                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
16194         else
16195                 update_fail_malformed_htlcs_arg_constr.data = NULL;
16196         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
16197         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
16198                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
16199                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
16200                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
16201                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = (update_fail_malformed_htlcs_arg_conv_25 & 1) || (update_fail_malformed_htlcs_arg_conv_25 == 0);
16202                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
16203                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
16204         }
16205         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
16206         LDKUpdateFee update_fee_arg_conv;
16207         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
16208         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
16209         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
16210         LDKCommitmentSigned commitment_signed_arg_conv;
16211         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
16212         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
16213         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
16214         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);
16215         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16216         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16217         long ret_ref = (long)ret_var.inner;
16218         if (ret_var.is_owned) {
16219                 ret_ref |= 1;
16220         }
16221         return ret_ref;
16222 }
16223
16224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16225         LDKCommitmentUpdate orig_conv;
16226         orig_conv.inner = (void*)(orig & (~1));
16227         orig_conv.is_owned = false;
16228         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
16229         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16230         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16231         long ret_ref = (long)ret_var.inner;
16232         if (ret_var.is_owned) {
16233                 ret_ref |= 1;
16234         }
16235         return ret_ref;
16236 }
16237
16238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16239         if ((this_ptr & 1) != 0) return;
16240         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
16241         FREE((void*)this_ptr);
16242         HTLCFailChannelUpdate_free(this_ptr_conv);
16243 }
16244
16245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16246         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
16247         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
16248         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
16249         long ret_ref = (long)ret_copy;
16250         return ret_ref;
16251 }
16252
16253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16254         if ((this_ptr & 1) != 0) return;
16255         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
16256         FREE((void*)this_ptr);
16257         ChannelMessageHandler_free(this_ptr_conv);
16258 }
16259
16260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16261         if ((this_ptr & 1) != 0) return;
16262         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
16263         FREE((void*)this_ptr);
16264         RoutingMessageHandler_free(this_ptr_conv);
16265 }
16266
16267 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
16268         LDKAcceptChannel obj_conv;
16269         obj_conv.inner = (void*)(obj & (~1));
16270         obj_conv.is_owned = false;
16271         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
16272         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16273         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16274         CVec_u8Z_free(ret_var);
16275         return ret_arr;
16276 }
16277
16278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16279         LDKu8slice ser_ref;
16280         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16281         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16282         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
16283         *ret_conv = AcceptChannel_read(ser_ref);
16284         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16285         return (long)ret_conv;
16286 }
16287
16288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
16289         LDKAnnouncementSignatures obj_conv;
16290         obj_conv.inner = (void*)(obj & (~1));
16291         obj_conv.is_owned = false;
16292         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
16293         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16294         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16295         CVec_u8Z_free(ret_var);
16296         return ret_arr;
16297 }
16298
16299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16300         LDKu8slice ser_ref;
16301         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16302         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16303         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
16304         *ret_conv = AnnouncementSignatures_read(ser_ref);
16305         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16306         return (long)ret_conv;
16307 }
16308
16309 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
16310         LDKChannelReestablish obj_conv;
16311         obj_conv.inner = (void*)(obj & (~1));
16312         obj_conv.is_owned = false;
16313         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
16314         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16315         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16316         CVec_u8Z_free(ret_var);
16317         return ret_arr;
16318 }
16319
16320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16321         LDKu8slice ser_ref;
16322         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16323         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16324         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
16325         *ret_conv = ChannelReestablish_read(ser_ref);
16326         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16327         return (long)ret_conv;
16328 }
16329
16330 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
16331         LDKClosingSigned obj_conv;
16332         obj_conv.inner = (void*)(obj & (~1));
16333         obj_conv.is_owned = false;
16334         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
16335         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16336         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16337         CVec_u8Z_free(ret_var);
16338         return ret_arr;
16339 }
16340
16341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16342         LDKu8slice ser_ref;
16343         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16344         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16345         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
16346         *ret_conv = ClosingSigned_read(ser_ref);
16347         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16348         return (long)ret_conv;
16349 }
16350
16351 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
16352         LDKCommitmentSigned obj_conv;
16353         obj_conv.inner = (void*)(obj & (~1));
16354         obj_conv.is_owned = false;
16355         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
16356         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16357         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16358         CVec_u8Z_free(ret_var);
16359         return ret_arr;
16360 }
16361
16362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16363         LDKu8slice ser_ref;
16364         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16365         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16366         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
16367         *ret_conv = CommitmentSigned_read(ser_ref);
16368         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16369         return (long)ret_conv;
16370 }
16371
16372 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
16373         LDKFundingCreated obj_conv;
16374         obj_conv.inner = (void*)(obj & (~1));
16375         obj_conv.is_owned = false;
16376         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
16377         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16378         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16379         CVec_u8Z_free(ret_var);
16380         return ret_arr;
16381 }
16382
16383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16384         LDKu8slice ser_ref;
16385         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16386         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16387         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
16388         *ret_conv = FundingCreated_read(ser_ref);
16389         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16390         return (long)ret_conv;
16391 }
16392
16393 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
16394         LDKFundingSigned obj_conv;
16395         obj_conv.inner = (void*)(obj & (~1));
16396         obj_conv.is_owned = false;
16397         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
16398         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16399         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16400         CVec_u8Z_free(ret_var);
16401         return ret_arr;
16402 }
16403
16404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16405         LDKu8slice ser_ref;
16406         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16407         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16408         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
16409         *ret_conv = FundingSigned_read(ser_ref);
16410         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16411         return (long)ret_conv;
16412 }
16413
16414 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
16415         LDKFundingLocked obj_conv;
16416         obj_conv.inner = (void*)(obj & (~1));
16417         obj_conv.is_owned = false;
16418         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
16419         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16420         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16421         CVec_u8Z_free(ret_var);
16422         return ret_arr;
16423 }
16424
16425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16426         LDKu8slice ser_ref;
16427         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16428         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16429         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
16430         *ret_conv = FundingLocked_read(ser_ref);
16431         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16432         return (long)ret_conv;
16433 }
16434
16435 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
16436         LDKInit obj_conv;
16437         obj_conv.inner = (void*)(obj & (~1));
16438         obj_conv.is_owned = false;
16439         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
16440         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16441         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16442         CVec_u8Z_free(ret_var);
16443         return ret_arr;
16444 }
16445
16446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16447         LDKu8slice ser_ref;
16448         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16449         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16450         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
16451         *ret_conv = Init_read(ser_ref);
16452         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16453         return (long)ret_conv;
16454 }
16455
16456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
16457         LDKOpenChannel obj_conv;
16458         obj_conv.inner = (void*)(obj & (~1));
16459         obj_conv.is_owned = false;
16460         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
16461         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16462         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16463         CVec_u8Z_free(ret_var);
16464         return ret_arr;
16465 }
16466
16467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16468         LDKu8slice ser_ref;
16469         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16470         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16471         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
16472         *ret_conv = OpenChannel_read(ser_ref);
16473         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16474         return (long)ret_conv;
16475 }
16476
16477 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
16478         LDKRevokeAndACK obj_conv;
16479         obj_conv.inner = (void*)(obj & (~1));
16480         obj_conv.is_owned = false;
16481         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
16482         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16483         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16484         CVec_u8Z_free(ret_var);
16485         return ret_arr;
16486 }
16487
16488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16489         LDKu8slice ser_ref;
16490         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16491         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16492         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
16493         *ret_conv = RevokeAndACK_read(ser_ref);
16494         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16495         return (long)ret_conv;
16496 }
16497
16498 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
16499         LDKShutdown obj_conv;
16500         obj_conv.inner = (void*)(obj & (~1));
16501         obj_conv.is_owned = false;
16502         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
16503         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16504         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16505         CVec_u8Z_free(ret_var);
16506         return ret_arr;
16507 }
16508
16509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16510         LDKu8slice ser_ref;
16511         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16512         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16513         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
16514         *ret_conv = Shutdown_read(ser_ref);
16515         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16516         return (long)ret_conv;
16517 }
16518
16519 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
16520         LDKUpdateFailHTLC obj_conv;
16521         obj_conv.inner = (void*)(obj & (~1));
16522         obj_conv.is_owned = false;
16523         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
16524         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16525         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16526         CVec_u8Z_free(ret_var);
16527         return ret_arr;
16528 }
16529
16530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16531         LDKu8slice ser_ref;
16532         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16533         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16534         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
16535         *ret_conv = UpdateFailHTLC_read(ser_ref);
16536         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16537         return (long)ret_conv;
16538 }
16539
16540 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
16541         LDKUpdateFailMalformedHTLC obj_conv;
16542         obj_conv.inner = (void*)(obj & (~1));
16543         obj_conv.is_owned = false;
16544         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
16545         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16546         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16547         CVec_u8Z_free(ret_var);
16548         return ret_arr;
16549 }
16550
16551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16552         LDKu8slice ser_ref;
16553         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16554         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16555         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
16556         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
16557         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16558         return (long)ret_conv;
16559 }
16560
16561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
16562         LDKUpdateFee obj_conv;
16563         obj_conv.inner = (void*)(obj & (~1));
16564         obj_conv.is_owned = false;
16565         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
16566         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16567         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16568         CVec_u8Z_free(ret_var);
16569         return ret_arr;
16570 }
16571
16572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16573         LDKu8slice ser_ref;
16574         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16575         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16576         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
16577         *ret_conv = UpdateFee_read(ser_ref);
16578         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16579         return (long)ret_conv;
16580 }
16581
16582 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
16583         LDKUpdateFulfillHTLC obj_conv;
16584         obj_conv.inner = (void*)(obj & (~1));
16585         obj_conv.is_owned = false;
16586         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
16587         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16588         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16589         CVec_u8Z_free(ret_var);
16590         return ret_arr;
16591 }
16592
16593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16594         LDKu8slice ser_ref;
16595         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16596         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16597         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
16598         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
16599         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16600         return (long)ret_conv;
16601 }
16602
16603 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
16604         LDKUpdateAddHTLC obj_conv;
16605         obj_conv.inner = (void*)(obj & (~1));
16606         obj_conv.is_owned = false;
16607         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
16608         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16609         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16610         CVec_u8Z_free(ret_var);
16611         return ret_arr;
16612 }
16613
16614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16615         LDKu8slice ser_ref;
16616         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16617         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16618         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
16619         *ret_conv = UpdateAddHTLC_read(ser_ref);
16620         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16621         return (long)ret_conv;
16622 }
16623
16624 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
16625         LDKPing obj_conv;
16626         obj_conv.inner = (void*)(obj & (~1));
16627         obj_conv.is_owned = false;
16628         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
16629         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16630         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16631         CVec_u8Z_free(ret_var);
16632         return ret_arr;
16633 }
16634
16635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16636         LDKu8slice ser_ref;
16637         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16638         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16639         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
16640         *ret_conv = Ping_read(ser_ref);
16641         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16642         return (long)ret_conv;
16643 }
16644
16645 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
16646         LDKPong obj_conv;
16647         obj_conv.inner = (void*)(obj & (~1));
16648         obj_conv.is_owned = false;
16649         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
16650         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16651         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16652         CVec_u8Z_free(ret_var);
16653         return ret_arr;
16654 }
16655
16656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16657         LDKu8slice ser_ref;
16658         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16659         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16660         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
16661         *ret_conv = Pong_read(ser_ref);
16662         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16663         return (long)ret_conv;
16664 }
16665
16666 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
16667         LDKUnsignedChannelAnnouncement obj_conv;
16668         obj_conv.inner = (void*)(obj & (~1));
16669         obj_conv.is_owned = false;
16670         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
16671         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16672         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16673         CVec_u8Z_free(ret_var);
16674         return ret_arr;
16675 }
16676
16677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16678         LDKu8slice ser_ref;
16679         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16680         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16681         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
16682         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
16683         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16684         return (long)ret_conv;
16685 }
16686
16687 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
16688         LDKChannelAnnouncement obj_conv;
16689         obj_conv.inner = (void*)(obj & (~1));
16690         obj_conv.is_owned = false;
16691         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
16692         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16693         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16694         CVec_u8Z_free(ret_var);
16695         return ret_arr;
16696 }
16697
16698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16699         LDKu8slice ser_ref;
16700         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16701         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16702         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
16703         *ret_conv = ChannelAnnouncement_read(ser_ref);
16704         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16705         return (long)ret_conv;
16706 }
16707
16708 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
16709         LDKUnsignedChannelUpdate obj_conv;
16710         obj_conv.inner = (void*)(obj & (~1));
16711         obj_conv.is_owned = false;
16712         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
16713         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16714         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16715         CVec_u8Z_free(ret_var);
16716         return ret_arr;
16717 }
16718
16719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16720         LDKu8slice ser_ref;
16721         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16722         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16723         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
16724         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
16725         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16726         return (long)ret_conv;
16727 }
16728
16729 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
16730         LDKChannelUpdate obj_conv;
16731         obj_conv.inner = (void*)(obj & (~1));
16732         obj_conv.is_owned = false;
16733         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
16734         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16735         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16736         CVec_u8Z_free(ret_var);
16737         return ret_arr;
16738 }
16739
16740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16741         LDKu8slice ser_ref;
16742         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16743         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16744         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
16745         *ret_conv = ChannelUpdate_read(ser_ref);
16746         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16747         return (long)ret_conv;
16748 }
16749
16750 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
16751         LDKErrorMessage obj_conv;
16752         obj_conv.inner = (void*)(obj & (~1));
16753         obj_conv.is_owned = false;
16754         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
16755         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16756         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16757         CVec_u8Z_free(ret_var);
16758         return ret_arr;
16759 }
16760
16761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16762         LDKu8slice ser_ref;
16763         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16764         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16765         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
16766         *ret_conv = ErrorMessage_read(ser_ref);
16767         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16768         return (long)ret_conv;
16769 }
16770
16771 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
16772         LDKUnsignedNodeAnnouncement obj_conv;
16773         obj_conv.inner = (void*)(obj & (~1));
16774         obj_conv.is_owned = false;
16775         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
16776         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16777         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16778         CVec_u8Z_free(ret_var);
16779         return ret_arr;
16780 }
16781
16782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16783         LDKu8slice ser_ref;
16784         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16785         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16786         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
16787         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
16788         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16789         return (long)ret_conv;
16790 }
16791
16792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
16793         LDKNodeAnnouncement obj_conv;
16794         obj_conv.inner = (void*)(obj & (~1));
16795         obj_conv.is_owned = false;
16796         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
16797         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16798         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16799         CVec_u8Z_free(ret_var);
16800         return ret_arr;
16801 }
16802
16803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16804         LDKu8slice ser_ref;
16805         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16806         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16807         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
16808         *ret_conv = NodeAnnouncement_read(ser_ref);
16809         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16810         return (long)ret_conv;
16811 }
16812
16813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16814         LDKu8slice ser_ref;
16815         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16816         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16817         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
16818         *ret_conv = QueryShortChannelIds_read(ser_ref);
16819         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16820         return (long)ret_conv;
16821 }
16822
16823 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
16824         LDKQueryShortChannelIds obj_conv;
16825         obj_conv.inner = (void*)(obj & (~1));
16826         obj_conv.is_owned = false;
16827         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
16828         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16829         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16830         CVec_u8Z_free(ret_var);
16831         return ret_arr;
16832 }
16833
16834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16835         LDKu8slice ser_ref;
16836         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16837         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16838         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
16839         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
16840         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16841         return (long)ret_conv;
16842 }
16843
16844 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
16845         LDKReplyShortChannelIdsEnd obj_conv;
16846         obj_conv.inner = (void*)(obj & (~1));
16847         obj_conv.is_owned = false;
16848         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
16849         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16850         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16851         CVec_u8Z_free(ret_var);
16852         return ret_arr;
16853 }
16854
16855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16856         LDKu8slice ser_ref;
16857         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16858         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16859         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
16860         *ret_conv = QueryChannelRange_read(ser_ref);
16861         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16862         return (long)ret_conv;
16863 }
16864
16865 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
16866         LDKQueryChannelRange obj_conv;
16867         obj_conv.inner = (void*)(obj & (~1));
16868         obj_conv.is_owned = false;
16869         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
16870         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16871         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16872         CVec_u8Z_free(ret_var);
16873         return ret_arr;
16874 }
16875
16876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16877         LDKu8slice ser_ref;
16878         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16879         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16880         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
16881         *ret_conv = ReplyChannelRange_read(ser_ref);
16882         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16883         return (long)ret_conv;
16884 }
16885
16886 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
16887         LDKReplyChannelRange obj_conv;
16888         obj_conv.inner = (void*)(obj & (~1));
16889         obj_conv.is_owned = false;
16890         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
16891         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16892         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16893         CVec_u8Z_free(ret_var);
16894         return ret_arr;
16895 }
16896
16897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16898         LDKu8slice ser_ref;
16899         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16900         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16901         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
16902         *ret_conv = GossipTimestampFilter_read(ser_ref);
16903         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16904         return (long)ret_conv;
16905 }
16906
16907 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
16908         LDKGossipTimestampFilter obj_conv;
16909         obj_conv.inner = (void*)(obj & (~1));
16910         obj_conv.is_owned = false;
16911         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
16912         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16913         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16914         CVec_u8Z_free(ret_var);
16915         return ret_arr;
16916 }
16917
16918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16919         LDKIgnoringMessageHandler this_obj_conv;
16920         this_obj_conv.inner = (void*)(this_obj & (~1));
16921         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16922         IgnoringMessageHandler_free(this_obj_conv);
16923 }
16924
16925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
16926         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
16927         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16928         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16929         long ret_ref = (long)ret_var.inner;
16930         if (ret_var.is_owned) {
16931                 ret_ref |= 1;
16932         }
16933         return ret_ref;
16934 }
16935
16936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
16937         LDKIgnoringMessageHandler this_arg_conv;
16938         this_arg_conv.inner = (void*)(this_arg & (~1));
16939         this_arg_conv.is_owned = false;
16940         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
16941         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
16942         return (long)ret;
16943 }
16944
16945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
16946         LDKIgnoringMessageHandler this_arg_conv;
16947         this_arg_conv.inner = (void*)(this_arg & (~1));
16948         this_arg_conv.is_owned = false;
16949         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
16950         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
16951         return (long)ret;
16952 }
16953
16954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16955         LDKErroringMessageHandler this_obj_conv;
16956         this_obj_conv.inner = (void*)(this_obj & (~1));
16957         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16958         ErroringMessageHandler_free(this_obj_conv);
16959 }
16960
16961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
16962         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
16963         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16964         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16965         long ret_ref = (long)ret_var.inner;
16966         if (ret_var.is_owned) {
16967                 ret_ref |= 1;
16968         }
16969         return ret_ref;
16970 }
16971
16972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
16973         LDKErroringMessageHandler this_arg_conv;
16974         this_arg_conv.inner = (void*)(this_arg & (~1));
16975         this_arg_conv.is_owned = false;
16976         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
16977         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
16978         return (long)ret;
16979 }
16980
16981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
16982         LDKErroringMessageHandler this_arg_conv;
16983         this_arg_conv.inner = (void*)(this_arg & (~1));
16984         this_arg_conv.is_owned = false;
16985         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
16986         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
16987         return (long)ret;
16988 }
16989
16990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16991         LDKMessageHandler this_obj_conv;
16992         this_obj_conv.inner = (void*)(this_obj & (~1));
16993         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16994         MessageHandler_free(this_obj_conv);
16995 }
16996
16997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
16998         LDKMessageHandler this_ptr_conv;
16999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17000         this_ptr_conv.is_owned = false;
17001         long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
17002         return ret_ret;
17003 }
17004
17005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17006         LDKMessageHandler this_ptr_conv;
17007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17008         this_ptr_conv.is_owned = false;
17009         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
17010         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
17011                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17012                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
17013         }
17014         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
17015 }
17016
17017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
17018         LDKMessageHandler this_ptr_conv;
17019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17020         this_ptr_conv.is_owned = false;
17021         long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
17022         return ret_ret;
17023 }
17024
17025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17026         LDKMessageHandler this_ptr_conv;
17027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17028         this_ptr_conv.is_owned = false;
17029         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
17030         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
17031                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17032                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
17033         }
17034         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
17035 }
17036
17037 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) {
17038         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
17039         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
17040                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17041                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
17042         }
17043         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
17044         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
17045                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17046                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
17047         }
17048         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
17049         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17050         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17051         long ret_ref = (long)ret_var.inner;
17052         if (ret_var.is_owned) {
17053                 ret_ref |= 1;
17054         }
17055         return ret_ref;
17056 }
17057
17058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17059         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
17060         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
17061         *ret = SocketDescriptor_clone(orig_conv);
17062         return (long)ret;
17063 }
17064
17065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17066         if ((this_ptr & 1) != 0) return;
17067         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
17068         FREE((void*)this_ptr);
17069         SocketDescriptor_free(this_ptr_conv);
17070 }
17071
17072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17073         LDKPeerHandleError this_obj_conv;
17074         this_obj_conv.inner = (void*)(this_obj & (~1));
17075         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17076         PeerHandleError_free(this_obj_conv);
17077 }
17078
17079 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
17080         LDKPeerHandleError this_ptr_conv;
17081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17082         this_ptr_conv.is_owned = false;
17083         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
17084         return ret_val;
17085 }
17086
17087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
17088         LDKPeerHandleError this_ptr_conv;
17089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17090         this_ptr_conv.is_owned = false;
17091         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
17092 }
17093
17094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
17095         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
17096         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17097         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17098         long ret_ref = (long)ret_var.inner;
17099         if (ret_var.is_owned) {
17100                 ret_ref |= 1;
17101         }
17102         return ret_ref;
17103 }
17104
17105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17106         LDKPeerHandleError orig_conv;
17107         orig_conv.inner = (void*)(orig & (~1));
17108         orig_conv.is_owned = false;
17109         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
17110         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17111         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17112         long ret_ref = (long)ret_var.inner;
17113         if (ret_var.is_owned) {
17114                 ret_ref |= 1;
17115         }
17116         return ret_ref;
17117 }
17118
17119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17120         LDKPeerManager this_obj_conv;
17121         this_obj_conv.inner = (void*)(this_obj & (~1));
17122         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17123         PeerManager_free(this_obj_conv);
17124 }
17125
17126 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) {
17127         LDKMessageHandler message_handler_conv;
17128         message_handler_conv.inner = (void*)(message_handler & (~1));
17129         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
17130         // Warning: we need a move here but no clone is available for LDKMessageHandler
17131         LDKSecretKey our_node_secret_ref;
17132         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
17133         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
17134         unsigned char ephemeral_random_data_arr[32];
17135         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
17136         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
17137         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
17138         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17139         if (logger_conv.free == LDKLogger_JCalls_free) {
17140                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17141                 LDKLogger_JCalls_clone(logger_conv.this_arg);
17142         }
17143         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
17144         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17145         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17146         long ret_ref = (long)ret_var.inner;
17147         if (ret_var.is_owned) {
17148                 ret_ref |= 1;
17149         }
17150         return ret_ref;
17151 }
17152
17153 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
17154         LDKPeerManager this_arg_conv;
17155         this_arg_conv.inner = (void*)(this_arg & (~1));
17156         this_arg_conv.is_owned = false;
17157         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
17158         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
17159         ;
17160         for (size_t i = 0; i < ret_var.datalen; i++) {
17161                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
17162                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
17163                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
17164         }
17165         FREE(ret_var.data);
17166         return ret_arr;
17167 }
17168
17169 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) {
17170         LDKPeerManager this_arg_conv;
17171         this_arg_conv.inner = (void*)(this_arg & (~1));
17172         this_arg_conv.is_owned = false;
17173         LDKPublicKey their_node_id_ref;
17174         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
17175         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
17176         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
17177         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
17178                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17179                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
17180         }
17181         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
17182         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
17183         return (long)ret_conv;
17184 }
17185
17186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
17187         LDKPeerManager this_arg_conv;
17188         this_arg_conv.inner = (void*)(this_arg & (~1));
17189         this_arg_conv.is_owned = false;
17190         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
17191         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
17192                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17193                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
17194         }
17195         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
17196         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
17197         return (long)ret_conv;
17198 }
17199
17200 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) {
17201         LDKPeerManager this_arg_conv;
17202         this_arg_conv.inner = (void*)(this_arg & (~1));
17203         this_arg_conv.is_owned = false;
17204         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
17205         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
17206         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
17207         return (long)ret_conv;
17208 }
17209
17210 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) {
17211         LDKPeerManager this_arg_conv;
17212         this_arg_conv.inner = (void*)(this_arg & (~1));
17213         this_arg_conv.is_owned = false;
17214         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
17215         LDKu8slice data_ref;
17216         data_ref.datalen = (*env)->GetArrayLength(env, data);
17217         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
17218         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
17219         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
17220         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
17221         return (long)ret_conv;
17222 }
17223
17224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
17225         LDKPeerManager this_arg_conv;
17226         this_arg_conv.inner = (void*)(this_arg & (~1));
17227         this_arg_conv.is_owned = false;
17228         PeerManager_process_events(&this_arg_conv);
17229 }
17230
17231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
17232         LDKPeerManager this_arg_conv;
17233         this_arg_conv.inner = (void*)(this_arg & (~1));
17234         this_arg_conv.is_owned = false;
17235         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
17236         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
17237 }
17238
17239 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) {
17240         LDKPeerManager this_arg_conv;
17241         this_arg_conv.inner = (void*)(this_arg & (~1));
17242         this_arg_conv.is_owned = false;
17243         LDKPublicKey node_id_ref;
17244         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17245         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17246         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
17247 }
17248
17249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occured(JNIEnv *env, jclass clz, int64_t this_arg) {
17250         LDKPeerManager this_arg_conv;
17251         this_arg_conv.inner = (void*)(this_arg & (~1));
17252         this_arg_conv.is_owned = false;
17253         PeerManager_timer_tick_occured(&this_arg_conv);
17254 }
17255
17256 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
17257         unsigned char commitment_seed_arr[32];
17258         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
17259         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
17260         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
17261         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17262         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
17263         return ret_arr;
17264 }
17265
17266 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) {
17267         LDKPublicKey per_commitment_point_ref;
17268         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
17269         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17270         unsigned char base_secret_arr[32];
17271         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
17272         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
17273         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
17274         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
17275         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
17276         return (long)ret_conv;
17277 }
17278
17279 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) {
17280         LDKPublicKey per_commitment_point_ref;
17281         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
17282         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17283         LDKPublicKey base_point_ref;
17284         CHECK((*env)->GetArrayLength(env, base_point) == 33);
17285         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
17286         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
17287         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
17288         return (long)ret_conv;
17289 }
17290
17291 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) {
17292         unsigned char per_commitment_secret_arr[32];
17293         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
17294         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
17295         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
17296         unsigned char countersignatory_revocation_base_secret_arr[32];
17297         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
17298         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
17299         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
17300         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
17301         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
17302         return (long)ret_conv;
17303 }
17304
17305 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) {
17306         LDKPublicKey per_commitment_point_ref;
17307         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
17308         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17309         LDKPublicKey countersignatory_revocation_base_point_ref;
17310         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
17311         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
17312         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
17313         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
17314         return (long)ret_conv;
17315 }
17316
17317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17318         LDKTxCreationKeys this_obj_conv;
17319         this_obj_conv.inner = (void*)(this_obj & (~1));
17320         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17321         TxCreationKeys_free(this_obj_conv);
17322 }
17323
17324 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17325         LDKTxCreationKeys this_ptr_conv;
17326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17327         this_ptr_conv.is_owned = false;
17328         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17329         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
17330         return ret_arr;
17331 }
17332
17333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17334         LDKTxCreationKeys this_ptr_conv;
17335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17336         this_ptr_conv.is_owned = false;
17337         LDKPublicKey val_ref;
17338         CHECK((*env)->GetArrayLength(env, val) == 33);
17339         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17340         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
17341 }
17342
17343 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17344         LDKTxCreationKeys this_ptr_conv;
17345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17346         this_ptr_conv.is_owned = false;
17347         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17348         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
17349         return ret_arr;
17350 }
17351
17352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17353         LDKTxCreationKeys this_ptr_conv;
17354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17355         this_ptr_conv.is_owned = false;
17356         LDKPublicKey val_ref;
17357         CHECK((*env)->GetArrayLength(env, val) == 33);
17358         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17359         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
17360 }
17361
17362 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17363         LDKTxCreationKeys this_ptr_conv;
17364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17365         this_ptr_conv.is_owned = false;
17366         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17367         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
17368         return ret_arr;
17369 }
17370
17371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17372         LDKTxCreationKeys this_ptr_conv;
17373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17374         this_ptr_conv.is_owned = false;
17375         LDKPublicKey val_ref;
17376         CHECK((*env)->GetArrayLength(env, val) == 33);
17377         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17378         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
17379 }
17380
17381 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17382         LDKTxCreationKeys this_ptr_conv;
17383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17384         this_ptr_conv.is_owned = false;
17385         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17386         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
17387         return ret_arr;
17388 }
17389
17390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17391         LDKTxCreationKeys this_ptr_conv;
17392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17393         this_ptr_conv.is_owned = false;
17394         LDKPublicKey val_ref;
17395         CHECK((*env)->GetArrayLength(env, val) == 33);
17396         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17397         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
17398 }
17399
17400 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17401         LDKTxCreationKeys this_ptr_conv;
17402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17403         this_ptr_conv.is_owned = false;
17404         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17405         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
17406         return ret_arr;
17407 }
17408
17409 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) {
17410         LDKTxCreationKeys this_ptr_conv;
17411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17412         this_ptr_conv.is_owned = false;
17413         LDKPublicKey val_ref;
17414         CHECK((*env)->GetArrayLength(env, val) == 33);
17415         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17416         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
17417 }
17418
17419 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) {
17420         LDKPublicKey per_commitment_point_arg_ref;
17421         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
17422         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
17423         LDKPublicKey revocation_key_arg_ref;
17424         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
17425         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
17426         LDKPublicKey broadcaster_htlc_key_arg_ref;
17427         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
17428         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
17429         LDKPublicKey countersignatory_htlc_key_arg_ref;
17430         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
17431         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
17432         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
17433         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
17434         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
17435         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);
17436         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17437         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17438         long ret_ref = (long)ret_var.inner;
17439         if (ret_var.is_owned) {
17440                 ret_ref |= 1;
17441         }
17442         return ret_ref;
17443 }
17444
17445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17446         LDKTxCreationKeys orig_conv;
17447         orig_conv.inner = (void*)(orig & (~1));
17448         orig_conv.is_owned = false;
17449         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
17450         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17451         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17452         long ret_ref = (long)ret_var.inner;
17453         if (ret_var.is_owned) {
17454                 ret_ref |= 1;
17455         }
17456         return ret_ref;
17457 }
17458
17459 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
17460         LDKTxCreationKeys obj_conv;
17461         obj_conv.inner = (void*)(obj & (~1));
17462         obj_conv.is_owned = false;
17463         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
17464         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17465         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17466         CVec_u8Z_free(ret_var);
17467         return ret_arr;
17468 }
17469
17470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17471         LDKu8slice ser_ref;
17472         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17473         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17474         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
17475         *ret_conv = TxCreationKeys_read(ser_ref);
17476         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17477         return (long)ret_conv;
17478 }
17479
17480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17481         LDKChannelPublicKeys this_obj_conv;
17482         this_obj_conv.inner = (void*)(this_obj & (~1));
17483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17484         ChannelPublicKeys_free(this_obj_conv);
17485 }
17486
17487 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17488         LDKChannelPublicKeys this_ptr_conv;
17489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17490         this_ptr_conv.is_owned = false;
17491         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17492         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
17493         return ret_arr;
17494 }
17495
17496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17497         LDKChannelPublicKeys this_ptr_conv;
17498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17499         this_ptr_conv.is_owned = false;
17500         LDKPublicKey val_ref;
17501         CHECK((*env)->GetArrayLength(env, val) == 33);
17502         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17503         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
17504 }
17505
17506 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17507         LDKChannelPublicKeys this_ptr_conv;
17508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17509         this_ptr_conv.is_owned = false;
17510         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17511         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
17512         return ret_arr;
17513 }
17514
17515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17516         LDKChannelPublicKeys this_ptr_conv;
17517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17518         this_ptr_conv.is_owned = false;
17519         LDKPublicKey val_ref;
17520         CHECK((*env)->GetArrayLength(env, val) == 33);
17521         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17522         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
17523 }
17524
17525 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17526         LDKChannelPublicKeys this_ptr_conv;
17527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17528         this_ptr_conv.is_owned = false;
17529         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17530         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
17531         return ret_arr;
17532 }
17533
17534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17535         LDKChannelPublicKeys this_ptr_conv;
17536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17537         this_ptr_conv.is_owned = false;
17538         LDKPublicKey val_ref;
17539         CHECK((*env)->GetArrayLength(env, val) == 33);
17540         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17541         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
17542 }
17543
17544 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17545         LDKChannelPublicKeys this_ptr_conv;
17546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17547         this_ptr_conv.is_owned = false;
17548         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17549         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
17550         return ret_arr;
17551 }
17552
17553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17554         LDKChannelPublicKeys this_ptr_conv;
17555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17556         this_ptr_conv.is_owned = false;
17557         LDKPublicKey val_ref;
17558         CHECK((*env)->GetArrayLength(env, val) == 33);
17559         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17560         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17561 }
17562
17563 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17564         LDKChannelPublicKeys this_ptr_conv;
17565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17566         this_ptr_conv.is_owned = false;
17567         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17568         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
17569         return ret_arr;
17570 }
17571
17572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17573         LDKChannelPublicKeys this_ptr_conv;
17574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17575         this_ptr_conv.is_owned = false;
17576         LDKPublicKey val_ref;
17577         CHECK((*env)->GetArrayLength(env, val) == 33);
17578         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17579         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
17580 }
17581
17582 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) {
17583         LDKPublicKey funding_pubkey_arg_ref;
17584         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
17585         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
17586         LDKPublicKey revocation_basepoint_arg_ref;
17587         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
17588         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
17589         LDKPublicKey payment_point_arg_ref;
17590         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
17591         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
17592         LDKPublicKey delayed_payment_basepoint_arg_ref;
17593         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
17594         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
17595         LDKPublicKey htlc_basepoint_arg_ref;
17596         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
17597         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
17598         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);
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 int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17609         LDKChannelPublicKeys orig_conv;
17610         orig_conv.inner = (void*)(orig & (~1));
17611         orig_conv.is_owned = false;
17612         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
17613         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17614         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17615         long ret_ref = (long)ret_var.inner;
17616         if (ret_var.is_owned) {
17617                 ret_ref |= 1;
17618         }
17619         return ret_ref;
17620 }
17621
17622 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
17623         LDKChannelPublicKeys obj_conv;
17624         obj_conv.inner = (void*)(obj & (~1));
17625         obj_conv.is_owned = false;
17626         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
17627         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17628         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17629         CVec_u8Z_free(ret_var);
17630         return ret_arr;
17631 }
17632
17633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17634         LDKu8slice ser_ref;
17635         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17636         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17637         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
17638         *ret_conv = ChannelPublicKeys_read(ser_ref);
17639         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17640         return (long)ret_conv;
17641 }
17642
17643 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) {
17644         LDKPublicKey per_commitment_point_ref;
17645         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
17646         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17647         LDKPublicKey broadcaster_delayed_payment_base_ref;
17648         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
17649         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
17650         LDKPublicKey broadcaster_htlc_base_ref;
17651         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
17652         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
17653         LDKPublicKey countersignatory_revocation_base_ref;
17654         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
17655         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
17656         LDKPublicKey countersignatory_htlc_base_ref;
17657         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
17658         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
17659         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
17660         *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);
17661         return (long)ret_conv;
17662 }
17663
17664 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) {
17665         LDKPublicKey per_commitment_point_ref;
17666         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
17667         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17668         LDKChannelPublicKeys broadcaster_keys_conv;
17669         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
17670         broadcaster_keys_conv.is_owned = false;
17671         LDKChannelPublicKeys countersignatory_keys_conv;
17672         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
17673         countersignatory_keys_conv.is_owned = false;
17674         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
17675         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
17676         return (long)ret_conv;
17677 }
17678
17679 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) {
17680         LDKPublicKey revocation_key_ref;
17681         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
17682         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
17683         LDKPublicKey broadcaster_delayed_payment_key_ref;
17684         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
17685         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
17686         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
17687         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17688         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17689         CVec_u8Z_free(ret_var);
17690         return ret_arr;
17691 }
17692
17693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17694         LDKHTLCOutputInCommitment this_obj_conv;
17695         this_obj_conv.inner = (void*)(this_obj & (~1));
17696         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17697         HTLCOutputInCommitment_free(this_obj_conv);
17698 }
17699
17700 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
17701         LDKHTLCOutputInCommitment this_ptr_conv;
17702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17703         this_ptr_conv.is_owned = false;
17704         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
17705         return ret_val;
17706 }
17707
17708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
17709         LDKHTLCOutputInCommitment this_ptr_conv;
17710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17711         this_ptr_conv.is_owned = false;
17712         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
17713 }
17714
17715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17716         LDKHTLCOutputInCommitment this_ptr_conv;
17717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17718         this_ptr_conv.is_owned = false;
17719         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
17720         return ret_val;
17721 }
17722
17723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17724         LDKHTLCOutputInCommitment this_ptr_conv;
17725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17726         this_ptr_conv.is_owned = false;
17727         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
17728 }
17729
17730 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
17731         LDKHTLCOutputInCommitment this_ptr_conv;
17732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17733         this_ptr_conv.is_owned = false;
17734         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
17735         return ret_val;
17736 }
17737
17738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17739         LDKHTLCOutputInCommitment this_ptr_conv;
17740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17741         this_ptr_conv.is_owned = false;
17742         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
17743 }
17744
17745 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
17746         LDKHTLCOutputInCommitment this_ptr_conv;
17747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17748         this_ptr_conv.is_owned = false;
17749         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17750         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
17751         return ret_arr;
17752 }
17753
17754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17755         LDKHTLCOutputInCommitment this_ptr_conv;
17756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17757         this_ptr_conv.is_owned = false;
17758         LDKThirtyTwoBytes val_ref;
17759         CHECK((*env)->GetArrayLength(env, val) == 32);
17760         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17761         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
17762 }
17763
17764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17765         LDKHTLCOutputInCommitment orig_conv;
17766         orig_conv.inner = (void*)(orig & (~1));
17767         orig_conv.is_owned = false;
17768         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
17769         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17770         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17771         long ret_ref = (long)ret_var.inner;
17772         if (ret_var.is_owned) {
17773                 ret_ref |= 1;
17774         }
17775         return ret_ref;
17776 }
17777
17778 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
17779         LDKHTLCOutputInCommitment obj_conv;
17780         obj_conv.inner = (void*)(obj & (~1));
17781         obj_conv.is_owned = false;
17782         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
17783         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17784         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17785         CVec_u8Z_free(ret_var);
17786         return ret_arr;
17787 }
17788
17789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17790         LDKu8slice ser_ref;
17791         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17792         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17793         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
17794         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
17795         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17796         return (long)ret_conv;
17797 }
17798
17799 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
17800         LDKHTLCOutputInCommitment htlc_conv;
17801         htlc_conv.inner = (void*)(htlc & (~1));
17802         htlc_conv.is_owned = false;
17803         LDKTxCreationKeys keys_conv;
17804         keys_conv.inner = (void*)(keys & (~1));
17805         keys_conv.is_owned = false;
17806         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
17807         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17808         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17809         CVec_u8Z_free(ret_var);
17810         return ret_arr;
17811 }
17812
17813 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
17814         LDKPublicKey broadcaster_ref;
17815         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
17816         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
17817         LDKPublicKey countersignatory_ref;
17818         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
17819         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
17820         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
17821         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17822         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17823         CVec_u8Z_free(ret_var);
17824         return ret_arr;
17825 }
17826
17827 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) {
17828         unsigned char prev_hash_arr[32];
17829         CHECK((*env)->GetArrayLength(env, prev_hash) == 32);
17830         (*env)->GetByteArrayRegion(env, prev_hash, 0, 32, prev_hash_arr);
17831         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
17832         LDKHTLCOutputInCommitment htlc_conv;
17833         htlc_conv.inner = (void*)(htlc & (~1));
17834         htlc_conv.is_owned = false;
17835         LDKPublicKey broadcaster_delayed_payment_key_ref;
17836         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
17837         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
17838         LDKPublicKey revocation_key_ref;
17839         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
17840         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
17841         LDKTransaction ret_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
17842         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17843         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17844         Transaction_free(ret_var);
17845         return ret_arr;
17846 }
17847
17848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17849         LDKChannelTransactionParameters this_obj_conv;
17850         this_obj_conv.inner = (void*)(this_obj & (~1));
17851         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17852         ChannelTransactionParameters_free(this_obj_conv);
17853 }
17854
17855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
17856         LDKChannelTransactionParameters this_ptr_conv;
17857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17858         this_ptr_conv.is_owned = false;
17859         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
17860         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17861         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17862         long ret_ref = (long)ret_var.inner;
17863         if (ret_var.is_owned) {
17864                 ret_ref |= 1;
17865         }
17866         return ret_ref;
17867 }
17868
17869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17870         LDKChannelTransactionParameters this_ptr_conv;
17871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17872         this_ptr_conv.is_owned = false;
17873         LDKChannelPublicKeys val_conv;
17874         val_conv.inner = (void*)(val & (~1));
17875         val_conv.is_owned = (val & 1) || (val == 0);
17876         val_conv = ChannelPublicKeys_clone(&val_conv);
17877         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
17878 }
17879
17880 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17881         LDKChannelTransactionParameters this_ptr_conv;
17882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17883         this_ptr_conv.is_owned = false;
17884         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
17885         return ret_val;
17886 }
17887
17888 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) {
17889         LDKChannelTransactionParameters this_ptr_conv;
17890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17891         this_ptr_conv.is_owned = false;
17892         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
17893 }
17894
17895 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
17896         LDKChannelTransactionParameters this_ptr_conv;
17897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17898         this_ptr_conv.is_owned = false;
17899         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
17900         return ret_val;
17901 }
17902
17903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
17904         LDKChannelTransactionParameters this_ptr_conv;
17905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17906         this_ptr_conv.is_owned = false;
17907         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
17908 }
17909
17910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
17911         LDKChannelTransactionParameters this_ptr_conv;
17912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17913         this_ptr_conv.is_owned = false;
17914         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
17915         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17916         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17917         long ret_ref = (long)ret_var.inner;
17918         if (ret_var.is_owned) {
17919                 ret_ref |= 1;
17920         }
17921         return ret_ref;
17922 }
17923
17924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17925         LDKChannelTransactionParameters this_ptr_conv;
17926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17927         this_ptr_conv.is_owned = false;
17928         LDKCounterpartyChannelTransactionParameters val_conv;
17929         val_conv.inner = (void*)(val & (~1));
17930         val_conv.is_owned = (val & 1) || (val == 0);
17931         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
17932         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
17933 }
17934
17935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17936         LDKChannelTransactionParameters this_ptr_conv;
17937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17938         this_ptr_conv.is_owned = false;
17939         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
17940         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17941         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17942         long ret_ref = (long)ret_var.inner;
17943         if (ret_var.is_owned) {
17944                 ret_ref |= 1;
17945         }
17946         return ret_ref;
17947 }
17948
17949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17950         LDKChannelTransactionParameters this_ptr_conv;
17951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17952         this_ptr_conv.is_owned = false;
17953         LDKOutPoint val_conv;
17954         val_conv.inner = (void*)(val & (~1));
17955         val_conv.is_owned = (val & 1) || (val == 0);
17956         val_conv = OutPoint_clone(&val_conv);
17957         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
17958 }
17959
17960 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) {
17961         LDKChannelPublicKeys holder_pubkeys_arg_conv;
17962         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
17963         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
17964         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
17965         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
17966         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
17967         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
17968         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
17969         LDKOutPoint funding_outpoint_arg_conv;
17970         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
17971         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
17972         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
17973         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);
17974         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17975         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17976         long ret_ref = (long)ret_var.inner;
17977         if (ret_var.is_owned) {
17978                 ret_ref |= 1;
17979         }
17980         return ret_ref;
17981 }
17982
17983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17984         LDKChannelTransactionParameters orig_conv;
17985         orig_conv.inner = (void*)(orig & (~1));
17986         orig_conv.is_owned = false;
17987         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
17988         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17989         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17990         long ret_ref = (long)ret_var.inner;
17991         if (ret_var.is_owned) {
17992                 ret_ref |= 1;
17993         }
17994         return ret_ref;
17995 }
17996
17997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17998         LDKCounterpartyChannelTransactionParameters this_obj_conv;
17999         this_obj_conv.inner = (void*)(this_obj & (~1));
18000         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18001         CounterpartyChannelTransactionParameters_free(this_obj_conv);
18002 }
18003
18004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
18005         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
18006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18007         this_ptr_conv.is_owned = false;
18008         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
18009         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18010         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18011         long ret_ref = (long)ret_var.inner;
18012         if (ret_var.is_owned) {
18013                 ret_ref |= 1;
18014         }
18015         return ret_ref;
18016 }
18017
18018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18019         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
18020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18021         this_ptr_conv.is_owned = false;
18022         LDKChannelPublicKeys val_conv;
18023         val_conv.inner = (void*)(val & (~1));
18024         val_conv.is_owned = (val & 1) || (val == 0);
18025         val_conv = ChannelPublicKeys_clone(&val_conv);
18026         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
18027 }
18028
18029 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
18030         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
18031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18032         this_ptr_conv.is_owned = false;
18033         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
18034         return ret_val;
18035 }
18036
18037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18038         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
18039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18040         this_ptr_conv.is_owned = false;
18041         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
18042 }
18043
18044 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) {
18045         LDKChannelPublicKeys pubkeys_arg_conv;
18046         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
18047         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
18048         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
18049         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
18050         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18051         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18052         long ret_ref = (long)ret_var.inner;
18053         if (ret_var.is_owned) {
18054                 ret_ref |= 1;
18055         }
18056         return ret_ref;
18057 }
18058
18059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18060         LDKCounterpartyChannelTransactionParameters orig_conv;
18061         orig_conv.inner = (void*)(orig & (~1));
18062         orig_conv.is_owned = false;
18063         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
18064         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18065         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18066         long ret_ref = (long)ret_var.inner;
18067         if (ret_var.is_owned) {
18068                 ret_ref |= 1;
18069         }
18070         return ret_ref;
18071 }
18072
18073 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
18074         LDKChannelTransactionParameters this_arg_conv;
18075         this_arg_conv.inner = (void*)(this_arg & (~1));
18076         this_arg_conv.is_owned = false;
18077         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
18078         return ret_val;
18079 }
18080
18081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
18082         LDKChannelTransactionParameters this_arg_conv;
18083         this_arg_conv.inner = (void*)(this_arg & (~1));
18084         this_arg_conv.is_owned = false;
18085         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
18086         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18087         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18088         long ret_ref = (long)ret_var.inner;
18089         if (ret_var.is_owned) {
18090                 ret_ref |= 1;
18091         }
18092         return ret_ref;
18093 }
18094
18095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
18096         LDKChannelTransactionParameters this_arg_conv;
18097         this_arg_conv.inner = (void*)(this_arg & (~1));
18098         this_arg_conv.is_owned = false;
18099         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
18100         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18101         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18102         long ret_ref = (long)ret_var.inner;
18103         if (ret_var.is_owned) {
18104                 ret_ref |= 1;
18105         }
18106         return ret_ref;
18107 }
18108
18109 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
18110         LDKCounterpartyChannelTransactionParameters obj_conv;
18111         obj_conv.inner = (void*)(obj & (~1));
18112         obj_conv.is_owned = false;
18113         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
18114         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18115         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18116         CVec_u8Z_free(ret_var);
18117         return ret_arr;
18118 }
18119
18120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18121         LDKu8slice ser_ref;
18122         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18123         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18124         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
18125         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
18126         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18127         return (long)ret_conv;
18128 }
18129
18130 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
18131         LDKChannelTransactionParameters obj_conv;
18132         obj_conv.inner = (void*)(obj & (~1));
18133         obj_conv.is_owned = false;
18134         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
18135         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18136         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18137         CVec_u8Z_free(ret_var);
18138         return ret_arr;
18139 }
18140
18141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18142         LDKu8slice ser_ref;
18143         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18144         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18145         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
18146         *ret_conv = ChannelTransactionParameters_read(ser_ref);
18147         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18148         return (long)ret_conv;
18149 }
18150
18151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18152         LDKDirectedChannelTransactionParameters this_obj_conv;
18153         this_obj_conv.inner = (void*)(this_obj & (~1));
18154         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18155         DirectedChannelTransactionParameters_free(this_obj_conv);
18156 }
18157
18158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
18159         LDKDirectedChannelTransactionParameters this_arg_conv;
18160         this_arg_conv.inner = (void*)(this_arg & (~1));
18161         this_arg_conv.is_owned = false;
18162         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
18163         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18164         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18165         long ret_ref = (long)ret_var.inner;
18166         if (ret_var.is_owned) {
18167                 ret_ref |= 1;
18168         }
18169         return ret_ref;
18170 }
18171
18172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
18173         LDKDirectedChannelTransactionParameters this_arg_conv;
18174         this_arg_conv.inner = (void*)(this_arg & (~1));
18175         this_arg_conv.is_owned = false;
18176         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
18177         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18178         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18179         long ret_ref = (long)ret_var.inner;
18180         if (ret_var.is_owned) {
18181                 ret_ref |= 1;
18182         }
18183         return ret_ref;
18184 }
18185
18186 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
18187         LDKDirectedChannelTransactionParameters this_arg_conv;
18188         this_arg_conv.inner = (void*)(this_arg & (~1));
18189         this_arg_conv.is_owned = false;
18190         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
18191         return ret_val;
18192 }
18193
18194 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
18195         LDKDirectedChannelTransactionParameters this_arg_conv;
18196         this_arg_conv.inner = (void*)(this_arg & (~1));
18197         this_arg_conv.is_owned = false;
18198         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
18199         return ret_val;
18200 }
18201
18202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
18203         LDKDirectedChannelTransactionParameters this_arg_conv;
18204         this_arg_conv.inner = (void*)(this_arg & (~1));
18205         this_arg_conv.is_owned = false;
18206         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
18207         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18208         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18209         long ret_ref = (long)ret_var.inner;
18210         if (ret_var.is_owned) {
18211                 ret_ref |= 1;
18212         }
18213         return ret_ref;
18214 }
18215
18216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18217         LDKHolderCommitmentTransaction this_obj_conv;
18218         this_obj_conv.inner = (void*)(this_obj & (~1));
18219         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18220         HolderCommitmentTransaction_free(this_obj_conv);
18221 }
18222
18223 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
18224         LDKHolderCommitmentTransaction this_ptr_conv;
18225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18226         this_ptr_conv.is_owned = false;
18227         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18228         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
18229         return ret_arr;
18230 }
18231
18232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18233         LDKHolderCommitmentTransaction this_ptr_conv;
18234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18235         this_ptr_conv.is_owned = false;
18236         LDKSignature val_ref;
18237         CHECK((*env)->GetArrayLength(env, val) == 64);
18238         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18239         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
18240 }
18241
18242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
18243         LDKHolderCommitmentTransaction this_ptr_conv;
18244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18245         this_ptr_conv.is_owned = false;
18246         LDKCVec_SignatureZ val_constr;
18247         val_constr.datalen = (*env)->GetArrayLength(env, val);
18248         if (val_constr.datalen > 0)
18249                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18250         else
18251                 val_constr.data = NULL;
18252         for (size_t i = 0; i < val_constr.datalen; i++) {
18253                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
18254                 LDKSignature val_conv_8_ref;
18255                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
18256                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
18257                 val_constr.data[i] = val_conv_8_ref;
18258         }
18259         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
18260 }
18261
18262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18263         LDKHolderCommitmentTransaction orig_conv;
18264         orig_conv.inner = (void*)(orig & (~1));
18265         orig_conv.is_owned = false;
18266         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
18267         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18268         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18269         long ret_ref = (long)ret_var.inner;
18270         if (ret_var.is_owned) {
18271                 ret_ref |= 1;
18272         }
18273         return ret_ref;
18274 }
18275
18276 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
18277         LDKHolderCommitmentTransaction obj_conv;
18278         obj_conv.inner = (void*)(obj & (~1));
18279         obj_conv.is_owned = false;
18280         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
18281         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18282         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18283         CVec_u8Z_free(ret_var);
18284         return ret_arr;
18285 }
18286
18287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18288         LDKu8slice ser_ref;
18289         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18290         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18291         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
18292         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
18293         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18294         return (long)ret_conv;
18295 }
18296
18297 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) {
18298         LDKCommitmentTransaction commitment_tx_conv;
18299         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
18300         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
18301         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
18302         LDKSignature counterparty_sig_ref;
18303         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
18304         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
18305         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
18306         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
18307         if (counterparty_htlc_sigs_constr.datalen > 0)
18308                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18309         else
18310                 counterparty_htlc_sigs_constr.data = NULL;
18311         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
18312                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
18313                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
18314                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
18315                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
18316                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
18317         }
18318         LDKPublicKey holder_funding_key_ref;
18319         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
18320         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
18321         LDKPublicKey counterparty_funding_key_ref;
18322         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
18323         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
18324         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
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_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18335         LDKBuiltCommitmentTransaction this_obj_conv;
18336         this_obj_conv.inner = (void*)(this_obj & (~1));
18337         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18338         BuiltCommitmentTransaction_free(this_obj_conv);
18339 }
18340
18341 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
18342         LDKBuiltCommitmentTransaction this_ptr_conv;
18343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18344         this_ptr_conv.is_owned = false;
18345         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
18346         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18347         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18348         Transaction_free(ret_var);
18349         return ret_arr;
18350 }
18351
18352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18353         LDKBuiltCommitmentTransaction this_ptr_conv;
18354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18355         this_ptr_conv.is_owned = false;
18356         LDKTransaction val_ref;
18357         val_ref.datalen = (*env)->GetArrayLength(env, val);
18358         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
18359         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
18360         val_ref.data_is_owned = true;
18361         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
18362 }
18363
18364 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
18365         LDKBuiltCommitmentTransaction this_ptr_conv;
18366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18367         this_ptr_conv.is_owned = false;
18368         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18369         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
18370         return ret_arr;
18371 }
18372
18373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18374         LDKBuiltCommitmentTransaction this_ptr_conv;
18375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18376         this_ptr_conv.is_owned = false;
18377         LDKThirtyTwoBytes val_ref;
18378         CHECK((*env)->GetArrayLength(env, val) == 32);
18379         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18380         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
18381 }
18382
18383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
18384         LDKTransaction transaction_arg_ref;
18385         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
18386         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
18387         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
18388         transaction_arg_ref.data_is_owned = true;
18389         LDKThirtyTwoBytes txid_arg_ref;
18390         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
18391         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
18392         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
18393         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18394         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18395         long ret_ref = (long)ret_var.inner;
18396         if (ret_var.is_owned) {
18397                 ret_ref |= 1;
18398         }
18399         return ret_ref;
18400 }
18401
18402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18403         LDKBuiltCommitmentTransaction orig_conv;
18404         orig_conv.inner = (void*)(orig & (~1));
18405         orig_conv.is_owned = false;
18406         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
18407         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18408         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18409         long ret_ref = (long)ret_var.inner;
18410         if (ret_var.is_owned) {
18411                 ret_ref |= 1;
18412         }
18413         return ret_ref;
18414 }
18415
18416 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
18417         LDKBuiltCommitmentTransaction obj_conv;
18418         obj_conv.inner = (void*)(obj & (~1));
18419         obj_conv.is_owned = false;
18420         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
18421         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18422         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18423         CVec_u8Z_free(ret_var);
18424         return ret_arr;
18425 }
18426
18427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18428         LDKu8slice ser_ref;
18429         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18430         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18431         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
18432         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
18433         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18434         return (long)ret_conv;
18435 }
18436
18437 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) {
18438         LDKBuiltCommitmentTransaction this_arg_conv;
18439         this_arg_conv.inner = (void*)(this_arg & (~1));
18440         this_arg_conv.is_owned = false;
18441         LDKu8slice funding_redeemscript_ref;
18442         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
18443         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
18444         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18445         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
18446         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
18447         return ret_arr;
18448 }
18449
18450 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) {
18451         LDKBuiltCommitmentTransaction this_arg_conv;
18452         this_arg_conv.inner = (void*)(this_arg & (~1));
18453         this_arg_conv.is_owned = false;
18454         unsigned char funding_key_arr[32];
18455         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
18456         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
18457         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
18458         LDKu8slice funding_redeemscript_ref;
18459         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
18460         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
18461         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18462         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
18463         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
18464         return ret_arr;
18465 }
18466
18467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18468         LDKCommitmentTransaction this_obj_conv;
18469         this_obj_conv.inner = (void*)(this_obj & (~1));
18470         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18471         CommitmentTransaction_free(this_obj_conv);
18472 }
18473
18474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18475         LDKCommitmentTransaction orig_conv;
18476         orig_conv.inner = (void*)(orig & (~1));
18477         orig_conv.is_owned = false;
18478         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
18479         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18480         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18481         long ret_ref = (long)ret_var.inner;
18482         if (ret_var.is_owned) {
18483                 ret_ref |= 1;
18484         }
18485         return ret_ref;
18486 }
18487
18488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
18489         LDKCommitmentTransaction obj_conv;
18490         obj_conv.inner = (void*)(obj & (~1));
18491         obj_conv.is_owned = false;
18492         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
18493         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18494         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18495         CVec_u8Z_free(ret_var);
18496         return ret_arr;
18497 }
18498
18499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18500         LDKu8slice ser_ref;
18501         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18502         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18503         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
18504         *ret_conv = CommitmentTransaction_read(ser_ref);
18505         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18506         return (long)ret_conv;
18507 }
18508
18509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
18510         LDKCommitmentTransaction this_arg_conv;
18511         this_arg_conv.inner = (void*)(this_arg & (~1));
18512         this_arg_conv.is_owned = false;
18513         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
18514         return ret_val;
18515 }
18516
18517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
18518         LDKCommitmentTransaction this_arg_conv;
18519         this_arg_conv.inner = (void*)(this_arg & (~1));
18520         this_arg_conv.is_owned = false;
18521         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
18522         return ret_val;
18523 }
18524
18525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
18526         LDKCommitmentTransaction this_arg_conv;
18527         this_arg_conv.inner = (void*)(this_arg & (~1));
18528         this_arg_conv.is_owned = false;
18529         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
18530         return ret_val;
18531 }
18532
18533 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
18534         LDKCommitmentTransaction this_arg_conv;
18535         this_arg_conv.inner = (void*)(this_arg & (~1));
18536         this_arg_conv.is_owned = false;
18537         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
18538         return ret_val;
18539 }
18540
18541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
18542         LDKCommitmentTransaction this_arg_conv;
18543         this_arg_conv.inner = (void*)(this_arg & (~1));
18544         this_arg_conv.is_owned = false;
18545         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
18546         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18547         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18548         long ret_ref = (long)ret_var.inner;
18549         if (ret_var.is_owned) {
18550                 ret_ref |= 1;
18551         }
18552         return ret_ref;
18553 }
18554
18555 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) {
18556         LDKCommitmentTransaction this_arg_conv;
18557         this_arg_conv.inner = (void*)(this_arg & (~1));
18558         this_arg_conv.is_owned = false;
18559         LDKDirectedChannelTransactionParameters channel_parameters_conv;
18560         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
18561         channel_parameters_conv.is_owned = false;
18562         LDKChannelPublicKeys broadcaster_keys_conv;
18563         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
18564         broadcaster_keys_conv.is_owned = false;
18565         LDKChannelPublicKeys countersignatory_keys_conv;
18566         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
18567         countersignatory_keys_conv.is_owned = false;
18568         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
18569         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
18570         return (long)ret_conv;
18571 }
18572
18573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18574         LDKTrustedCommitmentTransaction this_obj_conv;
18575         this_obj_conv.inner = (void*)(this_obj & (~1));
18576         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18577         TrustedCommitmentTransaction_free(this_obj_conv);
18578 }
18579
18580 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
18581         LDKTrustedCommitmentTransaction this_arg_conv;
18582         this_arg_conv.inner = (void*)(this_arg & (~1));
18583         this_arg_conv.is_owned = false;
18584         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18585         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
18586         return ret_arr;
18587 }
18588
18589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
18590         LDKTrustedCommitmentTransaction this_arg_conv;
18591         this_arg_conv.inner = (void*)(this_arg & (~1));
18592         this_arg_conv.is_owned = false;
18593         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
18594         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18595         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18596         long ret_ref = (long)ret_var.inner;
18597         if (ret_var.is_owned) {
18598                 ret_ref |= 1;
18599         }
18600         return ret_ref;
18601 }
18602
18603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
18604         LDKTrustedCommitmentTransaction this_arg_conv;
18605         this_arg_conv.inner = (void*)(this_arg & (~1));
18606         this_arg_conv.is_owned = false;
18607         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
18608         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18609         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18610         long ret_ref = (long)ret_var.inner;
18611         if (ret_var.is_owned) {
18612                 ret_ref |= 1;
18613         }
18614         return ret_ref;
18615 }
18616
18617 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) {
18618         LDKTrustedCommitmentTransaction this_arg_conv;
18619         this_arg_conv.inner = (void*)(this_arg & (~1));
18620         this_arg_conv.is_owned = false;
18621         unsigned char htlc_base_key_arr[32];
18622         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
18623         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
18624         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
18625         LDKDirectedChannelTransactionParameters channel_parameters_conv;
18626         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
18627         channel_parameters_conv.is_owned = false;
18628         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
18629         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
18630         return (long)ret_conv;
18631 }
18632
18633 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) {
18634         LDKPublicKey broadcaster_payment_basepoint_ref;
18635         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
18636         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
18637         LDKPublicKey countersignatory_payment_basepoint_ref;
18638         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
18639         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
18640         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
18641         return ret_val;
18642 }
18643
18644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18645         LDKInitFeatures orig_conv;
18646         orig_conv.inner = (void*)(orig & (~1));
18647         orig_conv.is_owned = false;
18648         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
18649         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18650         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18651         long ret_ref = (long)ret_var.inner;
18652         if (ret_var.is_owned) {
18653                 ret_ref |= 1;
18654         }
18655         return ret_ref;
18656 }
18657
18658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18659         LDKNodeFeatures orig_conv;
18660         orig_conv.inner = (void*)(orig & (~1));
18661         orig_conv.is_owned = false;
18662         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
18663         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18664         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18665         long ret_ref = (long)ret_var.inner;
18666         if (ret_var.is_owned) {
18667                 ret_ref |= 1;
18668         }
18669         return ret_ref;
18670 }
18671
18672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18673         LDKChannelFeatures orig_conv;
18674         orig_conv.inner = (void*)(orig & (~1));
18675         orig_conv.is_owned = false;
18676         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
18677         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18678         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18679         long ret_ref = (long)ret_var.inner;
18680         if (ret_var.is_owned) {
18681                 ret_ref |= 1;
18682         }
18683         return ret_ref;
18684 }
18685
18686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18687         LDKInitFeatures this_obj_conv;
18688         this_obj_conv.inner = (void*)(this_obj & (~1));
18689         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18690         InitFeatures_free(this_obj_conv);
18691 }
18692
18693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18694         LDKNodeFeatures this_obj_conv;
18695         this_obj_conv.inner = (void*)(this_obj & (~1));
18696         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18697         NodeFeatures_free(this_obj_conv);
18698 }
18699
18700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18701         LDKChannelFeatures this_obj_conv;
18702         this_obj_conv.inner = (void*)(this_obj & (~1));
18703         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18704         ChannelFeatures_free(this_obj_conv);
18705 }
18706
18707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
18708         LDKInitFeatures ret_var = InitFeatures_empty();
18709         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18710         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18711         long ret_ref = (long)ret_var.inner;
18712         if (ret_var.is_owned) {
18713                 ret_ref |= 1;
18714         }
18715         return ret_ref;
18716 }
18717
18718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
18719         LDKInitFeatures ret_var = InitFeatures_known();
18720         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18721         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18722         long ret_ref = (long)ret_var.inner;
18723         if (ret_var.is_owned) {
18724                 ret_ref |= 1;
18725         }
18726         return ret_ref;
18727 }
18728
18729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
18730         LDKNodeFeatures ret_var = NodeFeatures_empty();
18731         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18732         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18733         long ret_ref = (long)ret_var.inner;
18734         if (ret_var.is_owned) {
18735                 ret_ref |= 1;
18736         }
18737         return ret_ref;
18738 }
18739
18740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
18741         LDKNodeFeatures ret_var = NodeFeatures_known();
18742         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18743         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18744         long ret_ref = (long)ret_var.inner;
18745         if (ret_var.is_owned) {
18746                 ret_ref |= 1;
18747         }
18748         return ret_ref;
18749 }
18750
18751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
18752         LDKChannelFeatures ret_var = ChannelFeatures_empty();
18753         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18754         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18755         long ret_ref = (long)ret_var.inner;
18756         if (ret_var.is_owned) {
18757                 ret_ref |= 1;
18758         }
18759         return ret_ref;
18760 }
18761
18762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
18763         LDKChannelFeatures ret_var = ChannelFeatures_known();
18764         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18765         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18766         long ret_ref = (long)ret_var.inner;
18767         if (ret_var.is_owned) {
18768                 ret_ref |= 1;
18769         }
18770         return ret_ref;
18771 }
18772
18773 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
18774         LDKInitFeatures obj_conv;
18775         obj_conv.inner = (void*)(obj & (~1));
18776         obj_conv.is_owned = false;
18777         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
18778         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18779         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18780         CVec_u8Z_free(ret_var);
18781         return ret_arr;
18782 }
18783
18784 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
18785         LDKNodeFeatures obj_conv;
18786         obj_conv.inner = (void*)(obj & (~1));
18787         obj_conv.is_owned = false;
18788         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
18789         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18790         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18791         CVec_u8Z_free(ret_var);
18792         return ret_arr;
18793 }
18794
18795 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
18796         LDKChannelFeatures obj_conv;
18797         obj_conv.inner = (void*)(obj & (~1));
18798         obj_conv.is_owned = false;
18799         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
18800         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18801         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18802         CVec_u8Z_free(ret_var);
18803         return ret_arr;
18804 }
18805
18806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18807         LDKu8slice ser_ref;
18808         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18809         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18810         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18811         *ret_conv = InitFeatures_read(ser_ref);
18812         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18813         return (long)ret_conv;
18814 }
18815
18816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18817         LDKu8slice ser_ref;
18818         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18819         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18820         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18821         *ret_conv = NodeFeatures_read(ser_ref);
18822         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18823         return (long)ret_conv;
18824 }
18825
18826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18827         LDKu8slice ser_ref;
18828         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18829         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18830         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18831         *ret_conv = ChannelFeatures_read(ser_ref);
18832         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18833         return (long)ret_conv;
18834 }
18835
18836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18837         LDKRouteHop this_obj_conv;
18838         this_obj_conv.inner = (void*)(this_obj & (~1));
18839         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18840         RouteHop_free(this_obj_conv);
18841 }
18842
18843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18844         LDKRouteHop this_ptr_conv;
18845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18846         this_ptr_conv.is_owned = false;
18847         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18848         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
18849         return ret_arr;
18850 }
18851
18852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18853         LDKRouteHop this_ptr_conv;
18854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18855         this_ptr_conv.is_owned = false;
18856         LDKPublicKey val_ref;
18857         CHECK((*env)->GetArrayLength(env, val) == 33);
18858         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18859         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
18860 }
18861
18862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18863         LDKRouteHop this_ptr_conv;
18864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18865         this_ptr_conv.is_owned = false;
18866         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
18867         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18868         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18869         long ret_ref = (long)ret_var.inner;
18870         if (ret_var.is_owned) {
18871                 ret_ref |= 1;
18872         }
18873         return ret_ref;
18874 }
18875
18876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18877         LDKRouteHop this_ptr_conv;
18878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18879         this_ptr_conv.is_owned = false;
18880         LDKNodeFeatures val_conv;
18881         val_conv.inner = (void*)(val & (~1));
18882         val_conv.is_owned = (val & 1) || (val == 0);
18883         val_conv = NodeFeatures_clone(&val_conv);
18884         RouteHop_set_node_features(&this_ptr_conv, val_conv);
18885 }
18886
18887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18888         LDKRouteHop this_ptr_conv;
18889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18890         this_ptr_conv.is_owned = false;
18891         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
18892         return ret_val;
18893 }
18894
18895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18896         LDKRouteHop this_ptr_conv;
18897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18898         this_ptr_conv.is_owned = false;
18899         RouteHop_set_short_channel_id(&this_ptr_conv, val);
18900 }
18901
18902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18903         LDKRouteHop this_ptr_conv;
18904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18905         this_ptr_conv.is_owned = false;
18906         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
18907         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18908         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18909         long ret_ref = (long)ret_var.inner;
18910         if (ret_var.is_owned) {
18911                 ret_ref |= 1;
18912         }
18913         return ret_ref;
18914 }
18915
18916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18917         LDKRouteHop this_ptr_conv;
18918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18919         this_ptr_conv.is_owned = false;
18920         LDKChannelFeatures val_conv;
18921         val_conv.inner = (void*)(val & (~1));
18922         val_conv.is_owned = (val & 1) || (val == 0);
18923         val_conv = ChannelFeatures_clone(&val_conv);
18924         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
18925 }
18926
18927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18928         LDKRouteHop this_ptr_conv;
18929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18930         this_ptr_conv.is_owned = false;
18931         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
18932         return ret_val;
18933 }
18934
18935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18936         LDKRouteHop this_ptr_conv;
18937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18938         this_ptr_conv.is_owned = false;
18939         RouteHop_set_fee_msat(&this_ptr_conv, val);
18940 }
18941
18942 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
18943         LDKRouteHop this_ptr_conv;
18944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18945         this_ptr_conv.is_owned = false;
18946         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
18947         return ret_val;
18948 }
18949
18950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18951         LDKRouteHop this_ptr_conv;
18952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18953         this_ptr_conv.is_owned = false;
18954         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
18955 }
18956
18957 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) {
18958         LDKPublicKey pubkey_arg_ref;
18959         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
18960         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
18961         LDKNodeFeatures node_features_arg_conv;
18962         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
18963         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
18964         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
18965         LDKChannelFeatures channel_features_arg_conv;
18966         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
18967         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
18968         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
18969         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);
18970         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18971         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18972         long ret_ref = (long)ret_var.inner;
18973         if (ret_var.is_owned) {
18974                 ret_ref |= 1;
18975         }
18976         return ret_ref;
18977 }
18978
18979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18980         LDKRouteHop orig_conv;
18981         orig_conv.inner = (void*)(orig & (~1));
18982         orig_conv.is_owned = false;
18983         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
18984         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18985         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18986         long ret_ref = (long)ret_var.inner;
18987         if (ret_var.is_owned) {
18988                 ret_ref |= 1;
18989         }
18990         return ret_ref;
18991 }
18992
18993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18994         LDKRoute this_obj_conv;
18995         this_obj_conv.inner = (void*)(this_obj & (~1));
18996         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18997         Route_free(this_obj_conv);
18998 }
18999
19000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
19001         LDKRoute this_ptr_conv;
19002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19003         this_ptr_conv.is_owned = false;
19004         LDKCVec_CVec_RouteHopZZ val_constr;
19005         val_constr.datalen = (*env)->GetArrayLength(env, val);
19006         if (val_constr.datalen > 0)
19007                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
19008         else
19009                 val_constr.data = NULL;
19010         for (size_t m = 0; m < val_constr.datalen; m++) {
19011                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
19012                 LDKCVec_RouteHopZ val_conv_12_constr;
19013                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
19014                 if (val_conv_12_constr.datalen > 0)
19015                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19016                 else
19017                         val_conv_12_constr.data = NULL;
19018                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
19019                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
19020                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
19021                         LDKRouteHop val_conv_12_conv_10_conv;
19022                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
19023                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
19024                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
19025                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
19026                 }
19027                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
19028                 val_constr.data[m] = val_conv_12_constr;
19029         }
19030         Route_set_paths(&this_ptr_conv, val_constr);
19031 }
19032
19033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
19034         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
19035         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
19036         if (paths_arg_constr.datalen > 0)
19037                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
19038         else
19039                 paths_arg_constr.data = NULL;
19040         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
19041                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
19042                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
19043                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
19044                 if (paths_arg_conv_12_constr.datalen > 0)
19045                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19046                 else
19047                         paths_arg_conv_12_constr.data = NULL;
19048                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
19049                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
19050                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
19051                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
19052                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
19053                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
19054                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
19055                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
19056                 }
19057                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
19058                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
19059         }
19060         LDKRoute ret_var = Route_new(paths_arg_constr);
19061         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19062         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19063         long ret_ref = (long)ret_var.inner;
19064         if (ret_var.is_owned) {
19065                 ret_ref |= 1;
19066         }
19067         return ret_ref;
19068 }
19069
19070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19071         LDKRoute orig_conv;
19072         orig_conv.inner = (void*)(orig & (~1));
19073         orig_conv.is_owned = false;
19074         LDKRoute ret_var = Route_clone(&orig_conv);
19075         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19076         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19077         long ret_ref = (long)ret_var.inner;
19078         if (ret_var.is_owned) {
19079                 ret_ref |= 1;
19080         }
19081         return ret_ref;
19082 }
19083
19084 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
19085         LDKRoute obj_conv;
19086         obj_conv.inner = (void*)(obj & (~1));
19087         obj_conv.is_owned = false;
19088         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
19089         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19090         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19091         CVec_u8Z_free(ret_var);
19092         return ret_arr;
19093 }
19094
19095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19096         LDKu8slice ser_ref;
19097         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19098         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19099         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
19100         *ret_conv = Route_read(ser_ref);
19101         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19102         return (long)ret_conv;
19103 }
19104
19105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19106         LDKRouteHint this_obj_conv;
19107         this_obj_conv.inner = (void*)(this_obj & (~1));
19108         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19109         RouteHint_free(this_obj_conv);
19110 }
19111
19112 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19113         LDKRouteHint this_ptr_conv;
19114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19115         this_ptr_conv.is_owned = false;
19116         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19117         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHint_get_src_node_id(&this_ptr_conv).compressed_form);
19118         return ret_arr;
19119 }
19120
19121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19122         LDKRouteHint this_ptr_conv;
19123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19124         this_ptr_conv.is_owned = false;
19125         LDKPublicKey val_ref;
19126         CHECK((*env)->GetArrayLength(env, val) == 33);
19127         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19128         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
19129 }
19130
19131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19132         LDKRouteHint this_ptr_conv;
19133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19134         this_ptr_conv.is_owned = false;
19135         int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
19136         return ret_val;
19137 }
19138
19139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19140         LDKRouteHint this_ptr_conv;
19141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19142         this_ptr_conv.is_owned = false;
19143         RouteHint_set_short_channel_id(&this_ptr_conv, val);
19144 }
19145
19146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
19147         LDKRouteHint this_ptr_conv;
19148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19149         this_ptr_conv.is_owned = false;
19150         LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
19151         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19152         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19153         long ret_ref = (long)ret_var.inner;
19154         if (ret_var.is_owned) {
19155                 ret_ref |= 1;
19156         }
19157         return ret_ref;
19158 }
19159
19160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19161         LDKRouteHint this_ptr_conv;
19162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19163         this_ptr_conv.is_owned = false;
19164         LDKRoutingFees val_conv;
19165         val_conv.inner = (void*)(val & (~1));
19166         val_conv.is_owned = (val & 1) || (val == 0);
19167         val_conv = RoutingFees_clone(&val_conv);
19168         RouteHint_set_fees(&this_ptr_conv, val_conv);
19169 }
19170
19171 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
19172         LDKRouteHint this_ptr_conv;
19173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19174         this_ptr_conv.is_owned = false;
19175         int16_t ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
19176         return ret_val;
19177 }
19178
19179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19180         LDKRouteHint this_ptr_conv;
19181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19182         this_ptr_conv.is_owned = false;
19183         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
19184 }
19185
19186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19187         LDKRouteHint orig_conv;
19188         orig_conv.inner = (void*)(orig & (~1));
19189         orig_conv.is_owned = false;
19190         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
19191         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19192         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19193         long ret_ref = (long)ret_var.inner;
19194         if (ret_var.is_owned) {
19195                 ret_ref |= 1;
19196         }
19197         return ret_ref;
19198 }
19199
19200 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 payee, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) {
19201         LDKPublicKey our_node_id_ref;
19202         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
19203         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
19204         LDKNetworkGraph network_conv;
19205         network_conv.inner = (void*)(network & (~1));
19206         network_conv.is_owned = false;
19207         LDKPublicKey payee_ref;
19208         CHECK((*env)->GetArrayLength(env, payee) == 33);
19209         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
19210         LDKCVec_ChannelDetailsZ first_hops_constr;
19211         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
19212         if (first_hops_constr.datalen > 0)
19213                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
19214         else
19215                 first_hops_constr.data = NULL;
19216         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
19217         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
19218                 int64_t first_hops_conv_16 = first_hops_vals[q];
19219                 LDKChannelDetails first_hops_conv_16_conv;
19220                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
19221                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
19222                 first_hops_constr.data[q] = first_hops_conv_16_conv;
19223         }
19224         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
19225         LDKCVec_RouteHintZ last_hops_constr;
19226         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
19227         if (last_hops_constr.datalen > 0)
19228                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
19229         else
19230                 last_hops_constr.data = NULL;
19231         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
19232         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
19233                 int64_t last_hops_conv_11 = last_hops_vals[l];
19234                 LDKRouteHint last_hops_conv_11_conv;
19235                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
19236                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
19237                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
19238                 last_hops_constr.data[l] = last_hops_conv_11_conv;
19239         }
19240         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
19241         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19242         if (logger_conv.free == LDKLogger_JCalls_free) {
19243                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19244                 LDKLogger_JCalls_clone(logger_conv.this_arg);
19245         }
19246         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
19247         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
19248         FREE(first_hops_constr.data);
19249         return (long)ret_conv;
19250 }
19251
19252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19253         LDKNetworkGraph this_obj_conv;
19254         this_obj_conv.inner = (void*)(this_obj & (~1));
19255         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19256         NetworkGraph_free(this_obj_conv);
19257 }
19258
19259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19260         LDKNetworkGraph orig_conv;
19261         orig_conv.inner = (void*)(orig & (~1));
19262         orig_conv.is_owned = false;
19263         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
19264         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19265         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19266         long ret_ref = (long)ret_var.inner;
19267         if (ret_var.is_owned) {
19268                 ret_ref |= 1;
19269         }
19270         return ret_ref;
19271 }
19272
19273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19274         LDKLockedNetworkGraph this_obj_conv;
19275         this_obj_conv.inner = (void*)(this_obj & (~1));
19276         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19277         LockedNetworkGraph_free(this_obj_conv);
19278 }
19279
19280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19281         LDKNetGraphMsgHandler this_obj_conv;
19282         this_obj_conv.inner = (void*)(this_obj & (~1));
19283         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19284         NetGraphMsgHandler_free(this_obj_conv);
19285 }
19286
19287 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) {
19288         LDKThirtyTwoBytes genesis_hash_ref;
19289         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
19290         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
19291         LDKAccess *chain_access_conv_ptr = NULL;
19292         if (chain_access != 0) {
19293                 LDKAccess chain_access_conv;
19294                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19295                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
19296                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19297                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
19298                 }
19299                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19300                 *chain_access_conv_ptr = chain_access_conv;
19301         }
19302         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19303         if (logger_conv.free == LDKLogger_JCalls_free) {
19304                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19305                 LDKLogger_JCalls_clone(logger_conv.this_arg);
19306         }
19307         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
19308         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19309         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19310         long ret_ref = (long)ret_var.inner;
19311         if (ret_var.is_owned) {
19312                 ret_ref |= 1;
19313         }
19314         return ret_ref;
19315 }
19316
19317 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) {
19318         LDKAccess *chain_access_conv_ptr = NULL;
19319         if (chain_access != 0) {
19320                 LDKAccess chain_access_conv;
19321                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19322                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
19323                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19324                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
19325                 }
19326                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19327                 *chain_access_conv_ptr = chain_access_conv;
19328         }
19329         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19330         if (logger_conv.free == LDKLogger_JCalls_free) {
19331                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19332                 LDKLogger_JCalls_clone(logger_conv.this_arg);
19333         }
19334         LDKNetworkGraph network_graph_conv;
19335         network_graph_conv.inner = (void*)(network_graph & (~1));
19336         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
19337         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
19338         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
19339         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19340         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19341         long ret_ref = (long)ret_var.inner;
19342         if (ret_var.is_owned) {
19343                 ret_ref |= 1;
19344         }
19345         return ret_ref;
19346 }
19347
19348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
19349         LDKNetGraphMsgHandler this_arg_conv;
19350         this_arg_conv.inner = (void*)(this_arg & (~1));
19351         this_arg_conv.is_owned = false;
19352         LDKAccess *chain_access_conv_ptr = NULL;
19353         if (chain_access != 0) {
19354                 LDKAccess chain_access_conv;
19355                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19356                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
19357                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19358                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
19359                 }
19360                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19361                 *chain_access_conv_ptr = chain_access_conv;
19362         }
19363         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
19364 }
19365
19366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
19367         LDKNetGraphMsgHandler this_arg_conv;
19368         this_arg_conv.inner = (void*)(this_arg & (~1));
19369         this_arg_conv.is_owned = false;
19370         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
19371         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19372         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19373         long ret_ref = (long)ret_var.inner;
19374         if (ret_var.is_owned) {
19375                 ret_ref |= 1;
19376         }
19377         return ret_ref;
19378 }
19379
19380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
19381         LDKLockedNetworkGraph this_arg_conv;
19382         this_arg_conv.inner = (void*)(this_arg & (~1));
19383         this_arg_conv.is_owned = false;
19384         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
19385         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19386         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19387         long ret_ref = (long)ret_var.inner;
19388         if (ret_var.is_owned) {
19389                 ret_ref |= 1;
19390         }
19391         return ret_ref;
19392 }
19393
19394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
19395         LDKNetGraphMsgHandler this_arg_conv;
19396         this_arg_conv.inner = (void*)(this_arg & (~1));
19397         this_arg_conv.is_owned = false;
19398         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
19399         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
19400         return (long)ret;
19401 }
19402
19403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
19404         LDKNetGraphMsgHandler this_arg_conv;
19405         this_arg_conv.inner = (void*)(this_arg & (~1));
19406         this_arg_conv.is_owned = false;
19407         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
19408         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
19409         return (long)ret;
19410 }
19411
19412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19413         LDKDirectionalChannelInfo this_obj_conv;
19414         this_obj_conv.inner = (void*)(this_obj & (~1));
19415         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19416         DirectionalChannelInfo_free(this_obj_conv);
19417 }
19418
19419 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
19420         LDKDirectionalChannelInfo this_ptr_conv;
19421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19422         this_ptr_conv.is_owned = false;
19423         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
19424         return ret_val;
19425 }
19426
19427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19428         LDKDirectionalChannelInfo this_ptr_conv;
19429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19430         this_ptr_conv.is_owned = false;
19431         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
19432 }
19433
19434 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
19435         LDKDirectionalChannelInfo this_ptr_conv;
19436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19437         this_ptr_conv.is_owned = false;
19438         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
19439         return ret_val;
19440 }
19441
19442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19443         LDKDirectionalChannelInfo this_ptr_conv;
19444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19445         this_ptr_conv.is_owned = false;
19446         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
19447 }
19448
19449 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
19450         LDKDirectionalChannelInfo this_ptr_conv;
19451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19452         this_ptr_conv.is_owned = false;
19453         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
19454         return ret_val;
19455 }
19456
19457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19458         LDKDirectionalChannelInfo this_ptr_conv;
19459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19460         this_ptr_conv.is_owned = false;
19461         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
19462 }
19463
19464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19465         LDKDirectionalChannelInfo this_ptr_conv;
19466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19467         this_ptr_conv.is_owned = false;
19468         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
19469         return ret_val;
19470 }
19471
19472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19473         LDKDirectionalChannelInfo this_ptr_conv;
19474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19475         this_ptr_conv.is_owned = false;
19476         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
19477 }
19478
19479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
19480         LDKDirectionalChannelInfo this_ptr_conv;
19481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19482         this_ptr_conv.is_owned = false;
19483         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
19484         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19485         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19486         long ret_ref = (long)ret_var.inner;
19487         if (ret_var.is_owned) {
19488                 ret_ref |= 1;
19489         }
19490         return ret_ref;
19491 }
19492
19493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19494         LDKDirectionalChannelInfo this_ptr_conv;
19495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19496         this_ptr_conv.is_owned = false;
19497         LDKRoutingFees val_conv;
19498         val_conv.inner = (void*)(val & (~1));
19499         val_conv.is_owned = (val & 1) || (val == 0);
19500         val_conv = RoutingFees_clone(&val_conv);
19501         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
19502 }
19503
19504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
19505         LDKDirectionalChannelInfo this_ptr_conv;
19506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19507         this_ptr_conv.is_owned = false;
19508         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
19509         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19510         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19511         long ret_ref = (long)ret_var.inner;
19512         if (ret_var.is_owned) {
19513                 ret_ref |= 1;
19514         }
19515         return ret_ref;
19516 }
19517
19518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19519         LDKDirectionalChannelInfo this_ptr_conv;
19520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19521         this_ptr_conv.is_owned = false;
19522         LDKChannelUpdate val_conv;
19523         val_conv.inner = (void*)(val & (~1));
19524         val_conv.is_owned = (val & 1) || (val == 0);
19525         val_conv = ChannelUpdate_clone(&val_conv);
19526         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
19527 }
19528
19529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19530         LDKDirectionalChannelInfo orig_conv;
19531         orig_conv.inner = (void*)(orig & (~1));
19532         orig_conv.is_owned = false;
19533         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
19534         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19535         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19536         long ret_ref = (long)ret_var.inner;
19537         if (ret_var.is_owned) {
19538                 ret_ref |= 1;
19539         }
19540         return ret_ref;
19541 }
19542
19543 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
19544         LDKDirectionalChannelInfo obj_conv;
19545         obj_conv.inner = (void*)(obj & (~1));
19546         obj_conv.is_owned = false;
19547         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
19548         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19549         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19550         CVec_u8Z_free(ret_var);
19551         return ret_arr;
19552 }
19553
19554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19555         LDKu8slice ser_ref;
19556         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19557         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19558         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
19559         *ret_conv = DirectionalChannelInfo_read(ser_ref);
19560         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19561         return (long)ret_conv;
19562 }
19563
19564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19565         LDKChannelInfo this_obj_conv;
19566         this_obj_conv.inner = (void*)(this_obj & (~1));
19567         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19568         ChannelInfo_free(this_obj_conv);
19569 }
19570
19571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19572         LDKChannelInfo this_ptr_conv;
19573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19574         this_ptr_conv.is_owned = false;
19575         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
19576         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19577         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19578         long ret_ref = (long)ret_var.inner;
19579         if (ret_var.is_owned) {
19580                 ret_ref |= 1;
19581         }
19582         return ret_ref;
19583 }
19584
19585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19586         LDKChannelInfo this_ptr_conv;
19587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19588         this_ptr_conv.is_owned = false;
19589         LDKChannelFeatures val_conv;
19590         val_conv.inner = (void*)(val & (~1));
19591         val_conv.is_owned = (val & 1) || (val == 0);
19592         val_conv = ChannelFeatures_clone(&val_conv);
19593         ChannelInfo_set_features(&this_ptr_conv, val_conv);
19594 }
19595
19596 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
19597         LDKChannelInfo this_ptr_conv;
19598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19599         this_ptr_conv.is_owned = false;
19600         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19601         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
19602         return ret_arr;
19603 }
19604
19605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19606         LDKChannelInfo this_ptr_conv;
19607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19608         this_ptr_conv.is_owned = false;
19609         LDKPublicKey val_ref;
19610         CHECK((*env)->GetArrayLength(env, val) == 33);
19611         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19612         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
19613 }
19614
19615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
19616         LDKChannelInfo this_ptr_conv;
19617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19618         this_ptr_conv.is_owned = false;
19619         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
19620         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19621         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19622         long ret_ref = (long)ret_var.inner;
19623         if (ret_var.is_owned) {
19624                 ret_ref |= 1;
19625         }
19626         return ret_ref;
19627 }
19628
19629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19630         LDKChannelInfo this_ptr_conv;
19631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19632         this_ptr_conv.is_owned = false;
19633         LDKDirectionalChannelInfo val_conv;
19634         val_conv.inner = (void*)(val & (~1));
19635         val_conv.is_owned = (val & 1) || (val == 0);
19636         val_conv = DirectionalChannelInfo_clone(&val_conv);
19637         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
19638 }
19639
19640 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
19641         LDKChannelInfo this_ptr_conv;
19642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19643         this_ptr_conv.is_owned = false;
19644         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19645         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
19646         return ret_arr;
19647 }
19648
19649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19650         LDKChannelInfo this_ptr_conv;
19651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19652         this_ptr_conv.is_owned = false;
19653         LDKPublicKey val_ref;
19654         CHECK((*env)->GetArrayLength(env, val) == 33);
19655         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19656         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
19657 }
19658
19659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
19660         LDKChannelInfo this_ptr_conv;
19661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19662         this_ptr_conv.is_owned = false;
19663         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
19664         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19665         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19666         long ret_ref = (long)ret_var.inner;
19667         if (ret_var.is_owned) {
19668                 ret_ref |= 1;
19669         }
19670         return ret_ref;
19671 }
19672
19673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19674         LDKChannelInfo this_ptr_conv;
19675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19676         this_ptr_conv.is_owned = false;
19677         LDKDirectionalChannelInfo val_conv;
19678         val_conv.inner = (void*)(val & (~1));
19679         val_conv.is_owned = (val & 1) || (val == 0);
19680         val_conv = DirectionalChannelInfo_clone(&val_conv);
19681         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
19682 }
19683
19684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
19685         LDKChannelInfo this_ptr_conv;
19686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19687         this_ptr_conv.is_owned = false;
19688         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
19689         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19690         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19691         long ret_ref = (long)ret_var.inner;
19692         if (ret_var.is_owned) {
19693                 ret_ref |= 1;
19694         }
19695         return ret_ref;
19696 }
19697
19698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19699         LDKChannelInfo this_ptr_conv;
19700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19701         this_ptr_conv.is_owned = false;
19702         LDKChannelAnnouncement val_conv;
19703         val_conv.inner = (void*)(val & (~1));
19704         val_conv.is_owned = (val & 1) || (val == 0);
19705         val_conv = ChannelAnnouncement_clone(&val_conv);
19706         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
19707 }
19708
19709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19710         LDKChannelInfo orig_conv;
19711         orig_conv.inner = (void*)(orig & (~1));
19712         orig_conv.is_owned = false;
19713         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
19714         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19715         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19716         long ret_ref = (long)ret_var.inner;
19717         if (ret_var.is_owned) {
19718                 ret_ref |= 1;
19719         }
19720         return ret_ref;
19721 }
19722
19723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
19724         LDKChannelInfo obj_conv;
19725         obj_conv.inner = (void*)(obj & (~1));
19726         obj_conv.is_owned = false;
19727         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
19728         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19729         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19730         CVec_u8Z_free(ret_var);
19731         return ret_arr;
19732 }
19733
19734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19735         LDKu8slice ser_ref;
19736         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19737         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19738         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19739         *ret_conv = ChannelInfo_read(ser_ref);
19740         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19741         return (long)ret_conv;
19742 }
19743
19744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19745         LDKRoutingFees this_obj_conv;
19746         this_obj_conv.inner = (void*)(this_obj & (~1));
19747         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19748         RoutingFees_free(this_obj_conv);
19749 }
19750
19751 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19752         LDKRoutingFees this_ptr_conv;
19753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19754         this_ptr_conv.is_owned = false;
19755         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
19756         return ret_val;
19757 }
19758
19759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19760         LDKRoutingFees this_ptr_conv;
19761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19762         this_ptr_conv.is_owned = false;
19763         RoutingFees_set_base_msat(&this_ptr_conv, val);
19764 }
19765
19766 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
19767         LDKRoutingFees this_ptr_conv;
19768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19769         this_ptr_conv.is_owned = false;
19770         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
19771         return ret_val;
19772 }
19773
19774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19775         LDKRoutingFees this_ptr_conv;
19776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19777         this_ptr_conv.is_owned = false;
19778         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
19779 }
19780
19781 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) {
19782         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
19783         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19784         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19785         long ret_ref = (long)ret_var.inner;
19786         if (ret_var.is_owned) {
19787                 ret_ref |= 1;
19788         }
19789         return ret_ref;
19790 }
19791
19792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19793         LDKRoutingFees orig_conv;
19794         orig_conv.inner = (void*)(orig & (~1));
19795         orig_conv.is_owned = false;
19796         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
19797         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19798         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19799         long ret_ref = (long)ret_var.inner;
19800         if (ret_var.is_owned) {
19801                 ret_ref |= 1;
19802         }
19803         return ret_ref;
19804 }
19805
19806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19807         LDKu8slice ser_ref;
19808         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19809         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19810         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19811         *ret_conv = RoutingFees_read(ser_ref);
19812         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19813         return (long)ret_conv;
19814 }
19815
19816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
19817         LDKRoutingFees obj_conv;
19818         obj_conv.inner = (void*)(obj & (~1));
19819         obj_conv.is_owned = false;
19820         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
19821         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19822         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19823         CVec_u8Z_free(ret_var);
19824         return ret_arr;
19825 }
19826
19827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19828         LDKNodeAnnouncementInfo this_obj_conv;
19829         this_obj_conv.inner = (void*)(this_obj & (~1));
19830         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19831         NodeAnnouncementInfo_free(this_obj_conv);
19832 }
19833
19834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19835         LDKNodeAnnouncementInfo this_ptr_conv;
19836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19837         this_ptr_conv.is_owned = false;
19838         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
19839         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19840         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19841         long ret_ref = (long)ret_var.inner;
19842         if (ret_var.is_owned) {
19843                 ret_ref |= 1;
19844         }
19845         return ret_ref;
19846 }
19847
19848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19849         LDKNodeAnnouncementInfo this_ptr_conv;
19850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19851         this_ptr_conv.is_owned = false;
19852         LDKNodeFeatures val_conv;
19853         val_conv.inner = (void*)(val & (~1));
19854         val_conv.is_owned = (val & 1) || (val == 0);
19855         val_conv = NodeFeatures_clone(&val_conv);
19856         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
19857 }
19858
19859 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
19860         LDKNodeAnnouncementInfo this_ptr_conv;
19861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19862         this_ptr_conv.is_owned = false;
19863         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
19864         return ret_val;
19865 }
19866
19867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19868         LDKNodeAnnouncementInfo this_ptr_conv;
19869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19870         this_ptr_conv.is_owned = false;
19871         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
19872 }
19873
19874 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
19875         LDKNodeAnnouncementInfo this_ptr_conv;
19876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19877         this_ptr_conv.is_owned = false;
19878         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
19879         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
19880         return ret_arr;
19881 }
19882
19883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19884         LDKNodeAnnouncementInfo this_ptr_conv;
19885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19886         this_ptr_conv.is_owned = false;
19887         LDKThreeBytes val_ref;
19888         CHECK((*env)->GetArrayLength(env, val) == 3);
19889         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
19890         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
19891 }
19892
19893 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
19894         LDKNodeAnnouncementInfo this_ptr_conv;
19895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19896         this_ptr_conv.is_owned = false;
19897         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19898         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
19899         return ret_arr;
19900 }
19901
19902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19903         LDKNodeAnnouncementInfo this_ptr_conv;
19904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19905         this_ptr_conv.is_owned = false;
19906         LDKThirtyTwoBytes val_ref;
19907         CHECK((*env)->GetArrayLength(env, val) == 32);
19908         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19909         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
19910 }
19911
19912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19913         LDKNodeAnnouncementInfo this_ptr_conv;
19914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19915         this_ptr_conv.is_owned = false;
19916         LDKCVec_NetAddressZ val_constr;
19917         val_constr.datalen = (*env)->GetArrayLength(env, val);
19918         if (val_constr.datalen > 0)
19919                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19920         else
19921                 val_constr.data = NULL;
19922         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19923         for (size_t m = 0; m < val_constr.datalen; m++) {
19924                 int64_t val_conv_12 = val_vals[m];
19925                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
19926                 FREE((void*)val_conv_12);
19927                 val_constr.data[m] = val_conv_12_conv;
19928         }
19929         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19930         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
19931 }
19932
19933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
19934         LDKNodeAnnouncementInfo this_ptr_conv;
19935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19936         this_ptr_conv.is_owned = false;
19937         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
19938         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19939         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19940         long ret_ref = (long)ret_var.inner;
19941         if (ret_var.is_owned) {
19942                 ret_ref |= 1;
19943         }
19944         return ret_ref;
19945 }
19946
19947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19948         LDKNodeAnnouncementInfo this_ptr_conv;
19949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19950         this_ptr_conv.is_owned = false;
19951         LDKNodeAnnouncement val_conv;
19952         val_conv.inner = (void*)(val & (~1));
19953         val_conv.is_owned = (val & 1) || (val == 0);
19954         val_conv = NodeAnnouncement_clone(&val_conv);
19955         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
19956 }
19957
19958 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) {
19959         LDKNodeFeatures features_arg_conv;
19960         features_arg_conv.inner = (void*)(features_arg & (~1));
19961         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
19962         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
19963         LDKThreeBytes rgb_arg_ref;
19964         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
19965         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
19966         LDKThirtyTwoBytes alias_arg_ref;
19967         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
19968         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
19969         LDKCVec_NetAddressZ addresses_arg_constr;
19970         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
19971         if (addresses_arg_constr.datalen > 0)
19972                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19973         else
19974                 addresses_arg_constr.data = NULL;
19975         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
19976         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
19977                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
19978                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
19979                 FREE((void*)addresses_arg_conv_12);
19980                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
19981         }
19982         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
19983         LDKNodeAnnouncement announcement_message_arg_conv;
19984         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
19985         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
19986         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
19987         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
19988         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19989         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19990         long ret_ref = (long)ret_var.inner;
19991         if (ret_var.is_owned) {
19992                 ret_ref |= 1;
19993         }
19994         return ret_ref;
19995 }
19996
19997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19998         LDKNodeAnnouncementInfo orig_conv;
19999         orig_conv.inner = (void*)(orig & (~1));
20000         orig_conv.is_owned = false;
20001         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
20002         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20003         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20004         long ret_ref = (long)ret_var.inner;
20005         if (ret_var.is_owned) {
20006                 ret_ref |= 1;
20007         }
20008         return ret_ref;
20009 }
20010
20011 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
20012         LDKNodeAnnouncementInfo obj_conv;
20013         obj_conv.inner = (void*)(obj & (~1));
20014         obj_conv.is_owned = false;
20015         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
20016         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20017         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20018         CVec_u8Z_free(ret_var);
20019         return ret_arr;
20020 }
20021
20022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20023         LDKu8slice ser_ref;
20024         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20025         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20026         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20027         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
20028         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20029         return (long)ret_conv;
20030 }
20031
20032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20033         LDKNodeInfo this_obj_conv;
20034         this_obj_conv.inner = (void*)(this_obj & (~1));
20035         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20036         NodeInfo_free(this_obj_conv);
20037 }
20038
20039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20040         LDKNodeInfo this_ptr_conv;
20041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20042         this_ptr_conv.is_owned = false;
20043         LDKCVec_u64Z val_constr;
20044         val_constr.datalen = (*env)->GetArrayLength(env, val);
20045         if (val_constr.datalen > 0)
20046                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20047         else
20048                 val_constr.data = NULL;
20049         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20050         for (size_t g = 0; g < val_constr.datalen; g++) {
20051                 int64_t val_conv_6 = val_vals[g];
20052                 val_constr.data[g] = val_conv_6;
20053         }
20054         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20055         NodeInfo_set_channels(&this_ptr_conv, val_constr);
20056 }
20057
20058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
20059         LDKNodeInfo this_ptr_conv;
20060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20061         this_ptr_conv.is_owned = false;
20062         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
20063         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20064         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20065         long ret_ref = (long)ret_var.inner;
20066         if (ret_var.is_owned) {
20067                 ret_ref |= 1;
20068         }
20069         return ret_ref;
20070 }
20071
20072 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) {
20073         LDKNodeInfo this_ptr_conv;
20074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20075         this_ptr_conv.is_owned = false;
20076         LDKRoutingFees val_conv;
20077         val_conv.inner = (void*)(val & (~1));
20078         val_conv.is_owned = (val & 1) || (val == 0);
20079         val_conv = RoutingFees_clone(&val_conv);
20080         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
20081 }
20082
20083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
20084         LDKNodeInfo this_ptr_conv;
20085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20086         this_ptr_conv.is_owned = false;
20087         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
20088         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20089         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20090         long ret_ref = (long)ret_var.inner;
20091         if (ret_var.is_owned) {
20092                 ret_ref |= 1;
20093         }
20094         return ret_ref;
20095 }
20096
20097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20098         LDKNodeInfo this_ptr_conv;
20099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20100         this_ptr_conv.is_owned = false;
20101         LDKNodeAnnouncementInfo val_conv;
20102         val_conv.inner = (void*)(val & (~1));
20103         val_conv.is_owned = (val & 1) || (val == 0);
20104         val_conv = NodeAnnouncementInfo_clone(&val_conv);
20105         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
20106 }
20107
20108 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) {
20109         LDKCVec_u64Z channels_arg_constr;
20110         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
20111         if (channels_arg_constr.datalen > 0)
20112                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20113         else
20114                 channels_arg_constr.data = NULL;
20115         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
20116         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
20117                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
20118                 channels_arg_constr.data[g] = channels_arg_conv_6;
20119         }
20120         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
20121         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
20122         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
20123         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
20124         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
20125         LDKNodeAnnouncementInfo announcement_info_arg_conv;
20126         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
20127         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
20128         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
20129         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
20130         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20131         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20132         long ret_ref = (long)ret_var.inner;
20133         if (ret_var.is_owned) {
20134                 ret_ref |= 1;
20135         }
20136         return ret_ref;
20137 }
20138
20139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20140         LDKNodeInfo orig_conv;
20141         orig_conv.inner = (void*)(orig & (~1));
20142         orig_conv.is_owned = false;
20143         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
20144         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20145         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20146         long ret_ref = (long)ret_var.inner;
20147         if (ret_var.is_owned) {
20148                 ret_ref |= 1;
20149         }
20150         return ret_ref;
20151 }
20152
20153 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
20154         LDKNodeInfo obj_conv;
20155         obj_conv.inner = (void*)(obj & (~1));
20156         obj_conv.is_owned = false;
20157         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
20158         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20159         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20160         CVec_u8Z_free(ret_var);
20161         return ret_arr;
20162 }
20163
20164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20165         LDKu8slice ser_ref;
20166         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20167         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20168         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20169         *ret_conv = NodeInfo_read(ser_ref);
20170         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20171         return (long)ret_conv;
20172 }
20173
20174 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
20175         LDKNetworkGraph obj_conv;
20176         obj_conv.inner = (void*)(obj & (~1));
20177         obj_conv.is_owned = false;
20178         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
20179         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20180         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20181         CVec_u8Z_free(ret_var);
20182         return ret_arr;
20183 }
20184
20185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20186         LDKu8slice ser_ref;
20187         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20188         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20189         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20190         *ret_conv = NetworkGraph_read(ser_ref);
20191         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20192         return (long)ret_conv;
20193 }
20194
20195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
20196         LDKThirtyTwoBytes genesis_hash_ref;
20197         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
20198         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
20199         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
20200         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20201         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20202         long ret_ref = (long)ret_var.inner;
20203         if (ret_var.is_owned) {
20204                 ret_ref |= 1;
20205         }
20206         return ret_ref;
20207 }
20208
20209 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) {
20210         LDKNetworkGraph this_arg_conv;
20211         this_arg_conv.inner = (void*)(this_arg & (~1));
20212         this_arg_conv.is_owned = false;
20213         LDKNodeAnnouncement msg_conv;
20214         msg_conv.inner = (void*)(msg & (~1));
20215         msg_conv.is_owned = false;
20216         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20217         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
20218         return (long)ret_conv;
20219 }
20220
20221 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) {
20222         LDKNetworkGraph this_arg_conv;
20223         this_arg_conv.inner = (void*)(this_arg & (~1));
20224         this_arg_conv.is_owned = false;
20225         LDKUnsignedNodeAnnouncement msg_conv;
20226         msg_conv.inner = (void*)(msg & (~1));
20227         msg_conv.is_owned = false;
20228         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20229         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
20230         return (long)ret_conv;
20231 }
20232
20233 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) {
20234         LDKNetworkGraph this_arg_conv;
20235         this_arg_conv.inner = (void*)(this_arg & (~1));
20236         this_arg_conv.is_owned = false;
20237         LDKChannelAnnouncement msg_conv;
20238         msg_conv.inner = (void*)(msg & (~1));
20239         msg_conv.is_owned = false;
20240         LDKAccess *chain_access_conv_ptr = NULL;
20241         if (chain_access != 0) {
20242                 LDKAccess chain_access_conv;
20243                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20244                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
20245                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20246                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
20247                 }
20248                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20249                 *chain_access_conv_ptr = chain_access_conv;
20250         }
20251         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20252         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
20253         return (long)ret_conv;
20254 }
20255
20256 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) {
20257         LDKNetworkGraph this_arg_conv;
20258         this_arg_conv.inner = (void*)(this_arg & (~1));
20259         this_arg_conv.is_owned = false;
20260         LDKUnsignedChannelAnnouncement msg_conv;
20261         msg_conv.inner = (void*)(msg & (~1));
20262         msg_conv.is_owned = false;
20263         LDKAccess *chain_access_conv_ptr = NULL;
20264         if (chain_access != 0) {
20265                 LDKAccess chain_access_conv;
20266                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20267                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
20268                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20269                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
20270                 }
20271                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20272                 *chain_access_conv_ptr = chain_access_conv;
20273         }
20274         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20275         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
20276         return (long)ret_conv;
20277 }
20278
20279 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) {
20280         LDKNetworkGraph this_arg_conv;
20281         this_arg_conv.inner = (void*)(this_arg & (~1));
20282         this_arg_conv.is_owned = false;
20283         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
20284 }
20285
20286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
20287         LDKNetworkGraph this_arg_conv;
20288         this_arg_conv.inner = (void*)(this_arg & (~1));
20289         this_arg_conv.is_owned = false;
20290         LDKChannelUpdate msg_conv;
20291         msg_conv.inner = (void*)(msg & (~1));
20292         msg_conv.is_owned = false;
20293         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20294         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
20295         return (long)ret_conv;
20296 }
20297
20298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
20299         LDKNetworkGraph this_arg_conv;
20300         this_arg_conv.inner = (void*)(this_arg & (~1));
20301         this_arg_conv.is_owned = false;
20302         LDKUnsignedChannelUpdate msg_conv;
20303         msg_conv.inner = (void*)(msg & (~1));
20304         msg_conv.is_owned = false;
20305         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20306         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
20307         return (long)ret_conv;
20308 }
20309