Update auto-generated bindings
[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_B_clz = NULL;
116 static jclass arr_of_J_clz = NULL;
117 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
118         arr_of_B_clz = (*env)->FindClass(env, "[B");
119         CHECK(arr_of_B_clz != NULL);
120         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
121         arr_of_J_clz = (*env)->FindClass(env, "[J");
122         CHECK(arr_of_J_clz != NULL);
123         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_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 static jclass LDKCOption_u32Z_Some_class = NULL;
491 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
492 static jclass LDKCOption_u32Z_None_class = NULL;
493 static jmethodID LDKCOption_u32Z_None_meth = NULL;
494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
495         LDKCOption_u32Z_Some_class =
496                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
497         CHECK(LDKCOption_u32Z_Some_class != NULL);
498         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
499         CHECK(LDKCOption_u32Z_Some_meth != NULL);
500         LDKCOption_u32Z_None_class =
501                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
502         CHECK(LDKCOption_u32Z_None_class != NULL);
503         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
504         CHECK(LDKCOption_u32Z_None_meth != NULL);
505 }
506 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
507         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
508         switch(obj->tag) {
509                 case LDKCOption_u32Z_Some: {
510                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
511                 }
512                 case LDKCOption_u32Z_None: {
513                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
514                 }
515                 default: abort();
516         }
517 }
518 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
519         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
520 }
521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
522         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
523         CHECK(val->result_ok);
524         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
525         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
526         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
527         long res_ref = (long)res_var.inner & ~1;
528         return res_ref;
529 }
530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
531         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
532         CHECK(!val->result_ok);
533         LDKDecodeError err_var = (*val->contents.err);
534         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
535         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
536         long err_ref = (long)err_var.inner & ~1;
537         return err_ref;
538 }
539 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
540         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
541 }
542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
543         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
544         CHECK(val->result_ok);
545         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
546         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
547         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
548         long res_ref = (long)res_var.inner & ~1;
549         return res_ref;
550 }
551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
552         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
553         CHECK(!val->result_ok);
554         LDKDecodeError err_var = (*val->contents.err);
555         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
556         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
557         long err_ref = (long)err_var.inner & ~1;
558         return err_ref;
559 }
560 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
561         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
562 }
563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
564         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
565         CHECK(val->result_ok);
566         LDKChannelTransactionParameters res_var = (*val->contents.result);
567         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
568         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
569         long res_ref = (long)res_var.inner & ~1;
570         return res_ref;
571 }
572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
573         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
574         CHECK(!val->result_ok);
575         LDKDecodeError err_var = (*val->contents.err);
576         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
577         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
578         long err_ref = (long)err_var.inner & ~1;
579         return err_ref;
580 }
581 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
582         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
583 }
584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
585         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
586         CHECK(val->result_ok);
587         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
588         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
589         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
590         long res_ref = (long)res_var.inner & ~1;
591         return res_ref;
592 }
593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
594         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
595         CHECK(!val->result_ok);
596         LDKDecodeError err_var = (*val->contents.err);
597         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
598         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
599         long err_ref = (long)err_var.inner & ~1;
600         return err_ref;
601 }
602 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
603         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
604 }
605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
606         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
607         CHECK(val->result_ok);
608         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
609         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
610         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
611         long res_ref = (long)res_var.inner & ~1;
612         return res_ref;
613 }
614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
615         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
616         CHECK(!val->result_ok);
617         LDKDecodeError err_var = (*val->contents.err);
618         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
619         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
620         long err_ref = (long)err_var.inner & ~1;
621         return err_ref;
622 }
623 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
624         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
625 }
626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
627         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
628         CHECK(val->result_ok);
629         LDKCommitmentTransaction res_var = (*val->contents.result);
630         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
631         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
632         long res_ref = (long)res_var.inner & ~1;
633         return res_ref;
634 }
635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
636         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
637         CHECK(!val->result_ok);
638         LDKDecodeError err_var = (*val->contents.err);
639         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
640         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
641         long err_ref = (long)err_var.inner & ~1;
642         return err_ref;
643 }
644 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
645         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
646 }
647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
648         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
649         CHECK(val->result_ok);
650         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
651         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
652         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
653         long res_ref = (long)res_var.inner & ~1;
654         return res_ref;
655 }
656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
657         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
658         CHECK(!val->result_ok);
659         return *val->contents.err;
660 }
661 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
662         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
663 }
664 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
665         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
666         CHECK(val->result_ok);
667         LDKCVec_SignatureZ res_var = (*val->contents.result);
668         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
669         ;
670         for (size_t i = 0; i < res_var.datalen; i++) {
671                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
672                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
673                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
674         }
675         return res_arr;
676 }
677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
678         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
679         CHECK(!val->result_ok);
680         return *val->contents.err;
681 }
682 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
683 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
684 static jclass LDKErrorAction_IgnoreError_class = NULL;
685 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
686 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
687 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
689         LDKErrorAction_DisconnectPeer_class =
690                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
691         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
692         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
693         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
694         LDKErrorAction_IgnoreError_class =
695                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
696         CHECK(LDKErrorAction_IgnoreError_class != NULL);
697         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
698         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
699         LDKErrorAction_SendErrorMessage_class =
700                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
701         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
702         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
703         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
704 }
705 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
706         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
707         switch(obj->tag) {
708                 case LDKErrorAction_DisconnectPeer: {
709                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
710                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
711                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
712                         long msg_ref = (long)msg_var.inner & ~1;
713                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
714                 }
715                 case LDKErrorAction_IgnoreError: {
716                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
717                 }
718                 case LDKErrorAction_SendErrorMessage: {
719                         LDKErrorMessage msg_var = obj->send_error_message.msg;
720                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
721                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
722                         long msg_ref = (long)msg_var.inner & ~1;
723                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
724                 }
725                 default: abort();
726         }
727 }
728 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
729 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
730 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
731 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
732 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
733 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
735         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
736                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
737         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
738         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
739         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
740         LDKHTLCFailChannelUpdate_ChannelClosed_class =
741                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
742         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
743         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
744         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
745         LDKHTLCFailChannelUpdate_NodeFailure_class =
746                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
747         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
748         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
749         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
750 }
751 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
752         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
753         switch(obj->tag) {
754                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
755                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
756                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
757                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
758                         long msg_ref = (long)msg_var.inner & ~1;
759                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
760                 }
761                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
762                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
763                 }
764                 case LDKHTLCFailChannelUpdate_NodeFailure: {
765                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
766                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
767                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
768                 }
769                 default: abort();
770         }
771 }
772 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
773 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
774 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
775 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
776 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
777 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
778 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
779 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
780 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
781 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
782 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
783 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
784 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
785 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
786 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
787 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
788 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
789 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
790 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
791 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
792 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
793 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
794 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
795 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
796 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
797 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
798 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
799 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
800 static jclass LDKMessageSendEvent_HandleError_class = NULL;
801 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
802 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
803 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
804 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
805 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
806 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
807 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
808 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
809 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
811         LDKMessageSendEvent_SendAcceptChannel_class =
812                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
813         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
814         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
815         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
816         LDKMessageSendEvent_SendOpenChannel_class =
817                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
818         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
819         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
820         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
821         LDKMessageSendEvent_SendFundingCreated_class =
822                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
823         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
824         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
825         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
826         LDKMessageSendEvent_SendFundingSigned_class =
827                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
828         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
829         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
830         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
831         LDKMessageSendEvent_SendFundingLocked_class =
832                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
833         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
834         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
835         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
836         LDKMessageSendEvent_SendAnnouncementSignatures_class =
837                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
838         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
839         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
840         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
841         LDKMessageSendEvent_UpdateHTLCs_class =
842                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
843         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
844         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
845         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
846         LDKMessageSendEvent_SendRevokeAndACK_class =
847                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
848         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
849         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
850         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
851         LDKMessageSendEvent_SendClosingSigned_class =
852                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
853         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
854         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
855         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
856         LDKMessageSendEvent_SendShutdown_class =
857                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
858         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
859         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
860         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
861         LDKMessageSendEvent_SendChannelReestablish_class =
862                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
863         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
864         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
865         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
866         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
867                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
868         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
869         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
870         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
871         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
872                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
873         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
874         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
875         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
876         LDKMessageSendEvent_BroadcastChannelUpdate_class =
877                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
878         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
879         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
880         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
881         LDKMessageSendEvent_HandleError_class =
882                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
883         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
884         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
885         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
886         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
887                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
888         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
889         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
890         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
891         LDKMessageSendEvent_SendChannelRangeQuery_class =
892                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
893         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
894         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
895         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
896         LDKMessageSendEvent_SendShortIdsQuery_class =
897                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
898         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
899         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
900         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
901         LDKMessageSendEvent_SendReplyChannelRange_class =
902                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
903         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
904         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
905         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
906 }
907 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
908         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
909         switch(obj->tag) {
910                 case LDKMessageSendEvent_SendAcceptChannel: {
911                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
912                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
913                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
914                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
915                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
916                         long msg_ref = (long)msg_var.inner & ~1;
917                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
918                 }
919                 case LDKMessageSendEvent_SendOpenChannel: {
920                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
921                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
922                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
923                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
924                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
925                         long msg_ref = (long)msg_var.inner & ~1;
926                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
927                 }
928                 case LDKMessageSendEvent_SendFundingCreated: {
929                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
930                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
931                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
932                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
933                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
934                         long msg_ref = (long)msg_var.inner & ~1;
935                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
936                 }
937                 case LDKMessageSendEvent_SendFundingSigned: {
938                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
939                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
940                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
941                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
942                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
943                         long msg_ref = (long)msg_var.inner & ~1;
944                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
945                 }
946                 case LDKMessageSendEvent_SendFundingLocked: {
947                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
948                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
949                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
950                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
951                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
952                         long msg_ref = (long)msg_var.inner & ~1;
953                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
954                 }
955                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
956                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
957                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
958                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
959                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
960                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
961                         long msg_ref = (long)msg_var.inner & ~1;
962                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
963                 }
964                 case LDKMessageSendEvent_UpdateHTLCs: {
965                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
966                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
967                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
968                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
969                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
970                         long updates_ref = (long)updates_var.inner & ~1;
971                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
972                 }
973                 case LDKMessageSendEvent_SendRevokeAndACK: {
974                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
975                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
976                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
977                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
978                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
979                         long msg_ref = (long)msg_var.inner & ~1;
980                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
981                 }
982                 case LDKMessageSendEvent_SendClosingSigned: {
983                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
984                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
985                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
986                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
987                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
988                         long msg_ref = (long)msg_var.inner & ~1;
989                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
990                 }
991                 case LDKMessageSendEvent_SendShutdown: {
992                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
993                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
994                         LDKShutdown msg_var = obj->send_shutdown.msg;
995                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
996                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
997                         long msg_ref = (long)msg_var.inner & ~1;
998                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
999                 }
1000                 case LDKMessageSendEvent_SendChannelReestablish: {
1001                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1002                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1003                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1004                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1005                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1006                         long msg_ref = (long)msg_var.inner & ~1;
1007                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1008                 }
1009                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1010                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1011                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1012                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1013                         long msg_ref = (long)msg_var.inner & ~1;
1014                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1015                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1016                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1017                         long update_msg_ref = (long)update_msg_var.inner & ~1;
1018                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1019                 }
1020                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1021                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.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_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1026                 }
1027                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1028                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1029                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1030                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1031                         long msg_ref = (long)msg_var.inner & ~1;
1032                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1033                 }
1034                 case LDKMessageSendEvent_HandleError: {
1035                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1036                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1037                         long action_ref = ((long)&obj->handle_error.action) | 1;
1038                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1039                 }
1040                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1041                         long update_ref = ((long)&obj->payment_failure_network_update.update) | 1;
1042                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1043                 }
1044                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1045                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1046                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1047                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1048                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1049                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1050                         long msg_ref = (long)msg_var.inner & ~1;
1051                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1052                 }
1053                 case LDKMessageSendEvent_SendShortIdsQuery: {
1054                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1055                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1056                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1057                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1058                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1059                         long msg_ref = (long)msg_var.inner & ~1;
1060                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1061                 }
1062                 case LDKMessageSendEvent_SendReplyChannelRange: {
1063                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1064                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
1065                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1066                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1067                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1068                         long msg_ref = (long)msg_var.inner & ~1;
1069                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
1070                 }
1071                 default: abort();
1072         }
1073 }
1074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1075         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1076         ret->datalen = (*env)->GetArrayLength(env, elems);
1077         if (ret->datalen == 0) {
1078                 ret->data = NULL;
1079         } else {
1080                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1081                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1082                 for (size_t i = 0; i < ret->datalen; i++) {
1083                         int64_t arr_elem = java_elems[i];
1084                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1085                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1086                         ret->data[i] = arr_elem_conv;
1087                 }
1088                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1089         }
1090         return (long)ret;
1091 }
1092 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1093         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1094         for (size_t i = 0; i < ret.datalen; i++) {
1095                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1096         }
1097         return ret;
1098 }
1099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1100         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
1101 }
1102 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1103         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
1104         CHECK(val->result_ok);
1105         return *val->contents.result;
1106 }
1107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1108         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
1109         CHECK(!val->result_ok);
1110         LDKLightningError err_var = (*val->contents.err);
1111         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1112         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1113         long err_ref = (long)err_var.inner & ~1;
1114         return err_ref;
1115 }
1116 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) {
1117         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
1118         LDKChannelAnnouncement a_conv;
1119         a_conv.inner = (void*)(a & (~1));
1120         a_conv.is_owned = (a & 1) || (a == 0);
1121         a_conv = ChannelAnnouncement_clone(&a_conv);
1122         ret->a = a_conv;
1123         LDKChannelUpdate b_conv;
1124         b_conv.inner = (void*)(b & (~1));
1125         b_conv.is_owned = (b & 1) || (b == 0);
1126         b_conv = ChannelUpdate_clone(&b_conv);
1127         ret->b = b_conv;
1128         LDKChannelUpdate c_conv;
1129         c_conv.inner = (void*)(c & (~1));
1130         c_conv.is_owned = (c & 1) || (c == 0);
1131         c_conv = ChannelUpdate_clone(&c_conv);
1132         ret->c = c_conv;
1133         return (long)ret;
1134 }
1135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1136         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
1137         LDKChannelAnnouncement a_var = tuple->a;
1138         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1139         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1140         long a_ref = (long)a_var.inner & ~1;
1141         return a_ref;
1142 }
1143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1144         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
1145         LDKChannelUpdate b_var = tuple->b;
1146         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1147         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1148         long b_ref = (long)b_var.inner & ~1;
1149         return b_ref;
1150 }
1151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
1152         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
1153         LDKChannelUpdate c_var = tuple->c;
1154         CHECK((((long)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1155         CHECK((((long)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1156         long c_ref = (long)c_var.inner & ~1;
1157         return c_ref;
1158 }
1159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1160         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
1161         ret->datalen = (*env)->GetArrayLength(env, elems);
1162         if (ret->datalen == 0) {
1163                 ret->data = NULL;
1164         } else {
1165                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
1166                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1167                 for (size_t i = 0; i < ret->datalen; i++) {
1168                         int64_t arr_elem = java_elems[i];
1169                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
1170                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
1171                         ret->data[i] = arr_elem_conv;
1172                 }
1173                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1174         }
1175         return (long)ret;
1176 }
1177 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
1178         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
1179         for (size_t i = 0; i < ret.datalen; i++) {
1180                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
1181         }
1182         return ret;
1183 }
1184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1185         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
1186         ret->datalen = (*env)->GetArrayLength(env, elems);
1187         if (ret->datalen == 0) {
1188                 ret->data = NULL;
1189         } else {
1190                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
1191                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1192                 for (size_t i = 0; i < ret->datalen; i++) {
1193                         int64_t arr_elem = java_elems[i];
1194                         LDKNodeAnnouncement arr_elem_conv;
1195                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1196                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1197                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
1198                         ret->data[i] = arr_elem_conv;
1199                 }
1200                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1201         }
1202         return (long)ret;
1203 }
1204 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
1205         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
1206         for (size_t i = 0; i < ret.datalen; i++) {
1207                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
1208         }
1209         return ret;
1210 }
1211 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1212         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
1213 }
1214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1215         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
1216         CHECK(val->result_ok);
1217         return *val->contents.result;
1218 }
1219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1220         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
1221         CHECK(!val->result_ok);
1222         LDKLightningError err_var = (*val->contents.err);
1223         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1224         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1225         long err_ref = (long)err_var.inner & ~1;
1226         return err_ref;
1227 }
1228 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1229         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
1230 }
1231 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1232         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
1233         CHECK(val->result_ok);
1234         LDKCVec_u8Z res_var = (*val->contents.result);
1235         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
1236         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
1237         return res_arr;
1238 }
1239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1240         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
1241         CHECK(!val->result_ok);
1242         LDKPeerHandleError err_var = (*val->contents.err);
1243         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1244         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1245         long err_ref = (long)err_var.inner & ~1;
1246         return err_ref;
1247 }
1248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1249         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
1250 }
1251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1252         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
1253         CHECK(val->result_ok);
1254         return *val->contents.result;
1255 }
1256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1257         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
1258         CHECK(!val->result_ok);
1259         LDKPeerHandleError err_var = (*val->contents.err);
1260         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1261         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1262         long err_ref = (long)err_var.inner & ~1;
1263         return err_ref;
1264 }
1265 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1266         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
1267 }
1268 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1269         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
1270         CHECK(val->result_ok);
1271         return *val->contents.result;
1272 }
1273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1274         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
1275         CHECK(!val->result_ok);
1276         LDKPeerHandleError err_var = (*val->contents.err);
1277         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1278         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1279         long err_ref = (long)err_var.inner & ~1;
1280         return err_ref;
1281 }
1282 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1283         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1284 }
1285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1286         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1287         CHECK(val->result_ok);
1288         LDKInitFeatures res_var = (*val->contents.result);
1289         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1290         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1291         long res_ref = (long)res_var.inner & ~1;
1292         return res_ref;
1293 }
1294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1295         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1296         CHECK(!val->result_ok);
1297         LDKDecodeError err_var = (*val->contents.err);
1298         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1299         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1300         long err_ref = (long)err_var.inner & ~1;
1301         return err_ref;
1302 }
1303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1304         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1305 }
1306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1307         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1308         CHECK(val->result_ok);
1309         LDKNodeFeatures res_var = (*val->contents.result);
1310         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1311         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1312         long res_ref = (long)res_var.inner & ~1;
1313         return res_ref;
1314 }
1315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1316         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1317         CHECK(!val->result_ok);
1318         LDKDecodeError err_var = (*val->contents.err);
1319         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1320         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1321         long err_ref = (long)err_var.inner & ~1;
1322         return err_ref;
1323 }
1324 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1325         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1326 }
1327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1328         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1329         CHECK(val->result_ok);
1330         LDKChannelFeatures res_var = (*val->contents.result);
1331         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1332         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1333         long res_ref = (long)res_var.inner & ~1;
1334         return res_ref;
1335 }
1336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1337         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1338         CHECK(!val->result_ok);
1339         LDKDecodeError err_var = (*val->contents.err);
1340         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1341         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1342         long err_ref = (long)err_var.inner & ~1;
1343         return err_ref;
1344 }
1345 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1346         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1347 }
1348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1349         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1350         CHECK(val->result_ok);
1351         LDKInvoiceFeatures res_var = (*val->contents.result);
1352         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1353         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1354         long res_ref = (long)res_var.inner & ~1;
1355         return res_ref;
1356 }
1357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1358         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1359         CHECK(!val->result_ok);
1360         LDKDecodeError err_var = (*val->contents.err);
1361         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1362         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1363         long err_ref = (long)err_var.inner & ~1;
1364         return err_ref;
1365 }
1366 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1367         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
1368 }
1369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1370         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
1371         CHECK(val->result_ok);
1372         LDKChannelConfig res_var = (*val->contents.result);
1373         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1374         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1375         long res_ref = (long)res_var.inner & ~1;
1376         return res_ref;
1377 }
1378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1379         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
1380         CHECK(!val->result_ok);
1381         LDKDecodeError err_var = (*val->contents.err);
1382         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1383         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1384         long err_ref = (long)err_var.inner & ~1;
1385         return err_ref;
1386 }
1387 static jclass LDKCOption_u64Z_Some_class = NULL;
1388 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1389 static jclass LDKCOption_u64Z_None_class = NULL;
1390 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1392         LDKCOption_u64Z_Some_class =
1393                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1394         CHECK(LDKCOption_u64Z_Some_class != NULL);
1395         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1396         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1397         LDKCOption_u64Z_None_class =
1398                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1399         CHECK(LDKCOption_u64Z_None_class != NULL);
1400         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1401         CHECK(LDKCOption_u64Z_None_meth != NULL);
1402 }
1403 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1404         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1405         switch(obj->tag) {
1406                 case LDKCOption_u64Z_Some: {
1407                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1408                 }
1409                 case LDKCOption_u64Z_None: {
1410                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1411                 }
1412                 default: abort();
1413         }
1414 }
1415 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1416         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
1417 }
1418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1419         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
1420         CHECK(val->result_ok);
1421         LDKDirectionalChannelInfo res_var = (*val->contents.result);
1422         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1423         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1424         long res_ref = (long)res_var.inner & ~1;
1425         return res_ref;
1426 }
1427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1428         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
1429         CHECK(!val->result_ok);
1430         LDKDecodeError err_var = (*val->contents.err);
1431         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1432         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1433         long err_ref = (long)err_var.inner & ~1;
1434         return err_ref;
1435 }
1436 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1437         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
1438 }
1439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1440         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
1441         CHECK(val->result_ok);
1442         LDKChannelInfo res_var = (*val->contents.result);
1443         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1444         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1445         long res_ref = (long)res_var.inner & ~1;
1446         return res_ref;
1447 }
1448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1449         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
1450         CHECK(!val->result_ok);
1451         LDKDecodeError err_var = (*val->contents.err);
1452         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1453         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1454         long err_ref = (long)err_var.inner & ~1;
1455         return err_ref;
1456 }
1457 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1458         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
1459 }
1460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1461         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
1462         CHECK(val->result_ok);
1463         LDKRoutingFees res_var = (*val->contents.result);
1464         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1465         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1466         long res_ref = (long)res_var.inner & ~1;
1467         return res_ref;
1468 }
1469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1470         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
1471         CHECK(!val->result_ok);
1472         LDKDecodeError err_var = (*val->contents.err);
1473         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1474         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1475         long err_ref = (long)err_var.inner & ~1;
1476         return err_ref;
1477 }
1478 static jclass LDKNetAddress_IPv4_class = NULL;
1479 static jmethodID LDKNetAddress_IPv4_meth = NULL;
1480 static jclass LDKNetAddress_IPv6_class = NULL;
1481 static jmethodID LDKNetAddress_IPv6_meth = NULL;
1482 static jclass LDKNetAddress_OnionV2_class = NULL;
1483 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
1484 static jclass LDKNetAddress_OnionV3_class = NULL;
1485 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
1486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
1487         LDKNetAddress_IPv4_class =
1488                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
1489         CHECK(LDKNetAddress_IPv4_class != NULL);
1490         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
1491         CHECK(LDKNetAddress_IPv4_meth != NULL);
1492         LDKNetAddress_IPv6_class =
1493                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
1494         CHECK(LDKNetAddress_IPv6_class != NULL);
1495         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
1496         CHECK(LDKNetAddress_IPv6_meth != NULL);
1497         LDKNetAddress_OnionV2_class =
1498                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
1499         CHECK(LDKNetAddress_OnionV2_class != NULL);
1500         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
1501         CHECK(LDKNetAddress_OnionV2_meth != NULL);
1502         LDKNetAddress_OnionV3_class =
1503                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
1504         CHECK(LDKNetAddress_OnionV3_class != NULL);
1505         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
1506         CHECK(LDKNetAddress_OnionV3_meth != NULL);
1507 }
1508 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1509         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
1510         switch(obj->tag) {
1511                 case LDKNetAddress_IPv4: {
1512                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
1513                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
1514                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
1515                 }
1516                 case LDKNetAddress_IPv6: {
1517                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
1518                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
1519                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
1520                 }
1521                 case LDKNetAddress_OnionV2: {
1522                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
1523                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
1524                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
1525                 }
1526                 case LDKNetAddress_OnionV3: {
1527                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
1528                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
1529                         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);
1530                 }
1531                 default: abort();
1532         }
1533 }
1534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1535         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
1536         ret->datalen = (*env)->GetArrayLength(env, elems);
1537         if (ret->datalen == 0) {
1538                 ret->data = NULL;
1539         } else {
1540                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
1541                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1542                 for (size_t i = 0; i < ret->datalen; i++) {
1543                         int64_t arr_elem = java_elems[i];
1544                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
1545                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
1546                         ret->data[i] = arr_elem_conv;
1547                 }
1548                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1549         }
1550         return (long)ret;
1551 }
1552 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
1553         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
1554         for (size_t i = 0; i < ret.datalen; i++) {
1555                 ret.data[i] = NetAddress_clone(&orig->data[i]);
1556         }
1557         return ret;
1558 }
1559 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1560         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
1561 }
1562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1563         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
1564         CHECK(val->result_ok);
1565         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
1566         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1567         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1568         long res_ref = (long)res_var.inner & ~1;
1569         return res_ref;
1570 }
1571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1572         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
1573         CHECK(!val->result_ok);
1574         LDKDecodeError err_var = (*val->contents.err);
1575         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1576         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1577         long err_ref = (long)err_var.inner & ~1;
1578         return err_ref;
1579 }
1580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1581         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
1582         ret->datalen = (*env)->GetArrayLength(env, elems);
1583         if (ret->datalen == 0) {
1584                 ret->data = NULL;
1585         } else {
1586                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
1587                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1588                 for (size_t i = 0; i < ret->datalen; i++) {
1589                         ret->data[i] = java_elems[i];
1590                 }
1591                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1592         }
1593         return (long)ret;
1594 }
1595 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1596         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1597         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1598         return ret;
1599 }
1600 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1601         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
1602 }
1603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1604         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
1605         CHECK(val->result_ok);
1606         LDKNodeInfo res_var = (*val->contents.result);
1607         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1608         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1609         long res_ref = (long)res_var.inner & ~1;
1610         return res_ref;
1611 }
1612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1613         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
1614         CHECK(!val->result_ok);
1615         LDKDecodeError err_var = (*val->contents.err);
1616         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1617         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1618         long err_ref = (long)err_var.inner & ~1;
1619         return err_ref;
1620 }
1621 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1622         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
1623 }
1624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1625         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
1626         CHECK(val->result_ok);
1627         LDKNetworkGraph res_var = (*val->contents.result);
1628         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1629         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1630         long res_ref = (long)res_var.inner & ~1;
1631         return res_ref;
1632 }
1633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1634         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
1635         CHECK(!val->result_ok);
1636         LDKDecodeError err_var = (*val->contents.err);
1637         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1638         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1639         long err_ref = (long)err_var.inner & ~1;
1640         return err_ref;
1641 }
1642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1643         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1644         ret->a = a;
1645         LDKTransaction b_ref;
1646         b_ref.datalen = (*env)->GetArrayLength(env, b);
1647         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1648         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1649         b_ref.data_is_owned = false;
1650         ret->b = b_ref;
1651         return (long)ret;
1652 }
1653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1654         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1655         return tuple->a;
1656 }
1657 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1658         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1659         LDKTransaction b_var = tuple->b;
1660         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1661         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1662         return b_arr;
1663 }
1664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1665         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1666         ret->datalen = (*env)->GetArrayLength(env, elems);
1667         if (ret->datalen == 0) {
1668                 ret->data = NULL;
1669         } else {
1670                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1671                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1672                 for (size_t i = 0; i < ret->datalen; i++) {
1673                         int64_t arr_elem = java_elems[i];
1674                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1675                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
1676                         ret->data[i] = arr_elem_conv;
1677                 }
1678                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1679         }
1680         return (long)ret;
1681 }
1682 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1683         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1684 }
1685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1686         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1687         CHECK(val->result_ok);
1688         return *val->contents.result;
1689 }
1690 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1691         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1692         CHECK(!val->result_ok);
1693         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1694         return err_conv;
1695 }
1696 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1697 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1698 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1699 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1701         LDKMonitorEvent_HTLCEvent_class =
1702                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1703         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1704         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1705         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1706         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1707                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1708         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1709         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "(J)V");
1710         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1711 }
1712 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1713         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1714         switch(obj->tag) {
1715                 case LDKMonitorEvent_HTLCEvent: {
1716                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1717                         CHECK((((long)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1718                         CHECK((((long)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1719                         long htlc_event_ref = (long)htlc_event_var.inner & ~1;
1720                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1721                 }
1722                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1723                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
1724                         CHECK((((long)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1725                         CHECK((((long)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1726                         long commitment_tx_broadcasted_ref = (long)commitment_tx_broadcasted_var.inner & ~1;
1727                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref);
1728                 }
1729                 default: abort();
1730         }
1731 }
1732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1733         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1734         ret->datalen = (*env)->GetArrayLength(env, elems);
1735         if (ret->datalen == 0) {
1736                 ret->data = NULL;
1737         } else {
1738                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1739                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1740                 for (size_t i = 0; i < ret->datalen; i++) {
1741                         int64_t arr_elem = java_elems[i];
1742                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1743                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1744                         ret->data[i] = arr_elem_conv;
1745                 }
1746                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1747         }
1748         return (long)ret;
1749 }
1750 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1751         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1752         for (size_t i = 0; i < ret.datalen; i++) {
1753                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1754         }
1755         return ret;
1756 }
1757 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1758 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1759 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1760 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1761 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1762 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1764         LDKSpendableOutputDescriptor_StaticOutput_class =
1765                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1766         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1767         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1768         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1769         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1770                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1771         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1772         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1773         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1774         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1775                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1776         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1777         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1778         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1779 }
1780 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1781         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1782         switch(obj->tag) {
1783                 case LDKSpendableOutputDescriptor_StaticOutput: {
1784                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1785                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1786                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1787                         long outpoint_ref = (long)outpoint_var.inner & ~1;
1788                         long output_ref = ((long)&obj->static_output.output) | 1;
1789                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (long)output_ref);
1790                 }
1791                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1792                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1793                         CHECK((((long)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1794                         CHECK((((long)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1795                         long delayed_payment_output_ref = (long)delayed_payment_output_var.inner & ~1;
1796                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1797                 }
1798                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1799                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1800                         CHECK((((long)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1801                         CHECK((((long)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1802                         long static_payment_output_ref = (long)static_payment_output_var.inner & ~1;
1803                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1804                 }
1805                 default: abort();
1806         }
1807 }
1808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1809         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1810         ret->datalen = (*env)->GetArrayLength(env, elems);
1811         if (ret->datalen == 0) {
1812                 ret->data = NULL;
1813         } else {
1814                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1815                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1816                 for (size_t i = 0; i < ret->datalen; i++) {
1817                         int64_t arr_elem = java_elems[i];
1818                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1819                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1820                         ret->data[i] = arr_elem_conv;
1821                 }
1822                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1823         }
1824         return (long)ret;
1825 }
1826 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1827         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1828         for (size_t i = 0; i < ret.datalen; i++) {
1829                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1830         }
1831         return ret;
1832 }
1833 static jclass LDKEvent_FundingGenerationReady_class = NULL;
1834 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
1835 static jclass LDKEvent_FundingBroadcastSafe_class = NULL;
1836 static jmethodID LDKEvent_FundingBroadcastSafe_meth = NULL;
1837 static jclass LDKEvent_PaymentReceived_class = NULL;
1838 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
1839 static jclass LDKEvent_PaymentSent_class = NULL;
1840 static jmethodID LDKEvent_PaymentSent_meth = NULL;
1841 static jclass LDKEvent_PaymentFailed_class = NULL;
1842 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
1843 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
1844 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
1845 static jclass LDKEvent_SpendableOutputs_class = NULL;
1846 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
1847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
1848         LDKEvent_FundingGenerationReady_class =
1849                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
1850         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
1851         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
1852         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
1853         LDKEvent_FundingBroadcastSafe_class =
1854                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingBroadcastSafe;"));
1855         CHECK(LDKEvent_FundingBroadcastSafe_class != NULL);
1856         LDKEvent_FundingBroadcastSafe_meth = (*env)->GetMethodID(env, LDKEvent_FundingBroadcastSafe_class, "<init>", "(JJ)V");
1857         CHECK(LDKEvent_FundingBroadcastSafe_meth != NULL);
1858         LDKEvent_PaymentReceived_class =
1859                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
1860         CHECK(LDKEvent_PaymentReceived_class != NULL);
1861         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[BJ)V");
1862         CHECK(LDKEvent_PaymentReceived_meth != NULL);
1863         LDKEvent_PaymentSent_class =
1864                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
1865         CHECK(LDKEvent_PaymentSent_class != NULL);
1866         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
1867         CHECK(LDKEvent_PaymentSent_meth != NULL);
1868         LDKEvent_PaymentFailed_class =
1869                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
1870         CHECK(LDKEvent_PaymentFailed_class != NULL);
1871         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
1872         CHECK(LDKEvent_PaymentFailed_meth != NULL);
1873         LDKEvent_PendingHTLCsForwardable_class =
1874                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
1875         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
1876         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
1877         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
1878         LDKEvent_SpendableOutputs_class =
1879                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
1880         CHECK(LDKEvent_SpendableOutputs_class != NULL);
1881         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
1882         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
1883 }
1884 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1885         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1886         switch(obj->tag) {
1887                 case LDKEvent_FundingGenerationReady: {
1888                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
1889                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
1890                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1891                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
1892                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
1893                         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);
1894                 }
1895                 case LDKEvent_FundingBroadcastSafe: {
1896                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
1897                         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1898                         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1899                         long funding_txo_ref = (long)funding_txo_var.inner & ~1;
1900                         return (*env)->NewObject(env, LDKEvent_FundingBroadcastSafe_class, LDKEvent_FundingBroadcastSafe_meth, funding_txo_ref, obj->funding_broadcast_safe.user_channel_id);
1901                 }
1902                 case LDKEvent_PaymentReceived: {
1903                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1904                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
1905                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1906                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
1907                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_secret_arr, obj->payment_received.amt);
1908                 }
1909                 case LDKEvent_PaymentSent: {
1910                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1911                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
1912                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
1913                 }
1914                 case LDKEvent_PaymentFailed: {
1915                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1916                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
1917                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
1918                 }
1919                 case LDKEvent_PendingHTLCsForwardable: {
1920                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
1921                 }
1922                 case LDKEvent_SpendableOutputs: {
1923                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1924                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
1925                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
1926                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1927                                 long outputs_conv_27_ref = ((long)&outputs_var.data[b]) | 1;
1928                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1929                         }
1930                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
1931                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
1932                 }
1933                 default: abort();
1934         }
1935 }
1936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1937         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
1938         ret->datalen = (*env)->GetArrayLength(env, elems);
1939         if (ret->datalen == 0) {
1940                 ret->data = NULL;
1941         } else {
1942                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
1943                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1944                 for (size_t i = 0; i < ret->datalen; i++) {
1945                         int64_t arr_elem = java_elems[i];
1946                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
1947                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
1948                         ret->data[i] = arr_elem_conv;
1949                 }
1950                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1951         }
1952         return (long)ret;
1953 }
1954 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
1955         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
1956         for (size_t i = 0; i < ret.datalen; i++) {
1957                 ret.data[i] = Event_clone(&orig->data[i]);
1958         }
1959         return ret;
1960 }
1961 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1962         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
1963 }
1964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1965         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
1966         CHECK(val->result_ok);
1967         LDKOutPoint res_var = (*val->contents.result);
1968         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1969         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1970         long res_ref = (long)res_var.inner & ~1;
1971         return res_ref;
1972 }
1973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1974         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
1975         CHECK(!val->result_ok);
1976         LDKDecodeError err_var = (*val->contents.err);
1977         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1978         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1979         long err_ref = (long)err_var.inner & ~1;
1980         return err_ref;
1981 }
1982 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1983         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
1984 }
1985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1986         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
1987         CHECK(val->result_ok);
1988         LDKChannelMonitorUpdate res_var = (*val->contents.result);
1989         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1990         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1991         long res_ref = (long)res_var.inner & ~1;
1992         return res_ref;
1993 }
1994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1995         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
1996         CHECK(!val->result_ok);
1997         LDKDecodeError err_var = (*val->contents.err);
1998         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1999         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2000         long err_ref = (long)err_var.inner & ~1;
2001         return err_ref;
2002 }
2003 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2004         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
2005 }
2006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2007         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
2008         CHECK(val->result_ok);
2009         LDKHTLCUpdate res_var = (*val->contents.result);
2010         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2011         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2012         long res_ref = (long)res_var.inner & ~1;
2013         return res_ref;
2014 }
2015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2016         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
2017         CHECK(!val->result_ok);
2018         LDKDecodeError err_var = (*val->contents.err);
2019         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2020         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2021         long err_ref = (long)err_var.inner & ~1;
2022         return err_ref;
2023 }
2024 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2025         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
2026 }
2027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2028         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
2029         CHECK(val->result_ok);
2030         return *val->contents.result;
2031 }
2032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2033         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
2034         CHECK(!val->result_ok);
2035         LDKMonitorUpdateError err_var = (*val->contents.err);
2036         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2037         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2038         long err_ref = (long)err_var.inner & ~1;
2039         return err_ref;
2040 }
2041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
2042         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
2043         LDKOutPoint a_conv;
2044         a_conv.inner = (void*)(a & (~1));
2045         a_conv.is_owned = (a & 1) || (a == 0);
2046         a_conv = OutPoint_clone(&a_conv);
2047         ret->a = a_conv;
2048         LDKCVec_u8Z b_ref;
2049         b_ref.datalen = (*env)->GetArrayLength(env, b);
2050         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
2051         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
2052         ret->b = b_ref;
2053         return (long)ret;
2054 }
2055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2056         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
2057         LDKOutPoint a_var = tuple->a;
2058         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2059         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2060         long a_ref = (long)a_var.inner & ~1;
2061         return a_ref;
2062 }
2063 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2064         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
2065         LDKCVec_u8Z b_var = tuple->b;
2066         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
2067         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
2068         return b_arr;
2069 }
2070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
2071         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
2072         ret->a = a;
2073         LDKCVec_u8Z b_ref;
2074         b_ref.datalen = (*env)->GetArrayLength(env, b);
2075         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
2076         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
2077         ret->b = b_ref;
2078         return (long)ret;
2079 }
2080 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2081         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
2082         return tuple->a;
2083 }
2084 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2085         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
2086         LDKCVec_u8Z b_var = tuple->b;
2087         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
2088         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
2089         return b_arr;
2090 }
2091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2092         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
2093         ret->datalen = (*env)->GetArrayLength(env, elems);
2094         if (ret->datalen == 0) {
2095                 ret->data = NULL;
2096         } else {
2097                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
2098                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2099                 for (size_t i = 0; i < ret->datalen; i++) {
2100                         int64_t arr_elem = java_elems[i];
2101                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
2102                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
2103                         ret->data[i] = arr_elem_conv;
2104                 }
2105                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2106         }
2107         return (long)ret;
2108 }
2109 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
2110         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
2111         for (size_t i = 0; i < ret.datalen; i++) {
2112                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
2113         }
2114         return ret;
2115 }
2116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
2117         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
2118         LDKThirtyTwoBytes a_ref;
2119         CHECK((*env)->GetArrayLength(env, a) == 32);
2120         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2121         ret->a = a_ref;
2122         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
2123         b_constr.datalen = (*env)->GetArrayLength(env, b);
2124         if (b_constr.datalen > 0)
2125                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
2126         else
2127                 b_constr.data = NULL;
2128         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
2129         for (size_t b = 0; b < b_constr.datalen; b++) {
2130                 int64_t b_conv_27 = b_vals[b];
2131                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
2132                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
2133                 b_constr.data[b] = b_conv_27_conv;
2134         }
2135         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
2136         ret->b = b_constr;
2137         return (long)ret;
2138 }
2139 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2140         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
2141         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2142         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2143         return a_arr;
2144 }
2145 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2146         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
2147         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
2148         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
2149         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
2150         for (size_t b = 0; b < b_var.datalen; b++) {
2151                 long b_conv_27_ref = (long)(&b_var.data[b]) | 1;
2152                 b_arr_ptr[b] = b_conv_27_ref;
2153         }
2154         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
2155         return b_arr;
2156 }
2157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2158         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
2159         ret->datalen = (*env)->GetArrayLength(env, elems);
2160         if (ret->datalen == 0) {
2161                 ret->data = NULL;
2162         } else {
2163                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
2164                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2165                 for (size_t i = 0; i < ret->datalen; i++) {
2166                         int64_t arr_elem = java_elems[i];
2167                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
2168                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ
2169                         ret->data[i] = arr_elem_conv;
2170                 }
2171                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2172         }
2173         return (long)ret;
2174 }
2175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
2176         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
2177         ret->a = a;
2178         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
2179         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
2180         ret->b = b_conv;
2181         return (long)ret;
2182 }
2183 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2184         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
2185         return tuple->a;
2186 }
2187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2188         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
2189         long b_ref = ((long)&tuple->b) | 1;
2190         return (long)b_ref;
2191 }
2192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2193         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
2194         ret->datalen = (*env)->GetArrayLength(env, elems);
2195         if (ret->datalen == 0) {
2196                 ret->data = NULL;
2197         } else {
2198                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
2199                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2200                 for (size_t i = 0; i < ret->datalen; i++) {
2201                         int64_t arr_elem = java_elems[i];
2202                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
2203                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
2204                         ret->data[i] = arr_elem_conv;
2205                 }
2206                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2207         }
2208         return (long)ret;
2209 }
2210 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
2211         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
2212         for (size_t i = 0; i < ret.datalen; i++) {
2213                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
2214         }
2215         return ret;
2216 }
2217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
2218         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
2219         LDKThirtyTwoBytes a_ref;
2220         CHECK((*env)->GetArrayLength(env, a) == 32);
2221         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2222         ret->a = a_ref;
2223         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
2224         b_constr.datalen = (*env)->GetArrayLength(env, b);
2225         if (b_constr.datalen > 0)
2226                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
2227         else
2228                 b_constr.data = NULL;
2229         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
2230         for (size_t a = 0; a < b_constr.datalen; a++) {
2231                 int64_t b_conv_26 = b_vals[a];
2232                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
2233                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
2234                 b_constr.data[a] = b_conv_26_conv;
2235         }
2236         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
2237         ret->b = b_constr;
2238         return (long)ret;
2239 }
2240 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2241         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
2242         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2243         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2244         return a_arr;
2245 }
2246 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2247         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
2248         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
2249         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
2250         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
2251         for (size_t a = 0; a < b_var.datalen; a++) {
2252                 long b_conv_26_ref = (long)(&b_var.data[a]) | 1;
2253                 b_arr_ptr[a] = b_conv_26_ref;
2254         }
2255         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
2256         return b_arr;
2257 }
2258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2259         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
2260         ret->datalen = (*env)->GetArrayLength(env, elems);
2261         if (ret->datalen == 0) {
2262                 ret->data = NULL;
2263         } else {
2264                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
2265                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2266                 for (size_t i = 0; i < ret->datalen; i++) {
2267                         int64_t arr_elem = java_elems[i];
2268                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
2269                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ
2270                         ret->data[i] = arr_elem_conv;
2271                 }
2272                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2273         }
2274         return (long)ret;
2275 }
2276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2277         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2278         LDKSignature a_ref;
2279         CHECK((*env)->GetArrayLength(env, a) == 64);
2280         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2281         ret->a = a_ref;
2282         LDKCVec_SignatureZ b_constr;
2283         b_constr.datalen = (*env)->GetArrayLength(env, b);
2284         if (b_constr.datalen > 0)
2285                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2286         else
2287                 b_constr.data = NULL;
2288         for (size_t i = 0; i < b_constr.datalen; i++) {
2289                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2290                 LDKSignature b_conv_8_ref;
2291                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
2292                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
2293                 b_constr.data[i] = b_conv_8_ref;
2294         }
2295         ret->b = b_constr;
2296         return (long)ret;
2297 }
2298 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2299         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2300         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
2301         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
2302         return a_arr;
2303 }
2304 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2305         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2306         LDKCVec_SignatureZ b_var = tuple->b;
2307         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
2308         ;
2309         for (size_t i = 0; i < b_var.datalen; i++) {
2310                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
2311                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
2312                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
2313         }
2314         return b_arr;
2315 }
2316 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2317         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2318 }
2319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2320         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2321         CHECK(val->result_ok);
2322         long res_ref = (long)(&(*val->contents.result)) | 1;
2323         return res_ref;
2324 }
2325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2326         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2327         CHECK(!val->result_ok);
2328         return *val->contents.err;
2329 }
2330 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2331         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2332 }
2333 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2334         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2335         CHECK(val->result_ok);
2336         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2337         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2338         return res_arr;
2339 }
2340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2341         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2342         CHECK(!val->result_ok);
2343         return *val->contents.err;
2344 }
2345 typedef struct LDKSign_JCalls {
2346         atomic_size_t refcnt;
2347         JavaVM *vm;
2348         jweak o;
2349         jmethodID get_per_commitment_point_meth;
2350         jmethodID release_commitment_secret_meth;
2351         jmethodID channel_keys_id_meth;
2352         jmethodID sign_counterparty_commitment_meth;
2353         jmethodID sign_holder_commitment_and_htlcs_meth;
2354         jmethodID sign_justice_transaction_meth;
2355         jmethodID sign_counterparty_htlc_transaction_meth;
2356         jmethodID sign_closing_transaction_meth;
2357         jmethodID sign_channel_announcement_meth;
2358         jmethodID ready_channel_meth;
2359         jmethodID write_meth;
2360 } LDKSign_JCalls;
2361 static void LDKSign_JCalls_free(void* this_arg) {
2362         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2363         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2364                 JNIEnv *env;
2365                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2366                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2367                 FREE(j_calls);
2368         }
2369 }
2370 LDKPublicKey get_per_commitment_point_LDKSign_jcall(const void* this_arg, uint64_t idx) {
2371         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2372         JNIEnv *env;
2373         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2374         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2375         CHECK(obj != NULL);
2376         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2377         LDKPublicKey ret_ref;
2378         CHECK((*env)->GetArrayLength(env, ret) == 33);
2379         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2380         return ret_ref;
2381 }
2382 LDKThirtyTwoBytes release_commitment_secret_LDKSign_jcall(const void* this_arg, uint64_t idx) {
2383         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2384         JNIEnv *env;
2385         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2386         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2387         CHECK(obj != NULL);
2388         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2389         LDKThirtyTwoBytes ret_ref;
2390         CHECK((*env)->GetArrayLength(env, ret) == 32);
2391         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2392         return ret_ref;
2393 }
2394 LDKThirtyTwoBytes channel_keys_id_LDKSign_jcall(const void* this_arg) {
2395         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2396         JNIEnv *env;
2397         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2398         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2399         CHECK(obj != NULL);
2400         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2401         LDKThirtyTwoBytes ret_ref;
2402         CHECK((*env)->GetArrayLength(env, ret) == 32);
2403         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2404         return ret_ref;
2405 }
2406 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2407         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2408         JNIEnv *env;
2409         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2410         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2411         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2412         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2413         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2414         long commitment_tx_ref = (long)commitment_tx_var.inner;
2415         if (commitment_tx_var.is_owned) {
2416                 commitment_tx_ref |= 1;
2417         }
2418         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2419         CHECK(obj != NULL);
2420         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2421         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2422         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2423         return ret_conv;
2424 }
2425 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2426         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2427         JNIEnv *env;
2428         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2429         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2430         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2431         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2432         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2433         long commitment_tx_ref = (long)commitment_tx_var.inner;
2434         if (commitment_tx_var.is_owned) {
2435                 commitment_tx_ref |= 1;
2436         }
2437         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2438         CHECK(obj != NULL);
2439         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2440         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2441         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2442         return ret_conv;
2443 }
2444 LDKCResult_SignatureNoneZ sign_justice_transaction_LDKSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
2445         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2446         JNIEnv *env;
2447         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2448         LDKTransaction justice_tx_var = justice_tx;
2449         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2450         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2451         Transaction_free(justice_tx_var);
2452         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2453         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2454         LDKHTLCOutputInCommitment htlc_var = *htlc;
2455         htlc_var = HTLCOutputInCommitment_clone(htlc);
2456         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2457         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2458         long htlc_ref = (long)htlc_var.inner;
2459         if (htlc_var.is_owned) {
2460                 htlc_ref |= 1;
2461         }
2462         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2463         CHECK(obj != NULL);
2464         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);
2465         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2466         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2467         return ret_conv;
2468 }
2469 LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKSign_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
2470         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2471         JNIEnv *env;
2472         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2473         LDKTransaction htlc_tx_var = htlc_tx;
2474         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2475         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2476         Transaction_free(htlc_tx_var);
2477         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2478         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2479         LDKHTLCOutputInCommitment htlc_var = *htlc;
2480         htlc_var = HTLCOutputInCommitment_clone(htlc);
2481         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2482         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2483         long htlc_ref = (long)htlc_var.inner;
2484         if (htlc_var.is_owned) {
2485                 htlc_ref |= 1;
2486         }
2487         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2488         CHECK(obj != NULL);
2489         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);
2490         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2491         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2492         return ret_conv;
2493 }
2494 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
2495         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2496         JNIEnv *env;
2497         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2498         LDKTransaction closing_tx_var = closing_tx;
2499         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
2500         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
2501         Transaction_free(closing_tx_var);
2502         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2503         CHECK(obj != NULL);
2504         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
2505         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2506         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2507         return ret_conv;
2508 }
2509 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2510         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2511         JNIEnv *env;
2512         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2513         LDKUnsignedChannelAnnouncement msg_var = *msg;
2514         msg_var = UnsignedChannelAnnouncement_clone(msg);
2515         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2516         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2517         long msg_ref = (long)msg_var.inner;
2518         if (msg_var.is_owned) {
2519                 msg_ref |= 1;
2520         }
2521         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2522         CHECK(obj != NULL);
2523         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2524         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2525         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2526         return ret_conv;
2527 }
2528 void ready_channel_LDKSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2529         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2530         JNIEnv *env;
2531         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2532         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2533         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2534         CHECK((((long)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2535         CHECK((((long)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2536         long channel_parameters_ref = (long)channel_parameters_var.inner;
2537         if (channel_parameters_var.is_owned) {
2538                 channel_parameters_ref |= 1;
2539         }
2540         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2541         CHECK(obj != NULL);
2542         return (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2543 }
2544 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2545         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2546         JNIEnv *env;
2547         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2548         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2549         CHECK(obj != NULL);
2550         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2551         LDKCVec_u8Z ret_ref;
2552         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2553         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2554         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2555         return ret_ref;
2556 }
2557 static void* LDKSign_JCalls_clone(const void* this_arg) {
2558         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2559         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2560         return (void*) this_arg;
2561 }
2562 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2563         jclass c = (*env)->GetObjectClass(env, o);
2564         CHECK(c != NULL);
2565         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2566         atomic_init(&calls->refcnt, 1);
2567         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2568         calls->o = (*env)->NewWeakGlobalRef(env, o);
2569         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2570         CHECK(calls->get_per_commitment_point_meth != NULL);
2571         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2572         CHECK(calls->release_commitment_secret_meth != NULL);
2573         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2574         CHECK(calls->channel_keys_id_meth != NULL);
2575         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2576         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2577         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2578         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2579         calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "([BJJ[BJ)J");
2580         CHECK(calls->sign_justice_transaction_meth != NULL);
2581         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2582         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2583         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
2584         CHECK(calls->sign_closing_transaction_meth != NULL);
2585         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2586         CHECK(calls->sign_channel_announcement_meth != NULL);
2587         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2588         CHECK(calls->ready_channel_meth != NULL);
2589         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2590         CHECK(calls->write_meth != NULL);
2591
2592         LDKChannelPublicKeys pubkeys_conv;
2593         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2594         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2595         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2596
2597         LDKSign ret = {
2598                 .this_arg = (void*) calls,
2599                 .get_per_commitment_point = get_per_commitment_point_LDKSign_jcall,
2600                 .release_commitment_secret = release_commitment_secret_LDKSign_jcall,
2601                 .channel_keys_id = channel_keys_id_LDKSign_jcall,
2602                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKSign_jcall,
2603                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKSign_jcall,
2604                 .sign_justice_transaction = sign_justice_transaction_LDKSign_jcall,
2605                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKSign_jcall,
2606                 .sign_closing_transaction = sign_closing_transaction_LDKSign_jcall,
2607                 .sign_channel_announcement = sign_channel_announcement_LDKSign_jcall,
2608                 .ready_channel = ready_channel_LDKSign_jcall,
2609                 .clone = LDKSign_JCalls_clone,
2610                 .write = write_LDKSign_jcall,
2611                 .free = LDKSign_JCalls_free,
2612                 .pubkeys = pubkeys_conv,
2613                 .set_pubkeys = NULL,
2614         };
2615         return ret;
2616 }
2617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2618         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2619         *res_ptr = LDKSign_init(env, clz, o, pubkeys);
2620         return (long)res_ptr;
2621 }
2622 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) {
2623         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2624         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2625         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2626         return ret_arr;
2627 }
2628
2629 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2630         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2631         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2632         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2633         return ret_arr;
2634 }
2635
2636 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
2637         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2638         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2639         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2640         return ret_arr;
2641 }
2642
2643 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) {
2644         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2645         LDKCommitmentTransaction commitment_tx_conv;
2646         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2647         commitment_tx_conv.is_owned = false;
2648         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2649         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2650         return (long)ret_conv;
2651 }
2652
2653 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) {
2654         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2655         LDKHolderCommitmentTransaction commitment_tx_conv;
2656         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2657         commitment_tx_conv.is_owned = false;
2658         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2659         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2660         return (long)ret_conv;
2661 }
2662
2663 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) {
2664         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2665         LDKTransaction justice_tx_ref;
2666         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2667         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2668         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2669         justice_tx_ref.data_is_owned = true;
2670         unsigned char per_commitment_key_arr[32];
2671         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2672         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2673         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2674         LDKHTLCOutputInCommitment htlc_conv;
2675         htlc_conv.inner = (void*)(htlc & (~1));
2676         htlc_conv.is_owned = false;
2677         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2678         *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
2679         return (long)ret_conv;
2680 }
2681
2682 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) {
2683         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2684         LDKTransaction htlc_tx_ref;
2685         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2686         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2687         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2688         htlc_tx_ref.data_is_owned = true;
2689         LDKPublicKey per_commitment_point_ref;
2690         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2691         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2692         LDKHTLCOutputInCommitment htlc_conv;
2693         htlc_conv.inner = (void*)(htlc & (~1));
2694         htlc_conv.is_owned = false;
2695         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2696         *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);
2697         return (long)ret_conv;
2698 }
2699
2700 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) {
2701         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2702         LDKTransaction closing_tx_ref;
2703         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
2704         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2705         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
2706         closing_tx_ref.data_is_owned = true;
2707         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2708         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2709         return (long)ret_conv;
2710 }
2711
2712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2713         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2714         LDKUnsignedChannelAnnouncement msg_conv;
2715         msg_conv.inner = (void*)(msg & (~1));
2716         msg_conv.is_owned = false;
2717         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2718         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2719         return (long)ret_conv;
2720 }
2721
2722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2723         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2724         LDKChannelTransactionParameters channel_parameters_conv;
2725         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2726         channel_parameters_conv.is_owned = false;
2727         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2728 }
2729
2730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2731         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2732         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2733         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2734         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2735         CVec_u8Z_free(ret_var);
2736         return ret_arr;
2737 }
2738
2739 LDKChannelPublicKeys LDKSign_set_get_pubkeys(LDKSign* this_arg) {
2740         if (this_arg->set_pubkeys != NULL)
2741                 this_arg->set_pubkeys(this_arg);
2742         return this_arg->pubkeys;
2743 }
2744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2745         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2746         LDKChannelPublicKeys ret_var = LDKSign_set_get_pubkeys(this_arg_conv);
2747         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2748         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2749         long ret_ref = (long)ret_var.inner;
2750         if (ret_var.is_owned) {
2751                 ret_ref |= 1;
2752         }
2753         return ret_ref;
2754 }
2755
2756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
2757         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2758         LDKThirtyTwoBytes a_ref;
2759         CHECK((*env)->GetArrayLength(env, a) == 32);
2760         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2761         ret->a = a_ref;
2762         LDKChannelMonitor b_conv;
2763         b_conv.inner = (void*)(b & (~1));
2764         b_conv.is_owned = (b & 1) || (b == 0);
2765         b_conv = ChannelMonitor_clone(&b_conv);
2766         ret->b = b_conv;
2767         return (long)ret;
2768 }
2769 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2770         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2771         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2772         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2773         return a_arr;
2774 }
2775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2776         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2777         LDKChannelMonitor b_var = tuple->b;
2778         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2779         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2780         long b_ref = (long)b_var.inner & ~1;
2781         return b_ref;
2782 }
2783 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2784         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
2785 }
2786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2787         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2788         CHECK(val->result_ok);
2789         long res_ref = (long)(&(*val->contents.result)) | 1;
2790         return res_ref;
2791 }
2792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2793         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2794         CHECK(!val->result_ok);
2795         LDKDecodeError err_var = (*val->contents.err);
2796         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2797         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2798         long err_ref = (long)err_var.inner & ~1;
2799         return err_ref;
2800 }
2801 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2802         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
2803 }
2804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2805         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2806         CHECK(val->result_ok);
2807         long res_ref = ((long)&(*val->contents.result)) | 1;
2808         return (long)res_ref;
2809 }
2810 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2811         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2812         CHECK(!val->result_ok);
2813         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
2814         return err_conv;
2815 }
2816 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
2817 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
2818 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
2819 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
2820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
2821         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
2822                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
2823         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
2824         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
2825         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
2826         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
2827                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
2828         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
2829         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
2830         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
2831 }
2832 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2833         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2834         switch(obj->tag) {
2835                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
2836                         long some_ref = (long)(&obj->some) | 1;
2837                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, some_ref);
2838                 }
2839                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
2840                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
2841                 }
2842                 default: abort();
2843         }
2844 }
2845 static jclass LDKAPIError_APIMisuseError_class = NULL;
2846 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
2847 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
2848 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
2849 static jclass LDKAPIError_RouteError_class = NULL;
2850 static jmethodID LDKAPIError_RouteError_meth = NULL;
2851 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
2852 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
2853 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
2854 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
2855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
2856         LDKAPIError_APIMisuseError_class =
2857                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
2858         CHECK(LDKAPIError_APIMisuseError_class != NULL);
2859         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "([B)V");
2860         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
2861         LDKAPIError_FeeRateTooHigh_class =
2862                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
2863         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
2864         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "([BI)V");
2865         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
2866         LDKAPIError_RouteError_class =
2867                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
2868         CHECK(LDKAPIError_RouteError_class != NULL);
2869         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
2870         CHECK(LDKAPIError_RouteError_meth != NULL);
2871         LDKAPIError_ChannelUnavailable_class =
2872                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
2873         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
2874         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "([B)V");
2875         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
2876         LDKAPIError_MonitorUpdateFailed_class =
2877                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
2878         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
2879         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
2880         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
2881 }
2882 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2883         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2884         switch(obj->tag) {
2885                 case LDKAPIError_APIMisuseError: {
2886                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
2887                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
2888                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
2889                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_arr);
2890                 }
2891                 case LDKAPIError_FeeRateTooHigh: {
2892                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
2893                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
2894                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
2895                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_arr, obj->fee_rate_too_high.feerate);
2896                 }
2897                 case LDKAPIError_RouteError: {
2898                         LDKStr err_str = obj->route_error.err;
2899                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2900                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
2901                 }
2902                 case LDKAPIError_ChannelUnavailable: {
2903                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
2904                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
2905                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
2906                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_arr);
2907                 }
2908                 case LDKAPIError_MonitorUpdateFailed: {
2909                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
2910                 }
2911                 default: abort();
2912         }
2913 }
2914 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2915         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2916 }
2917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2918         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2919         CHECK(val->result_ok);
2920         return *val->contents.result;
2921 }
2922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2923         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2924         CHECK(!val->result_ok);
2925         long err_ref = ((long)&(*val->contents.err)) | 1;
2926         return err_ref;
2927 }
2928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2929         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2930         ret->datalen = (*env)->GetArrayLength(env, elems);
2931         if (ret->datalen == 0) {
2932                 ret->data = NULL;
2933         } else {
2934                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2935                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2936                 for (size_t i = 0; i < ret->datalen; i++) {
2937                         int64_t arr_elem = java_elems[i];
2938                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2939                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
2940                         ret->data[i] = arr_elem_conv;
2941                 }
2942                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2943         }
2944         return (long)ret;
2945 }
2946 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2947         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2948         for (size_t i = 0; i < ret.datalen; i++) {
2949                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2950         }
2951         return ret;
2952 }
2953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2954         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2955         ret->datalen = (*env)->GetArrayLength(env, elems);
2956         if (ret->datalen == 0) {
2957                 ret->data = NULL;
2958         } else {
2959                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
2960                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2961                 for (size_t i = 0; i < ret->datalen; i++) {
2962                         int64_t arr_elem = java_elems[i];
2963                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
2964                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
2965                         ret->data[i] = arr_elem_conv;
2966                 }
2967                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2968         }
2969         return (long)ret;
2970 }
2971 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2972         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2973         for (size_t i = 0; i < ret.datalen; i++) {
2974                 ret.data[i] = APIError_clone(&orig->data[i]);
2975         }
2976         return ret;
2977 }
2978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2979         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
2980         ret->datalen = (*env)->GetArrayLength(env, elems);
2981         if (ret->datalen == 0) {
2982                 ret->data = NULL;
2983         } else {
2984                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
2985                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2986                 for (size_t i = 0; i < ret->datalen; i++) {
2987                         int64_t arr_elem = java_elems[i];
2988                         LDKChannelDetails arr_elem_conv;
2989                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2990                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2991                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
2992                         ret->data[i] = arr_elem_conv;
2993                 }
2994                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2995         }
2996         return (long)ret;
2997 }
2998 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2999         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
3000         for (size_t i = 0; i < ret.datalen; i++) {
3001                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
3002         }
3003         return ret;
3004 }
3005 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3006 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3007 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3008 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3009 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3010 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3011 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3012 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3014         LDKPaymentSendFailure_ParameterError_class =
3015                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3016         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3017         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3018         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3019         LDKPaymentSendFailure_PathParameterError_class =
3020                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3021         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3022         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3023         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3024         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3025                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3026         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3027         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3028         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3029         LDKPaymentSendFailure_PartialFailure_class =
3030                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3031         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3032         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
3033         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3034 }
3035 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3036         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3037         switch(obj->tag) {
3038                 case LDKPaymentSendFailure_ParameterError: {
3039                         long parameter_error_ref = ((long)&obj->parameter_error) | 1;
3040                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3041                 }
3042                 case LDKPaymentSendFailure_PathParameterError: {
3043                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3044                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3045                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3046                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3047                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3048                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3049                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3050                                 path_parameter_error_arr_ptr[w] = (long)path_parameter_error_conv_22_conv;
3051                         }
3052                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3053                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3054                 }
3055                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3056                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3057                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3058                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3059                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3060                                 long all_failed_retry_safe_conv_10_ref = ((long)&all_failed_retry_safe_var.data[k]) | 1;
3061                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3062                         }
3063                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3064                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3065                 }
3066                 case LDKPaymentSendFailure_PartialFailure: {
3067                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3068                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
3069                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
3070                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3071                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3072                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3073                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3074                                 partial_failure_arr_ptr[w] = (long)partial_failure_conv_22_conv;
3075                         }
3076                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
3077                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
3078                 }
3079                 default: abort();
3080         }
3081 }
3082 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3083         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3084 }
3085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3086         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3087         CHECK(val->result_ok);
3088         return *val->contents.result;
3089 }
3090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3091         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3092         CHECK(!val->result_ok);
3093         long err_ref = ((long)&(*val->contents.err)) | 1;
3094         return err_ref;
3095 }
3096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3097         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3098         ret->datalen = (*env)->GetArrayLength(env, elems);
3099         if (ret->datalen == 0) {
3100                 ret->data = NULL;
3101         } else {
3102                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3103                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3104                 for (size_t i = 0; i < ret->datalen; i++) {
3105                         int64_t arr_elem = java_elems[i];
3106                         LDKChannelMonitor arr_elem_conv;
3107                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3108                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3109                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3110                         ret->data[i] = arr_elem_conv;
3111                 }
3112                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3113         }
3114         return (long)ret;
3115 }
3116 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3117         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3118         for (size_t i = 0; i < ret.datalen; i++) {
3119                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3120         }
3121         return ret;
3122 }
3123 typedef struct LDKWatch_JCalls {
3124         atomic_size_t refcnt;
3125         JavaVM *vm;
3126         jweak o;
3127         jmethodID watch_channel_meth;
3128         jmethodID update_channel_meth;
3129         jmethodID release_pending_monitor_events_meth;
3130 } LDKWatch_JCalls;
3131 static void LDKWatch_JCalls_free(void* this_arg) {
3132         LDKWatch_JCalls *j_calls = (LDKWatch_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 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3141         LDKWatch_JCalls *j_calls = (LDKWatch_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         LDKOutPoint funding_txo_var = funding_txo;
3145         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3146         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3147         long funding_txo_ref = (long)funding_txo_var.inner;
3148         if (funding_txo_var.is_owned) {
3149                 funding_txo_ref |= 1;
3150         }
3151         LDKChannelMonitor monitor_var = monitor;
3152         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3153         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3154         long monitor_ref = (long)monitor_var.inner;
3155         if (monitor_var.is_owned) {
3156                 monitor_ref |= 1;
3157         }
3158         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3159         CHECK(obj != NULL);
3160         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3161         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3162         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3163         return ret_conv;
3164 }
3165 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3166         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3167         JNIEnv *env;
3168         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3169         LDKOutPoint funding_txo_var = funding_txo;
3170         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3171         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3172         long funding_txo_ref = (long)funding_txo_var.inner;
3173         if (funding_txo_var.is_owned) {
3174                 funding_txo_ref |= 1;
3175         }
3176         LDKChannelMonitorUpdate update_var = update;
3177         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3178         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3179         long update_ref = (long)update_var.inner;
3180         if (update_var.is_owned) {
3181                 update_ref |= 1;
3182         }
3183         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3184         CHECK(obj != NULL);
3185         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3186         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3187         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3188         return ret_conv;
3189 }
3190 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
3191         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3192         JNIEnv *env;
3193         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3194         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3195         CHECK(obj != NULL);
3196         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3197         LDKCVec_MonitorEventZ ret_constr;
3198         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3199         if (ret_constr.datalen > 0)
3200                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3201         else
3202                 ret_constr.data = NULL;
3203         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3204         for (size_t o = 0; o < ret_constr.datalen; o++) {
3205                 int64_t ret_conv_14 = ret_vals[o];
3206                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3207                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3208                 ret_constr.data[o] = ret_conv_14_conv;
3209         }
3210         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3211         return ret_constr;
3212 }
3213 static void* LDKWatch_JCalls_clone(const void* this_arg) {
3214         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3215         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3216         return (void*) this_arg;
3217 }
3218 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3219         jclass c = (*env)->GetObjectClass(env, o);
3220         CHECK(c != NULL);
3221         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3222         atomic_init(&calls->refcnt, 1);
3223         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3224         calls->o = (*env)->NewWeakGlobalRef(env, o);
3225         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3226         CHECK(calls->watch_channel_meth != NULL);
3227         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3228         CHECK(calls->update_channel_meth != NULL);
3229         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3230         CHECK(calls->release_pending_monitor_events_meth != NULL);
3231
3232         LDKWatch ret = {
3233                 .this_arg = (void*) calls,
3234                 .watch_channel = watch_channel_LDKWatch_jcall,
3235                 .update_channel = update_channel_LDKWatch_jcall,
3236                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3237                 .free = LDKWatch_JCalls_free,
3238         };
3239         return ret;
3240 }
3241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3242         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3243         *res_ptr = LDKWatch_init(env, clz, o);
3244         return (long)res_ptr;
3245 }
3246 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) {
3247         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3248         LDKOutPoint funding_txo_conv;
3249         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3250         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3251         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3252         LDKChannelMonitor monitor_conv;
3253         monitor_conv.inner = (void*)(monitor & (~1));
3254         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3255         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3256         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3257         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3258         return (long)ret_conv;
3259 }
3260
3261 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) {
3262         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3263         LDKOutPoint funding_txo_conv;
3264         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3265         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3266         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3267         LDKChannelMonitorUpdate update_conv;
3268         update_conv.inner = (void*)(update & (~1));
3269         update_conv.is_owned = (update & 1) || (update == 0);
3270         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3271         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3272         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3273         return (long)ret_conv;
3274 }
3275
3276 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3277         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3278         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3279         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3280         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3281         for (size_t o = 0; o < ret_var.datalen; o++) {
3282                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3283                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3284                 long ret_conv_14_ref = (long)ret_conv_14_copy;
3285                 ret_arr_ptr[o] = ret_conv_14_ref;
3286         }
3287         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3288         FREE(ret_var.data);
3289         return ret_arr;
3290 }
3291
3292 typedef struct LDKBroadcasterInterface_JCalls {
3293         atomic_size_t refcnt;
3294         JavaVM *vm;
3295         jweak o;
3296         jmethodID broadcast_transaction_meth;
3297 } LDKBroadcasterInterface_JCalls;
3298 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3299         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3300         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3301                 JNIEnv *env;
3302                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3303                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3304                 FREE(j_calls);
3305         }
3306 }
3307 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3308         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3309         JNIEnv *env;
3310         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3311         LDKTransaction tx_var = tx;
3312         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3313         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3314         Transaction_free(tx_var);
3315         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3316         CHECK(obj != NULL);
3317         return (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3318 }
3319 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
3320         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3321         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3322         return (void*) this_arg;
3323 }
3324 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
3325         jclass c = (*env)->GetObjectClass(env, o);
3326         CHECK(c != NULL);
3327         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3328         atomic_init(&calls->refcnt, 1);
3329         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3330         calls->o = (*env)->NewWeakGlobalRef(env, o);
3331         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
3332         CHECK(calls->broadcast_transaction_meth != NULL);
3333
3334         LDKBroadcasterInterface ret = {
3335                 .this_arg = (void*) calls,
3336                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3337                 .free = LDKBroadcasterInterface_JCalls_free,
3338         };
3339         return ret;
3340 }
3341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3342         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3343         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
3344         return (long)res_ptr;
3345 }
3346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
3347         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
3348         LDKTransaction tx_ref;
3349         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
3350         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3351         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
3352         tx_ref.data_is_owned = true;
3353         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3354 }
3355
3356 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3357         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
3358 }
3359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3360         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3361         CHECK(val->result_ok);
3362         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3363         *ret = Sign_clone(&(*val->contents.result));
3364         return (long)ret;
3365 }
3366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3367         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3368         CHECK(!val->result_ok);
3369         LDKDecodeError err_var = (*val->contents.err);
3370         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3371         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3372         long err_ref = (long)err_var.inner & ~1;
3373         return err_ref;
3374 }
3375 typedef struct LDKKeysInterface_JCalls {
3376         atomic_size_t refcnt;
3377         JavaVM *vm;
3378         jweak o;
3379         jmethodID get_node_secret_meth;
3380         jmethodID get_destination_script_meth;
3381         jmethodID get_shutdown_pubkey_meth;
3382         jmethodID get_channel_signer_meth;
3383         jmethodID get_secure_random_bytes_meth;
3384         jmethodID read_chan_signer_meth;
3385 } LDKKeysInterface_JCalls;
3386 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3387         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3388         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3389                 JNIEnv *env;
3390                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3391                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3392                 FREE(j_calls);
3393         }
3394 }
3395 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3396         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3397         JNIEnv *env;
3398         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3399         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3400         CHECK(obj != NULL);
3401         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3402         LDKSecretKey ret_ref;
3403         CHECK((*env)->GetArrayLength(env, ret) == 32);
3404         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
3405         return ret_ref;
3406 }
3407 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3408         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_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         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3412         CHECK(obj != NULL);
3413         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
3414         LDKCVec_u8Z ret_ref;
3415         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3416         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3417         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3418         return ret_ref;
3419 }
3420 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
3421         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3422         JNIEnv *env;
3423         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3424         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3425         CHECK(obj != NULL);
3426         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
3427         LDKPublicKey ret_ref;
3428         CHECK((*env)->GetArrayLength(env, ret) == 33);
3429         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3430         return ret_ref;
3431 }
3432 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3433         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3434         JNIEnv *env;
3435         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3436         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3437         CHECK(obj != NULL);
3438         LDKSign* ret = (LDKSign*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3439         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
3440         ret_conv = Sign_clone(ret);
3441         return ret_conv;
3442 }
3443 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
3444         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3445         JNIEnv *env;
3446         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3447         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3448         CHECK(obj != NULL);
3449         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
3450         LDKThirtyTwoBytes ret_ref;
3451         CHECK((*env)->GetArrayLength(env, ret) == 32);
3452         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3453         return ret_ref;
3454 }
3455 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3456         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3457         JNIEnv *env;
3458         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3459         LDKu8slice reader_var = reader;
3460         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
3461         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
3462         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3463         CHECK(obj != NULL);
3464         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
3465         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
3466         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
3467         return ret_conv;
3468 }
3469 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
3470         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3471         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3472         return (void*) this_arg;
3473 }
3474 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
3475         jclass c = (*env)->GetObjectClass(env, o);
3476         CHECK(c != NULL);
3477         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3478         atomic_init(&calls->refcnt, 1);
3479         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3480         calls->o = (*env)->NewWeakGlobalRef(env, o);
3481         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
3482         CHECK(calls->get_node_secret_meth != NULL);
3483         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
3484         CHECK(calls->get_destination_script_meth != NULL);
3485         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
3486         CHECK(calls->get_shutdown_pubkey_meth != NULL);
3487         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
3488         CHECK(calls->get_channel_signer_meth != NULL);
3489         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
3490         CHECK(calls->get_secure_random_bytes_meth != NULL);
3491         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
3492         CHECK(calls->read_chan_signer_meth != NULL);
3493
3494         LDKKeysInterface ret = {
3495                 .this_arg = (void*) calls,
3496                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
3497                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
3498                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
3499                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
3500                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
3501                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
3502                 .free = LDKKeysInterface_JCalls_free,
3503         };
3504         return ret;
3505 }
3506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3507         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3508         *res_ptr = LDKKeysInterface_init(env, clz, o);
3509         return (long)res_ptr;
3510 }
3511 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
3512         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3513         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3514         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
3515         return ret_arr;
3516 }
3517
3518 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
3519         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3520         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3521         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3522         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3523         CVec_u8Z_free(ret_var);
3524         return ret_arr;
3525 }
3526
3527 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
3528         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3529         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3530         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
3531         return ret_arr;
3532 }
3533
3534 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) {
3535         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3536         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3537         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
3538         return (long)ret;
3539 }
3540
3541 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
3542         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3543         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3544         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
3545         return ret_arr;
3546 }
3547
3548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
3549         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3550         LDKu8slice reader_ref;
3551         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
3552         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
3553         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
3554         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
3555         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
3556         return (long)ret_conv;
3557 }
3558
3559 typedef struct LDKFeeEstimator_JCalls {
3560         atomic_size_t refcnt;
3561         JavaVM *vm;
3562         jweak o;
3563         jmethodID get_est_sat_per_1000_weight_meth;
3564 } LDKFeeEstimator_JCalls;
3565 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3566         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3567         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3568                 JNIEnv *env;
3569                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3570                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3571                 FREE(j_calls);
3572         }
3573 }
3574 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
3575         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3576         JNIEnv *env;
3577         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3578         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
3579         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3580         CHECK(obj != NULL);
3581         return (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
3582 }
3583 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
3584         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3585         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3586         return (void*) this_arg;
3587 }
3588 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
3589         jclass c = (*env)->GetObjectClass(env, o);
3590         CHECK(c != NULL);
3591         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
3592         atomic_init(&calls->refcnt, 1);
3593         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3594         calls->o = (*env)->NewWeakGlobalRef(env, o);
3595         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I");
3596         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
3597
3598         LDKFeeEstimator ret = {
3599                 .this_arg = (void*) calls,
3600                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
3601                 .free = LDKFeeEstimator_JCalls_free,
3602         };
3603         return ret;
3604 }
3605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
3606         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
3607         *res_ptr = LDKFeeEstimator_init(env, clz, o);
3608         return (long)res_ptr;
3609 }
3610 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) {
3611         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
3612         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
3613         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
3614         return ret_val;
3615 }
3616
3617 typedef struct LDKLogger_JCalls {
3618         atomic_size_t refcnt;
3619         JavaVM *vm;
3620         jweak o;
3621         jmethodID log_meth;
3622 } LDKLogger_JCalls;
3623 static void LDKLogger_JCalls_free(void* this_arg) {
3624         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3625         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3626                 JNIEnv *env;
3627                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3628                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3629                 FREE(j_calls);
3630         }
3631 }
3632 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
3633         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3634         JNIEnv *env;
3635         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3636         const char* record_str = record;
3637         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
3638         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3639         CHECK(obj != NULL);
3640         return (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
3641 }
3642 static void* LDKLogger_JCalls_clone(const void* this_arg) {
3643         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3644         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3645         return (void*) this_arg;
3646 }
3647 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3648         jclass c = (*env)->GetObjectClass(env, o);
3649         CHECK(c != NULL);
3650         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3651         atomic_init(&calls->refcnt, 1);
3652         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3653         calls->o = (*env)->NewWeakGlobalRef(env, o);
3654         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
3655         CHECK(calls->log_meth != NULL);
3656
3657         LDKLogger ret = {
3658                 .this_arg = (void*) calls,
3659                 .log = log_LDKLogger_jcall,
3660                 .free = LDKLogger_JCalls_free,
3661         };
3662         return ret;
3663 }
3664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3665         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3666         *res_ptr = LDKLogger_init(env, clz, o);
3667         return (long)res_ptr;
3668 }
3669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
3670         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
3671         LDKThirtyTwoBytes a_ref;
3672         CHECK((*env)->GetArrayLength(env, a) == 32);
3673         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3674         ret->a = a_ref;
3675         LDKChannelManager b_conv;
3676         b_conv.inner = (void*)(b & (~1));
3677         b_conv.is_owned = (b & 1) || (b == 0);
3678         // Warning: we need a move here but no clone is available for LDKChannelManager
3679         ret->b = b_conv;
3680         return (long)ret;
3681 }
3682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3683         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
3684         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3685         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3686         return a_arr;
3687 }
3688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3689         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
3690         LDKChannelManager b_var = tuple->b;
3691         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3692         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3693         long b_ref = (long)b_var.inner & ~1;
3694         return b_ref;
3695 }
3696 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3697         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
3698 }
3699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3700         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3701         CHECK(val->result_ok);
3702         long res_ref = (long)(&(*val->contents.result)) | 1;
3703         return res_ref;
3704 }
3705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3706         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3707         CHECK(!val->result_ok);
3708         LDKDecodeError err_var = (*val->contents.err);
3709         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3710         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3711         long err_ref = (long)err_var.inner & ~1;
3712         return err_ref;
3713 }
3714 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3715         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
3716 }
3717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3718         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
3719         CHECK(val->result_ok);
3720         long res_ref = ((long)&(*val->contents.result)) | 1;
3721         return res_ref;
3722 }
3723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3724         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
3725         CHECK(!val->result_ok);
3726         LDKDecodeError err_var = (*val->contents.err);
3727         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3728         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3729         long err_ref = (long)err_var.inner & ~1;
3730         return err_ref;
3731 }
3732 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3733         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3734         for (size_t i = 0; i < ret.datalen; i++) {
3735                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3736         }
3737         return ret;
3738 }
3739 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3740         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
3741 }
3742 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3743         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3744         CHECK(val->result_ok);
3745         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
3746         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
3747         ;
3748         for (size_t i = 0; i < res_var.datalen; i++) {
3749                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
3750                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
3751                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
3752                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
3753         }
3754         return res_arr;
3755 }
3756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3757         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3758         CHECK(!val->result_ok);
3759         return *val->contents.err;
3760 }
3761 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3762         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
3763 }
3764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3765         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3766         CHECK(val->result_ok);
3767         LDKInMemorySigner res_var = (*val->contents.result);
3768         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3769         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3770         long res_ref = (long)res_var.inner & ~1;
3771         return res_ref;
3772 }
3773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3774         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3775         CHECK(!val->result_ok);
3776         LDKDecodeError err_var = (*val->contents.err);
3777         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3778         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3779         long err_ref = (long)err_var.inner & ~1;
3780         return err_ref;
3781 }
3782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3783         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
3784         ret->datalen = (*env)->GetArrayLength(env, elems);
3785         if (ret->datalen == 0) {
3786                 ret->data = NULL;
3787         } else {
3788                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
3789                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3790                 for (size_t i = 0; i < ret->datalen; i++) {
3791                         int64_t arr_elem = java_elems[i];
3792                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
3793                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
3794                         ret->data[i] = arr_elem_conv;
3795                 }
3796                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3797         }
3798         return (long)ret;
3799 }
3800 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3801         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3802         for (size_t i = 0; i < ret.datalen; i++) {
3803                 ret.data[i] = TxOut_clone(&orig->data[i]);
3804         }
3805         return ret;
3806 }
3807 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3808         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
3809 }
3810 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3811         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3812         CHECK(val->result_ok);
3813         LDKTransaction res_var = (*val->contents.result);
3814         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
3815         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
3816         return res_arr;
3817 }
3818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3819         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3820         CHECK(!val->result_ok);
3821         return *val->contents.err;
3822 }
3823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3824         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
3825         ret->datalen = (*env)->GetArrayLength(env, elems);
3826         if (ret->datalen == 0) {
3827                 ret->data = NULL;
3828         } else {
3829                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
3830                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3831                 for (size_t i = 0; i < ret->datalen; i++) {
3832                         int64_t arr_elem = java_elems[i];
3833                         LDKRouteHop arr_elem_conv;
3834                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3835                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3836                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
3837                         ret->data[i] = arr_elem_conv;
3838                 }
3839                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3840         }
3841         return (long)ret;
3842 }
3843 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
3844         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
3845         for (size_t i = 0; i < ret.datalen; i++) {
3846                 ret.data[i] = RouteHop_clone(&orig->data[i]);
3847         }
3848         return ret;
3849 }
3850 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
3851         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
3852         for (size_t i = 0; i < ret.datalen; i++) {
3853                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
3854         }
3855         return ret;
3856 }
3857 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3858         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
3859 }
3860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3861         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
3862         CHECK(val->result_ok);
3863         LDKRoute res_var = (*val->contents.result);
3864         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3865         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3866         long res_ref = (long)res_var.inner & ~1;
3867         return res_ref;
3868 }
3869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3870         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
3871         CHECK(!val->result_ok);
3872         LDKDecodeError err_var = (*val->contents.err);
3873         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3874         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3875         long err_ref = (long)err_var.inner & ~1;
3876         return err_ref;
3877 }
3878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3879         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
3880         ret->datalen = (*env)->GetArrayLength(env, elems);
3881         if (ret->datalen == 0) {
3882                 ret->data = NULL;
3883         } else {
3884                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
3885                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3886                 for (size_t i = 0; i < ret->datalen; i++) {
3887                         int64_t arr_elem = java_elems[i];
3888                         LDKRouteHint arr_elem_conv;
3889                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3890                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3891                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
3892                         ret->data[i] = arr_elem_conv;
3893                 }
3894                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3895         }
3896         return (long)ret;
3897 }
3898 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
3899         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
3900         for (size_t i = 0; i < ret.datalen; i++) {
3901                 ret.data[i] = RouteHint_clone(&orig->data[i]);
3902         }
3903         return ret;
3904 }
3905 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3906         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
3907 }
3908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3909         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
3910         CHECK(val->result_ok);
3911         LDKRoute res_var = (*val->contents.result);
3912         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3913         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3914         long res_ref = (long)res_var.inner & ~1;
3915         return res_ref;
3916 }
3917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3918         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
3919         CHECK(!val->result_ok);
3920         LDKLightningError err_var = (*val->contents.err);
3921         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3922         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3923         long err_ref = (long)err_var.inner & ~1;
3924         return err_ref;
3925 }
3926 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3927         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
3928 }
3929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3930         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3931         CHECK(val->result_ok);
3932         long res_ref = ((long)&(*val->contents.result)) | 1;
3933         return res_ref;
3934 }
3935 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3936         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3937         CHECK(!val->result_ok);
3938         return *val->contents.err;
3939 }
3940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3941         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
3942 }
3943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3944         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3945         CHECK(val->result_ok);
3946         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3947         *res_conv = (*val->contents.result);
3948         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
3949         return (long)res_conv;
3950 }
3951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3952         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3953         CHECK(!val->result_ok);
3954         LDKDecodeError err_var = (*val->contents.err);
3955         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3956         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3957         long err_ref = (long)err_var.inner & ~1;
3958         return err_ref;
3959 }
3960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3961         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
3962         ret->datalen = (*env)->GetArrayLength(env, elems);
3963         if (ret->datalen == 0) {
3964                 ret->data = NULL;
3965         } else {
3966                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
3967                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3968                 for (size_t i = 0; i < ret->datalen; i++) {
3969                         int64_t arr_elem = java_elems[i];
3970                         LDKUpdateAddHTLC arr_elem_conv;
3971                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3972                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3973                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3974                         ret->data[i] = arr_elem_conv;
3975                 }
3976                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3977         }
3978         return (long)ret;
3979 }
3980 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
3981         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
3982         for (size_t i = 0; i < ret.datalen; i++) {
3983                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
3984         }
3985         return ret;
3986 }
3987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3988         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
3989         ret->datalen = (*env)->GetArrayLength(env, elems);
3990         if (ret->datalen == 0) {
3991                 ret->data = NULL;
3992         } else {
3993                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
3994                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3995                 for (size_t i = 0; i < ret->datalen; i++) {
3996                         int64_t arr_elem = java_elems[i];
3997                         LDKUpdateFulfillHTLC arr_elem_conv;
3998                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3999                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4000                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
4001                         ret->data[i] = arr_elem_conv;
4002                 }
4003                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4004         }
4005         return (long)ret;
4006 }
4007 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
4008         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
4009         for (size_t i = 0; i < ret.datalen; i++) {
4010                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
4011         }
4012         return ret;
4013 }
4014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4015         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
4016         ret->datalen = (*env)->GetArrayLength(env, elems);
4017         if (ret->datalen == 0) {
4018                 ret->data = NULL;
4019         } else {
4020                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
4021                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4022                 for (size_t i = 0; i < ret->datalen; i++) {
4023                         int64_t arr_elem = java_elems[i];
4024                         LDKUpdateFailHTLC arr_elem_conv;
4025                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4026                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4027                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
4028                         ret->data[i] = arr_elem_conv;
4029                 }
4030                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4031         }
4032         return (long)ret;
4033 }
4034 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
4035         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
4036         for (size_t i = 0; i < ret.datalen; i++) {
4037                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
4038         }
4039         return ret;
4040 }
4041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4042         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
4043         ret->datalen = (*env)->GetArrayLength(env, elems);
4044         if (ret->datalen == 0) {
4045                 ret->data = NULL;
4046         } else {
4047                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
4048                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4049                 for (size_t i = 0; i < ret->datalen; i++) {
4050                         int64_t arr_elem = java_elems[i];
4051                         LDKUpdateFailMalformedHTLC arr_elem_conv;
4052                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4053                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4054                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
4055                         ret->data[i] = arr_elem_conv;
4056                 }
4057                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4058         }
4059         return (long)ret;
4060 }
4061 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
4062         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
4063         for (size_t i = 0; i < ret.datalen; i++) {
4064                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
4065         }
4066         return ret;
4067 }
4068 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4069         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
4070 }
4071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4072         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
4073         CHECK(val->result_ok);
4074         LDKAcceptChannel res_var = (*val->contents.result);
4075         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4076         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4077         long res_ref = (long)res_var.inner & ~1;
4078         return res_ref;
4079 }
4080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4081         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
4082         CHECK(!val->result_ok);
4083         LDKDecodeError err_var = (*val->contents.err);
4084         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4085         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4086         long err_ref = (long)err_var.inner & ~1;
4087         return err_ref;
4088 }
4089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4090         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
4091 }
4092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4093         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4094         CHECK(val->result_ok);
4095         LDKAnnouncementSignatures res_var = (*val->contents.result);
4096         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4097         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4098         long res_ref = (long)res_var.inner & ~1;
4099         return res_ref;
4100 }
4101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4102         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4103         CHECK(!val->result_ok);
4104         LDKDecodeError err_var = (*val->contents.err);
4105         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4106         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4107         long err_ref = (long)err_var.inner & ~1;
4108         return err_ref;
4109 }
4110 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4111         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
4112 }
4113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4114         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4115         CHECK(val->result_ok);
4116         LDKChannelReestablish res_var = (*val->contents.result);
4117         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4118         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4119         long res_ref = (long)res_var.inner & ~1;
4120         return res_ref;
4121 }
4122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4123         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4124         CHECK(!val->result_ok);
4125         LDKDecodeError err_var = (*val->contents.err);
4126         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4127         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4128         long err_ref = (long)err_var.inner & ~1;
4129         return err_ref;
4130 }
4131 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4132         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
4133 }
4134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4135         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4136         CHECK(val->result_ok);
4137         LDKClosingSigned res_var = (*val->contents.result);
4138         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4139         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4140         long res_ref = (long)res_var.inner & ~1;
4141         return res_ref;
4142 }
4143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4144         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4145         CHECK(!val->result_ok);
4146         LDKDecodeError err_var = (*val->contents.err);
4147         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4148         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4149         long err_ref = (long)err_var.inner & ~1;
4150         return err_ref;
4151 }
4152 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4153         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
4154 }
4155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4156         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4157         CHECK(val->result_ok);
4158         LDKCommitmentSigned res_var = (*val->contents.result);
4159         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4160         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4161         long res_ref = (long)res_var.inner & ~1;
4162         return res_ref;
4163 }
4164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4165         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4166         CHECK(!val->result_ok);
4167         LDKDecodeError err_var = (*val->contents.err);
4168         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4169         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4170         long err_ref = (long)err_var.inner & ~1;
4171         return err_ref;
4172 }
4173 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4174         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
4175 }
4176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4177         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4178         CHECK(val->result_ok);
4179         LDKFundingCreated res_var = (*val->contents.result);
4180         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4181         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4182         long res_ref = (long)res_var.inner & ~1;
4183         return res_ref;
4184 }
4185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4186         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4187         CHECK(!val->result_ok);
4188         LDKDecodeError err_var = (*val->contents.err);
4189         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4190         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4191         long err_ref = (long)err_var.inner & ~1;
4192         return err_ref;
4193 }
4194 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4195         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
4196 }
4197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4198         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4199         CHECK(val->result_ok);
4200         LDKFundingSigned res_var = (*val->contents.result);
4201         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4202         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4203         long res_ref = (long)res_var.inner & ~1;
4204         return res_ref;
4205 }
4206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4207         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4208         CHECK(!val->result_ok);
4209         LDKDecodeError err_var = (*val->contents.err);
4210         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4211         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4212         long err_ref = (long)err_var.inner & ~1;
4213         return err_ref;
4214 }
4215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4216         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
4217 }
4218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4219         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4220         CHECK(val->result_ok);
4221         LDKFundingLocked res_var = (*val->contents.result);
4222         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4223         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4224         long res_ref = (long)res_var.inner & ~1;
4225         return res_ref;
4226 }
4227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4228         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4229         CHECK(!val->result_ok);
4230         LDKDecodeError err_var = (*val->contents.err);
4231         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4232         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4233         long err_ref = (long)err_var.inner & ~1;
4234         return err_ref;
4235 }
4236 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4237         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
4238 }
4239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4240         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4241         CHECK(val->result_ok);
4242         LDKInit res_var = (*val->contents.result);
4243         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4244         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4245         long res_ref = (long)res_var.inner & ~1;
4246         return res_ref;
4247 }
4248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4249         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4250         CHECK(!val->result_ok);
4251         LDKDecodeError err_var = (*val->contents.err);
4252         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4253         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4254         long err_ref = (long)err_var.inner & ~1;
4255         return err_ref;
4256 }
4257 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4258         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
4259 }
4260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4261         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4262         CHECK(val->result_ok);
4263         LDKOpenChannel res_var = (*val->contents.result);
4264         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4265         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4266         long res_ref = (long)res_var.inner & ~1;
4267         return res_ref;
4268 }
4269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4270         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4271         CHECK(!val->result_ok);
4272         LDKDecodeError err_var = (*val->contents.err);
4273         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4274         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4275         long err_ref = (long)err_var.inner & ~1;
4276         return err_ref;
4277 }
4278 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4279         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
4280 }
4281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4282         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4283         CHECK(val->result_ok);
4284         LDKRevokeAndACK res_var = (*val->contents.result);
4285         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4286         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4287         long res_ref = (long)res_var.inner & ~1;
4288         return res_ref;
4289 }
4290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4291         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4292         CHECK(!val->result_ok);
4293         LDKDecodeError err_var = (*val->contents.err);
4294         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4295         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4296         long err_ref = (long)err_var.inner & ~1;
4297         return err_ref;
4298 }
4299 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4300         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
4301 }
4302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4303         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4304         CHECK(val->result_ok);
4305         LDKShutdown res_var = (*val->contents.result);
4306         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4307         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4308         long res_ref = (long)res_var.inner & ~1;
4309         return res_ref;
4310 }
4311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4312         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4313         CHECK(!val->result_ok);
4314         LDKDecodeError err_var = (*val->contents.err);
4315         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4316         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4317         long err_ref = (long)err_var.inner & ~1;
4318         return err_ref;
4319 }
4320 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4321         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
4322 }
4323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4324         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4325         CHECK(val->result_ok);
4326         LDKUpdateFailHTLC res_var = (*val->contents.result);
4327         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4328         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4329         long res_ref = (long)res_var.inner & ~1;
4330         return res_ref;
4331 }
4332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4333         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4334         CHECK(!val->result_ok);
4335         LDKDecodeError err_var = (*val->contents.err);
4336         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4337         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4338         long err_ref = (long)err_var.inner & ~1;
4339         return err_ref;
4340 }
4341 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4342         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
4343 }
4344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4345         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4346         CHECK(val->result_ok);
4347         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
4348         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4349         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4350         long res_ref = (long)res_var.inner & ~1;
4351         return res_ref;
4352 }
4353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4354         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4355         CHECK(!val->result_ok);
4356         LDKDecodeError err_var = (*val->contents.err);
4357         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4358         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4359         long err_ref = (long)err_var.inner & ~1;
4360         return err_ref;
4361 }
4362 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4363         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
4364 }
4365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4366         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4367         CHECK(val->result_ok);
4368         LDKUpdateFee res_var = (*val->contents.result);
4369         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4370         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4371         long res_ref = (long)res_var.inner & ~1;
4372         return res_ref;
4373 }
4374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4375         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4376         CHECK(!val->result_ok);
4377         LDKDecodeError err_var = (*val->contents.err);
4378         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4379         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4380         long err_ref = (long)err_var.inner & ~1;
4381         return err_ref;
4382 }
4383 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4384         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
4385 }
4386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4387         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4388         CHECK(val->result_ok);
4389         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
4390         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4391         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4392         long res_ref = (long)res_var.inner & ~1;
4393         return res_ref;
4394 }
4395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4396         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4397         CHECK(!val->result_ok);
4398         LDKDecodeError err_var = (*val->contents.err);
4399         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4400         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4401         long err_ref = (long)err_var.inner & ~1;
4402         return err_ref;
4403 }
4404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4405         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
4406 }
4407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4408         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4409         CHECK(val->result_ok);
4410         LDKUpdateAddHTLC res_var = (*val->contents.result);
4411         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4412         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4413         long res_ref = (long)res_var.inner & ~1;
4414         return res_ref;
4415 }
4416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4417         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4418         CHECK(!val->result_ok);
4419         LDKDecodeError err_var = (*val->contents.err);
4420         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4421         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4422         long err_ref = (long)err_var.inner & ~1;
4423         return err_ref;
4424 }
4425 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4426         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
4427 }
4428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4429         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4430         CHECK(val->result_ok);
4431         LDKPing res_var = (*val->contents.result);
4432         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4433         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4434         long res_ref = (long)res_var.inner & ~1;
4435         return res_ref;
4436 }
4437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4438         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4439         CHECK(!val->result_ok);
4440         LDKDecodeError err_var = (*val->contents.err);
4441         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4442         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4443         long err_ref = (long)err_var.inner & ~1;
4444         return err_ref;
4445 }
4446 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4447         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
4448 }
4449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4450         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4451         CHECK(val->result_ok);
4452         LDKPong res_var = (*val->contents.result);
4453         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4454         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4455         long res_ref = (long)res_var.inner & ~1;
4456         return res_ref;
4457 }
4458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4459         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4460         CHECK(!val->result_ok);
4461         LDKDecodeError err_var = (*val->contents.err);
4462         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4463         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4464         long err_ref = (long)err_var.inner & ~1;
4465         return err_ref;
4466 }
4467 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4468         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4469 }
4470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4471         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4472         CHECK(val->result_ok);
4473         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
4474         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4475         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4476         long res_ref = (long)res_var.inner & ~1;
4477         return res_ref;
4478 }
4479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4480         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4481         CHECK(!val->result_ok);
4482         LDKDecodeError err_var = (*val->contents.err);
4483         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4484         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4485         long err_ref = (long)err_var.inner & ~1;
4486         return err_ref;
4487 }
4488 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4489         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4490 }
4491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4492         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4493         CHECK(val->result_ok);
4494         LDKChannelAnnouncement res_var = (*val->contents.result);
4495         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4496         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4497         long res_ref = (long)res_var.inner & ~1;
4498         return res_ref;
4499 }
4500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4501         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4502         CHECK(!val->result_ok);
4503         LDKDecodeError err_var = (*val->contents.err);
4504         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4505         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4506         long err_ref = (long)err_var.inner & ~1;
4507         return err_ref;
4508 }
4509 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4510         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
4511 }
4512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4513         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4514         CHECK(val->result_ok);
4515         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
4516         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4517         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4518         long res_ref = (long)res_var.inner & ~1;
4519         return res_ref;
4520 }
4521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4522         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4523         CHECK(!val->result_ok);
4524         LDKDecodeError err_var = (*val->contents.err);
4525         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4526         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4527         long err_ref = (long)err_var.inner & ~1;
4528         return err_ref;
4529 }
4530 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4531         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
4532 }
4533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4534         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4535         CHECK(val->result_ok);
4536         LDKChannelUpdate res_var = (*val->contents.result);
4537         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4538         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4539         long res_ref = (long)res_var.inner & ~1;
4540         return res_ref;
4541 }
4542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4543         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4544         CHECK(!val->result_ok);
4545         LDKDecodeError err_var = (*val->contents.err);
4546         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4547         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4548         long err_ref = (long)err_var.inner & ~1;
4549         return err_ref;
4550 }
4551 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4552         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
4553 }
4554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4555         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4556         CHECK(val->result_ok);
4557         LDKErrorMessage res_var = (*val->contents.result);
4558         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4559         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4560         long res_ref = (long)res_var.inner & ~1;
4561         return res_ref;
4562 }
4563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4564         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4565         CHECK(!val->result_ok);
4566         LDKDecodeError err_var = (*val->contents.err);
4567         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4568         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4569         long err_ref = (long)err_var.inner & ~1;
4570         return err_ref;
4571 }
4572 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4573         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4574 }
4575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4576         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4577         CHECK(val->result_ok);
4578         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
4579         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4580         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4581         long res_ref = (long)res_var.inner & ~1;
4582         return res_ref;
4583 }
4584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4585         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4586         CHECK(!val->result_ok);
4587         LDKDecodeError err_var = (*val->contents.err);
4588         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4589         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4590         long err_ref = (long)err_var.inner & ~1;
4591         return err_ref;
4592 }
4593 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4594         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4595 }
4596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4597         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4598         CHECK(val->result_ok);
4599         LDKNodeAnnouncement res_var = (*val->contents.result);
4600         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4601         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4602         long res_ref = (long)res_var.inner & ~1;
4603         return res_ref;
4604 }
4605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4606         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4607         CHECK(!val->result_ok);
4608         LDKDecodeError err_var = (*val->contents.err);
4609         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4610         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4611         long err_ref = (long)err_var.inner & ~1;
4612         return err_ref;
4613 }
4614 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4615         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
4616 }
4617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4618         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4619         CHECK(val->result_ok);
4620         LDKQueryShortChannelIds res_var = (*val->contents.result);
4621         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4622         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4623         long res_ref = (long)res_var.inner & ~1;
4624         return res_ref;
4625 }
4626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4627         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4628         CHECK(!val->result_ok);
4629         LDKDecodeError err_var = (*val->contents.err);
4630         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4631         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4632         long err_ref = (long)err_var.inner & ~1;
4633         return err_ref;
4634 }
4635 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4636         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
4637 }
4638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4639         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4640         CHECK(val->result_ok);
4641         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
4642         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4643         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4644         long res_ref = (long)res_var.inner & ~1;
4645         return res_ref;
4646 }
4647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4648         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4649         CHECK(!val->result_ok);
4650         LDKDecodeError err_var = (*val->contents.err);
4651         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4652         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4653         long err_ref = (long)err_var.inner & ~1;
4654         return err_ref;
4655 }
4656 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4657         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
4658 }
4659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4660         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4661         CHECK(val->result_ok);
4662         LDKQueryChannelRange res_var = (*val->contents.result);
4663         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4664         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4665         long res_ref = (long)res_var.inner & ~1;
4666         return res_ref;
4667 }
4668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4669         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4670         CHECK(!val->result_ok);
4671         LDKDecodeError err_var = (*val->contents.err);
4672         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4673         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4674         long err_ref = (long)err_var.inner & ~1;
4675         return err_ref;
4676 }
4677 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4678         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
4679 }
4680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4681         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4682         CHECK(val->result_ok);
4683         LDKReplyChannelRange res_var = (*val->contents.result);
4684         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4685         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4686         long res_ref = (long)res_var.inner & ~1;
4687         return res_ref;
4688 }
4689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4690         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4691         CHECK(!val->result_ok);
4692         LDKDecodeError err_var = (*val->contents.err);
4693         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4694         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4695         long err_ref = (long)err_var.inner & ~1;
4696         return err_ref;
4697 }
4698 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4699         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
4700 }
4701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4702         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4703         CHECK(val->result_ok);
4704         LDKGossipTimestampFilter res_var = (*val->contents.result);
4705         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4706         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4707         long res_ref = (long)res_var.inner & ~1;
4708         return res_ref;
4709 }
4710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4711         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4712         CHECK(!val->result_ok);
4713         LDKDecodeError err_var = (*val->contents.err);
4714         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4715         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4716         long err_ref = (long)err_var.inner & ~1;
4717         return err_ref;
4718 }
4719 typedef struct LDKMessageSendEventsProvider_JCalls {
4720         atomic_size_t refcnt;
4721         JavaVM *vm;
4722         jweak o;
4723         jmethodID get_and_clear_pending_msg_events_meth;
4724 } LDKMessageSendEventsProvider_JCalls;
4725 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
4726         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4727         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4728                 JNIEnv *env;
4729                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4730                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4731                 FREE(j_calls);
4732         }
4733 }
4734 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
4735         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4736         JNIEnv *env;
4737         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4738         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4739         CHECK(obj != NULL);
4740         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
4741         LDKCVec_MessageSendEventZ ret_constr;
4742         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
4743         if (ret_constr.datalen > 0)
4744                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4745         else
4746                 ret_constr.data = NULL;
4747         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
4748         for (size_t s = 0; s < ret_constr.datalen; s++) {
4749                 int64_t ret_conv_18 = ret_vals[s];
4750                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
4751                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
4752                 ret_constr.data[s] = ret_conv_18_conv;
4753         }
4754         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
4755         return ret_constr;
4756 }
4757 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
4758         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4759         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4760         return (void*) this_arg;
4761 }
4762 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
4763         jclass c = (*env)->GetObjectClass(env, o);
4764         CHECK(c != NULL);
4765         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
4766         atomic_init(&calls->refcnt, 1);
4767         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4768         calls->o = (*env)->NewWeakGlobalRef(env, o);
4769         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
4770         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
4771
4772         LDKMessageSendEventsProvider ret = {
4773                 .this_arg = (void*) calls,
4774                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
4775                 .free = LDKMessageSendEventsProvider_JCalls_free,
4776         };
4777         return ret;
4778 }
4779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
4780         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
4781         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
4782         return (long)res_ptr;
4783 }
4784 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4785         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
4786         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
4787         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4788         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4789         for (size_t s = 0; s < ret_var.datalen; s++) {
4790                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
4791                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
4792                 long ret_conv_18_ref = (long)ret_conv_18_copy;
4793                 ret_arr_ptr[s] = ret_conv_18_ref;
4794         }
4795         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4796         FREE(ret_var.data);
4797         return ret_arr;
4798 }
4799
4800 typedef struct LDKEventsProvider_JCalls {
4801         atomic_size_t refcnt;
4802         JavaVM *vm;
4803         jweak o;
4804         jmethodID get_and_clear_pending_events_meth;
4805 } LDKEventsProvider_JCalls;
4806 static void LDKEventsProvider_JCalls_free(void* this_arg) {
4807         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4808         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4809                 JNIEnv *env;
4810                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4811                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4812                 FREE(j_calls);
4813         }
4814 }
4815 LDKCVec_EventZ get_and_clear_pending_events_LDKEventsProvider_jcall(const void* this_arg) {
4816         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4817         JNIEnv *env;
4818         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4819         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4820         CHECK(obj != NULL);
4821         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_events_meth);
4822         LDKCVec_EventZ ret_constr;
4823         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
4824         if (ret_constr.datalen > 0)
4825                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
4826         else
4827                 ret_constr.data = NULL;
4828         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
4829         for (size_t h = 0; h < ret_constr.datalen; h++) {
4830                 int64_t ret_conv_7 = ret_vals[h];
4831                 LDKEvent ret_conv_7_conv = *(LDKEvent*)(((uint64_t)ret_conv_7) & ~1);
4832                 ret_conv_7_conv = Event_clone((LDKEvent*)(((uint64_t)ret_conv_7) & ~1));
4833                 ret_constr.data[h] = ret_conv_7_conv;
4834         }
4835         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
4836         return ret_constr;
4837 }
4838 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
4839         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4840         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4841         return (void*) this_arg;
4842 }
4843 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
4844         jclass c = (*env)->GetObjectClass(env, o);
4845         CHECK(c != NULL);
4846         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
4847         atomic_init(&calls->refcnt, 1);
4848         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4849         calls->o = (*env)->NewWeakGlobalRef(env, o);
4850         calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()[J");
4851         CHECK(calls->get_and_clear_pending_events_meth != NULL);
4852
4853         LDKEventsProvider ret = {
4854                 .this_arg = (void*) calls,
4855                 .get_and_clear_pending_events = get_and_clear_pending_events_LDKEventsProvider_jcall,
4856                 .free = LDKEventsProvider_JCalls_free,
4857         };
4858         return ret;
4859 }
4860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
4861         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
4862         *res_ptr = LDKEventsProvider_init(env, clz, o);
4863         return (long)res_ptr;
4864 }
4865 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_EventsProvider_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4866         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
4867         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
4868         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4869         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4870         for (size_t h = 0; h < ret_var.datalen; h++) {
4871                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
4872                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
4873                 long ret_conv_7_ref = (long)ret_conv_7_copy;
4874                 ret_arr_ptr[h] = ret_conv_7_ref;
4875         }
4876         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4877         FREE(ret_var.data);
4878         return ret_arr;
4879 }
4880
4881 typedef struct LDKAccess_JCalls {
4882         atomic_size_t refcnt;
4883         JavaVM *vm;
4884         jweak o;
4885         jmethodID get_utxo_meth;
4886 } LDKAccess_JCalls;
4887 static void LDKAccess_JCalls_free(void* this_arg) {
4888         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4889         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4890                 JNIEnv *env;
4891                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4892                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4893                 FREE(j_calls);
4894         }
4895 }
4896 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4897         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4898         JNIEnv *env;
4899         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4900         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
4901         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
4902         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4903         CHECK(obj != NULL);
4904         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4905         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
4906         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
4907         return ret_conv;
4908 }
4909 static void* LDKAccess_JCalls_clone(const void* this_arg) {
4910         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4911         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4912         return (void*) this_arg;
4913 }
4914 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
4915         jclass c = (*env)->GetObjectClass(env, o);
4916         CHECK(c != NULL);
4917         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4918         atomic_init(&calls->refcnt, 1);
4919         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4920         calls->o = (*env)->NewWeakGlobalRef(env, o);
4921         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
4922         CHECK(calls->get_utxo_meth != NULL);
4923
4924         LDKAccess ret = {
4925                 .this_arg = (void*) calls,
4926                 .get_utxo = get_utxo_LDKAccess_jcall,
4927                 .free = LDKAccess_JCalls_free,
4928         };
4929         return ret;
4930 }
4931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
4932         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4933         *res_ptr = LDKAccess_init(env, clz, o);
4934         return (long)res_ptr;
4935 }
4936 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) {
4937         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
4938         unsigned char genesis_hash_arr[32];
4939         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
4940         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
4941         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4942         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4943         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4944         return (long)ret_conv;
4945 }
4946
4947 typedef struct LDKListen_JCalls {
4948         atomic_size_t refcnt;
4949         JavaVM *vm;
4950         jweak o;
4951         jmethodID block_connected_meth;
4952         jmethodID block_disconnected_meth;
4953 } LDKListen_JCalls;
4954 static void LDKListen_JCalls_free(void* this_arg) {
4955         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4956         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4957                 JNIEnv *env;
4958                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4959                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4960                 FREE(j_calls);
4961         }
4962 }
4963 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
4964         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4965         JNIEnv *env;
4966         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4967         LDKu8slice block_var = block;
4968         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
4969         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
4970         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4971         CHECK(obj != NULL);
4972         return (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
4973 }
4974 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
4975         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4976         JNIEnv *env;
4977         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4978         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
4979         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
4980         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4981         CHECK(obj != NULL);
4982         return (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
4983 }
4984 static void* LDKListen_JCalls_clone(const void* this_arg) {
4985         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4986         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4987         return (void*) this_arg;
4988 }
4989 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
4990         jclass c = (*env)->GetObjectClass(env, o);
4991         CHECK(c != NULL);
4992         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
4993         atomic_init(&calls->refcnt, 1);
4994         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4995         calls->o = (*env)->NewWeakGlobalRef(env, o);
4996         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
4997         CHECK(calls->block_connected_meth != NULL);
4998         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
4999         CHECK(calls->block_disconnected_meth != NULL);
5000
5001         LDKListen ret = {
5002                 .this_arg = (void*) calls,
5003                 .block_connected = block_connected_LDKListen_jcall,
5004                 .block_disconnected = block_disconnected_LDKListen_jcall,
5005                 .free = LDKListen_JCalls_free,
5006         };
5007         return ret;
5008 }
5009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
5010         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
5011         *res_ptr = LDKListen_init(env, clz, o);
5012         return (long)res_ptr;
5013 }
5014 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) {
5015         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
5016         LDKu8slice block_ref;
5017         block_ref.datalen = (*env)->GetArrayLength(env, block);
5018         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
5019         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
5020         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
5021 }
5022
5023 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) {
5024         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
5025         unsigned char header_arr[80];
5026         CHECK((*env)->GetArrayLength(env, header) == 80);
5027         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
5028         unsigned char (*header_ref)[80] = &header_arr;
5029         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
5030 }
5031
5032 typedef struct LDKFilter_JCalls {
5033         atomic_size_t refcnt;
5034         JavaVM *vm;
5035         jweak o;
5036         jmethodID register_tx_meth;
5037         jmethodID register_output_meth;
5038 } LDKFilter_JCalls;
5039 static void LDKFilter_JCalls_free(void* this_arg) {
5040         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5041         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5042                 JNIEnv *env;
5043                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5044                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5045                 FREE(j_calls);
5046         }
5047 }
5048 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5049         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5050         JNIEnv *env;
5051         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5052         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
5053         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
5054         LDKu8slice script_pubkey_var = script_pubkey;
5055         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
5056         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
5057         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5058         CHECK(obj != NULL);
5059         return (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
5060 }
5061 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5062         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5063         JNIEnv *env;
5064         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5065         LDKWatchedOutput output_var = output;
5066         CHECK((((long)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5067         CHECK((((long)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5068         long output_ref = (long)output_var.inner;
5069         if (output_var.is_owned) {
5070                 output_ref |= 1;
5071         }
5072         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5073         CHECK(obj != NULL);
5074         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)(*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
5075         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
5076         // Warning: we may need a move here but no clone is available for LDKCOption_C2Tuple_usizeTransactionZZ
5077         return ret_conv;
5078 }
5079 static void* LDKFilter_JCalls_clone(const void* this_arg) {
5080         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5081         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5082         return (void*) this_arg;
5083 }
5084 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
5085         jclass c = (*env)->GetObjectClass(env, o);
5086         CHECK(c != NULL);
5087         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5088         atomic_init(&calls->refcnt, 1);
5089         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5090         calls->o = (*env)->NewWeakGlobalRef(env, o);
5091         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
5092         CHECK(calls->register_tx_meth != NULL);
5093         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
5094         CHECK(calls->register_output_meth != NULL);
5095
5096         LDKFilter ret = {
5097                 .this_arg = (void*) calls,
5098                 .register_tx = register_tx_LDKFilter_jcall,
5099                 .register_output = register_output_LDKFilter_jcall,
5100                 .free = LDKFilter_JCalls_free,
5101         };
5102         return ret;
5103 }
5104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
5105         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5106         *res_ptr = LDKFilter_init(env, clz, o);
5107         return (long)res_ptr;
5108 }
5109 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) {
5110         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5111         unsigned char txid_arr[32];
5112         CHECK((*env)->GetArrayLength(env, txid) == 32);
5113         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
5114         unsigned char (*txid_ref)[32] = &txid_arr;
5115         LDKu8slice script_pubkey_ref;
5116         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
5117         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
5118         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5119         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
5120 }
5121
5122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
5123         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5124         LDKWatchedOutput output_conv;
5125         output_conv.inner = (void*)(output & (~1));
5126         output_conv.is_owned = (output & 1) || (output == 0);
5127         // Warning: we need a move here but no clone is available for LDKWatchedOutput
5128         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5129         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5130         long ret_ref = (long)ret_copy;
5131         return ret_ref;
5132 }
5133
5134 typedef struct LDKPersist_JCalls {
5135         atomic_size_t refcnt;
5136         JavaVM *vm;
5137         jweak o;
5138         jmethodID persist_new_channel_meth;
5139         jmethodID update_persisted_channel_meth;
5140 } LDKPersist_JCalls;
5141 static void LDKPersist_JCalls_free(void* this_arg) {
5142         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5143         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5144                 JNIEnv *env;
5145                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5146                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5147                 FREE(j_calls);
5148         }
5149 }
5150 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
5151         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5152         JNIEnv *env;
5153         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5154         LDKOutPoint id_var = id;
5155         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5156         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5157         long id_ref = (long)id_var.inner;
5158         if (id_var.is_owned) {
5159                 id_ref |= 1;
5160         }
5161         LDKChannelMonitor data_var = *data;
5162         data_var = ChannelMonitor_clone(data);
5163         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5164         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5165         long data_ref = (long)data_var.inner;
5166         if (data_var.is_owned) {
5167                 data_ref |= 1;
5168         }
5169         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5170         CHECK(obj != NULL);
5171         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
5172         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5173         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5174         return ret_conv;
5175 }
5176 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
5177         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5178         JNIEnv *env;
5179         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5180         LDKOutPoint id_var = id;
5181         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5182         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5183         long id_ref = (long)id_var.inner;
5184         if (id_var.is_owned) {
5185                 id_ref |= 1;
5186         }
5187         LDKChannelMonitorUpdate update_var = *update;
5188         update_var = ChannelMonitorUpdate_clone(update);
5189         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5190         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5191         long update_ref = (long)update_var.inner;
5192         if (update_var.is_owned) {
5193                 update_ref |= 1;
5194         }
5195         LDKChannelMonitor data_var = *data;
5196         data_var = ChannelMonitor_clone(data);
5197         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5198         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5199         long data_ref = (long)data_var.inner;
5200         if (data_var.is_owned) {
5201                 data_ref |= 1;
5202         }
5203         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5204         CHECK(obj != NULL);
5205         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
5206         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5207         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5208         return ret_conv;
5209 }
5210 static void* LDKPersist_JCalls_clone(const void* this_arg) {
5211         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5212         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5213         return (void*) this_arg;
5214 }
5215 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
5216         jclass c = (*env)->GetObjectClass(env, o);
5217         CHECK(c != NULL);
5218         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
5219         atomic_init(&calls->refcnt, 1);
5220         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5221         calls->o = (*env)->NewWeakGlobalRef(env, o);
5222         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
5223         CHECK(calls->persist_new_channel_meth != NULL);
5224         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
5225         CHECK(calls->update_persisted_channel_meth != NULL);
5226
5227         LDKPersist ret = {
5228                 .this_arg = (void*) calls,
5229                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
5230                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
5231                 .free = LDKPersist_JCalls_free,
5232         };
5233         return ret;
5234 }
5235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
5236         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
5237         *res_ptr = LDKPersist_init(env, clz, o);
5238         return (long)res_ptr;
5239 }
5240 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) {
5241         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5242         LDKOutPoint id_conv;
5243         id_conv.inner = (void*)(id & (~1));
5244         id_conv.is_owned = (id & 1) || (id == 0);
5245         id_conv = OutPoint_clone(&id_conv);
5246         LDKChannelMonitor data_conv;
5247         data_conv.inner = (void*)(data & (~1));
5248         data_conv.is_owned = false;
5249         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5250         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
5251         return (long)ret_conv;
5252 }
5253
5254 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) {
5255         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5256         LDKOutPoint id_conv;
5257         id_conv.inner = (void*)(id & (~1));
5258         id_conv.is_owned = (id & 1) || (id == 0);
5259         id_conv = OutPoint_clone(&id_conv);
5260         LDKChannelMonitorUpdate update_conv;
5261         update_conv.inner = (void*)(update & (~1));
5262         update_conv.is_owned = false;
5263         LDKChannelMonitor data_conv;
5264         data_conv.inner = (void*)(data & (~1));
5265         data_conv.is_owned = false;
5266         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5267         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
5268         return (long)ret_conv;
5269 }
5270
5271 typedef struct LDKChannelMessageHandler_JCalls {
5272         atomic_size_t refcnt;
5273         JavaVM *vm;
5274         jweak o;
5275         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5276         jmethodID handle_open_channel_meth;
5277         jmethodID handle_accept_channel_meth;
5278         jmethodID handle_funding_created_meth;
5279         jmethodID handle_funding_signed_meth;
5280         jmethodID handle_funding_locked_meth;
5281         jmethodID handle_shutdown_meth;
5282         jmethodID handle_closing_signed_meth;
5283         jmethodID handle_update_add_htlc_meth;
5284         jmethodID handle_update_fulfill_htlc_meth;
5285         jmethodID handle_update_fail_htlc_meth;
5286         jmethodID handle_update_fail_malformed_htlc_meth;
5287         jmethodID handle_commitment_signed_meth;
5288         jmethodID handle_revoke_and_ack_meth;
5289         jmethodID handle_update_fee_meth;
5290         jmethodID handle_announcement_signatures_meth;
5291         jmethodID peer_disconnected_meth;
5292         jmethodID peer_connected_meth;
5293         jmethodID handle_channel_reestablish_meth;
5294         jmethodID handle_channel_update_meth;
5295         jmethodID handle_error_meth;
5296 } LDKChannelMessageHandler_JCalls;
5297 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
5298         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5299         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5300                 JNIEnv *env;
5301                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5302                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5303                 FREE(j_calls);
5304         }
5305 }
5306 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
5307         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5308         JNIEnv *env;
5309         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5310         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5311         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5312         LDKInitFeatures their_features_var = their_features;
5313         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5314         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5315         long their_features_ref = (long)their_features_var.inner;
5316         if (their_features_var.is_owned) {
5317                 their_features_ref |= 1;
5318         }
5319         LDKOpenChannel msg_var = *msg;
5320         msg_var = OpenChannel_clone(msg);
5321         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5322         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5323         long msg_ref = (long)msg_var.inner;
5324         if (msg_var.is_owned) {
5325                 msg_ref |= 1;
5326         }
5327         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5328         CHECK(obj != NULL);
5329         return (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5330 }
5331 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
5332         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5333         JNIEnv *env;
5334         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5335         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5336         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5337         LDKInitFeatures their_features_var = their_features;
5338         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5339         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5340         long their_features_ref = (long)their_features_var.inner;
5341         if (their_features_var.is_owned) {
5342                 their_features_ref |= 1;
5343         }
5344         LDKAcceptChannel msg_var = *msg;
5345         msg_var = AcceptChannel_clone(msg);
5346         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5347         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5348         long msg_ref = (long)msg_var.inner;
5349         if (msg_var.is_owned) {
5350                 msg_ref |= 1;
5351         }
5352         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5353         CHECK(obj != NULL);
5354         return (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5355 }
5356 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
5357         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5358         JNIEnv *env;
5359         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5360         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5361         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5362         LDKFundingCreated msg_var = *msg;
5363         msg_var = FundingCreated_clone(msg);
5364         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5365         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5366         long msg_ref = (long)msg_var.inner;
5367         if (msg_var.is_owned) {
5368                 msg_ref |= 1;
5369         }
5370         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5371         CHECK(obj != NULL);
5372         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
5373 }
5374 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
5375         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5376         JNIEnv *env;
5377         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5378         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5379         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5380         LDKFundingSigned msg_var = *msg;
5381         msg_var = FundingSigned_clone(msg);
5382         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5383         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5384         long msg_ref = (long)msg_var.inner;
5385         if (msg_var.is_owned) {
5386                 msg_ref |= 1;
5387         }
5388         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5389         CHECK(obj != NULL);
5390         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
5391 }
5392 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
5393         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5394         JNIEnv *env;
5395         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5396         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5397         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5398         LDKFundingLocked msg_var = *msg;
5399         msg_var = FundingLocked_clone(msg);
5400         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5401         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5402         long msg_ref = (long)msg_var.inner;
5403         if (msg_var.is_owned) {
5404                 msg_ref |= 1;
5405         }
5406         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5407         CHECK(obj != NULL);
5408         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
5409 }
5410 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
5411         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5412         JNIEnv *env;
5413         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5414         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5415         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5416         LDKInitFeatures their_features_var = *their_features;
5417         their_features_var = InitFeatures_clone(their_features);
5418         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5419         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5420         long their_features_ref = (long)their_features_var.inner;
5421         if (their_features_var.is_owned) {
5422                 their_features_ref |= 1;
5423         }
5424         LDKShutdown msg_var = *msg;
5425         msg_var = Shutdown_clone(msg);
5426         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5427         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5428         long msg_ref = (long)msg_var.inner;
5429         if (msg_var.is_owned) {
5430                 msg_ref |= 1;
5431         }
5432         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5433         CHECK(obj != NULL);
5434         return (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
5435 }
5436 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
5437         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5438         JNIEnv *env;
5439         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5440         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5441         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5442         LDKClosingSigned msg_var = *msg;
5443         msg_var = ClosingSigned_clone(msg);
5444         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5445         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5446         long msg_ref = (long)msg_var.inner;
5447         if (msg_var.is_owned) {
5448                 msg_ref |= 1;
5449         }
5450         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5451         CHECK(obj != NULL);
5452         return (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
5453 }
5454 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
5455         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5456         JNIEnv *env;
5457         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5458         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5459         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5460         LDKUpdateAddHTLC msg_var = *msg;
5461         msg_var = UpdateAddHTLC_clone(msg);
5462         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5463         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5464         long msg_ref = (long)msg_var.inner;
5465         if (msg_var.is_owned) {
5466                 msg_ref |= 1;
5467         }
5468         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5469         CHECK(obj != NULL);
5470         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
5471 }
5472 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
5473         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5474         JNIEnv *env;
5475         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5476         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5477         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5478         LDKUpdateFulfillHTLC msg_var = *msg;
5479         msg_var = UpdateFulfillHTLC_clone(msg);
5480         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5481         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5482         long msg_ref = (long)msg_var.inner;
5483         if (msg_var.is_owned) {
5484                 msg_ref |= 1;
5485         }
5486         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5487         CHECK(obj != NULL);
5488         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
5489 }
5490 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
5491         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5492         JNIEnv *env;
5493         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5494         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5495         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5496         LDKUpdateFailHTLC msg_var = *msg;
5497         msg_var = UpdateFailHTLC_clone(msg);
5498         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5499         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5500         long msg_ref = (long)msg_var.inner;
5501         if (msg_var.is_owned) {
5502                 msg_ref |= 1;
5503         }
5504         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5505         CHECK(obj != NULL);
5506         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
5507 }
5508 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
5509         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5510         JNIEnv *env;
5511         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5512         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5513         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5514         LDKUpdateFailMalformedHTLC msg_var = *msg;
5515         msg_var = UpdateFailMalformedHTLC_clone(msg);
5516         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5517         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5518         long msg_ref = (long)msg_var.inner;
5519         if (msg_var.is_owned) {
5520                 msg_ref |= 1;
5521         }
5522         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5523         CHECK(obj != NULL);
5524         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
5525 }
5526 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
5527         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5528         JNIEnv *env;
5529         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5530         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5531         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5532         LDKCommitmentSigned msg_var = *msg;
5533         msg_var = CommitmentSigned_clone(msg);
5534         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5535         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5536         long msg_ref = (long)msg_var.inner;
5537         if (msg_var.is_owned) {
5538                 msg_ref |= 1;
5539         }
5540         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5541         CHECK(obj != NULL);
5542         return (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
5543 }
5544 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
5545         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5546         JNIEnv *env;
5547         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5548         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5549         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5550         LDKRevokeAndACK msg_var = *msg;
5551         msg_var = RevokeAndACK_clone(msg);
5552         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5553         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5554         long msg_ref = (long)msg_var.inner;
5555         if (msg_var.is_owned) {
5556                 msg_ref |= 1;
5557         }
5558         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5559         CHECK(obj != NULL);
5560         return (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
5561 }
5562 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
5563         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5564         JNIEnv *env;
5565         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5566         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5567         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5568         LDKUpdateFee msg_var = *msg;
5569         msg_var = UpdateFee_clone(msg);
5570         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5571         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5572         long msg_ref = (long)msg_var.inner;
5573         if (msg_var.is_owned) {
5574                 msg_ref |= 1;
5575         }
5576         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5577         CHECK(obj != NULL);
5578         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
5579 }
5580 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
5581         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5582         JNIEnv *env;
5583         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5584         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5585         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5586         LDKAnnouncementSignatures msg_var = *msg;
5587         msg_var = AnnouncementSignatures_clone(msg);
5588         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5589         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5590         long msg_ref = (long)msg_var.inner;
5591         if (msg_var.is_owned) {
5592                 msg_ref |= 1;
5593         }
5594         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5595         CHECK(obj != NULL);
5596         return (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
5597 }
5598 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
5599         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5600         JNIEnv *env;
5601         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5602         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5603         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5604         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5605         CHECK(obj != NULL);
5606         return (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
5607 }
5608 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
5609         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5610         JNIEnv *env;
5611         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5612         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5613         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5614         LDKInit msg_var = *msg;
5615         msg_var = Init_clone(msg);
5616         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5617         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5618         long msg_ref = (long)msg_var.inner;
5619         if (msg_var.is_owned) {
5620                 msg_ref |= 1;
5621         }
5622         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5623         CHECK(obj != NULL);
5624         return (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
5625 }
5626 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
5627         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5628         JNIEnv *env;
5629         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5630         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5631         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5632         LDKChannelReestablish msg_var = *msg;
5633         msg_var = ChannelReestablish_clone(msg);
5634         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5635         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5636         long msg_ref = (long)msg_var.inner;
5637         if (msg_var.is_owned) {
5638                 msg_ref |= 1;
5639         }
5640         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5641         CHECK(obj != NULL);
5642         return (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
5643 }
5644 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
5645         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5646         JNIEnv *env;
5647         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5648         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5649         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5650         LDKChannelUpdate msg_var = *msg;
5651         msg_var = ChannelUpdate_clone(msg);
5652         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5653         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5654         long msg_ref = (long)msg_var.inner;
5655         if (msg_var.is_owned) {
5656                 msg_ref |= 1;
5657         }
5658         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5659         CHECK(obj != NULL);
5660         return (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
5661 }
5662 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
5663         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5664         JNIEnv *env;
5665         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5666         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5667         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5668         LDKErrorMessage msg_var = *msg;
5669         msg_var = ErrorMessage_clone(msg);
5670         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5671         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5672         long msg_ref = (long)msg_var.inner;
5673         if (msg_var.is_owned) {
5674                 msg_ref |= 1;
5675         }
5676         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5677         CHECK(obj != NULL);
5678         return (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
5679 }
5680 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
5681         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5682         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5683         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5684         return (void*) this_arg;
5685 }
5686 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
5687         jclass c = (*env)->GetObjectClass(env, o);
5688         CHECK(c != NULL);
5689         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
5690         atomic_init(&calls->refcnt, 1);
5691         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5692         calls->o = (*env)->NewWeakGlobalRef(env, o);
5693         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
5694         CHECK(calls->handle_open_channel_meth != NULL);
5695         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
5696         CHECK(calls->handle_accept_channel_meth != NULL);
5697         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
5698         CHECK(calls->handle_funding_created_meth != NULL);
5699         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
5700         CHECK(calls->handle_funding_signed_meth != NULL);
5701         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
5702         CHECK(calls->handle_funding_locked_meth != NULL);
5703         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
5704         CHECK(calls->handle_shutdown_meth != NULL);
5705         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
5706         CHECK(calls->handle_closing_signed_meth != NULL);
5707         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
5708         CHECK(calls->handle_update_add_htlc_meth != NULL);
5709         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
5710         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
5711         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
5712         CHECK(calls->handle_update_fail_htlc_meth != NULL);
5713         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
5714         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
5715         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
5716         CHECK(calls->handle_commitment_signed_meth != NULL);
5717         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
5718         CHECK(calls->handle_revoke_and_ack_meth != NULL);
5719         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
5720         CHECK(calls->handle_update_fee_meth != NULL);
5721         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
5722         CHECK(calls->handle_announcement_signatures_meth != NULL);
5723         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
5724         CHECK(calls->peer_disconnected_meth != NULL);
5725         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
5726         CHECK(calls->peer_connected_meth != NULL);
5727         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
5728         CHECK(calls->handle_channel_reestablish_meth != NULL);
5729         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
5730         CHECK(calls->handle_channel_update_meth != NULL);
5731         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
5732         CHECK(calls->handle_error_meth != NULL);
5733
5734         LDKChannelMessageHandler ret = {
5735                 .this_arg = (void*) calls,
5736                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
5737                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
5738                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
5739                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
5740                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
5741                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
5742                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
5743                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
5744                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
5745                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
5746                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
5747                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
5748                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
5749                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
5750                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
5751                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
5752                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
5753                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
5754                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
5755                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
5756                 .free = LDKChannelMessageHandler_JCalls_free,
5757                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
5758         };
5759         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5760         return ret;
5761 }
5762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
5763         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
5764         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
5765         return (long)res_ptr;
5766 }
5767 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) {
5768         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5769         LDKPublicKey their_node_id_ref;
5770         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5771         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5772         LDKInitFeatures their_features_conv;
5773         their_features_conv.inner = (void*)(their_features & (~1));
5774         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5775         their_features_conv = InitFeatures_clone(&their_features_conv);
5776         LDKOpenChannel msg_conv;
5777         msg_conv.inner = (void*)(msg & (~1));
5778         msg_conv.is_owned = false;
5779         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5780 }
5781
5782 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) {
5783         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5784         LDKPublicKey their_node_id_ref;
5785         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5786         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5787         LDKInitFeatures their_features_conv;
5788         their_features_conv.inner = (void*)(their_features & (~1));
5789         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5790         their_features_conv = InitFeatures_clone(&their_features_conv);
5791         LDKAcceptChannel msg_conv;
5792         msg_conv.inner = (void*)(msg & (~1));
5793         msg_conv.is_owned = false;
5794         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5795 }
5796
5797 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) {
5798         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5799         LDKPublicKey their_node_id_ref;
5800         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5801         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5802         LDKFundingCreated msg_conv;
5803         msg_conv.inner = (void*)(msg & (~1));
5804         msg_conv.is_owned = false;
5805         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5806 }
5807
5808 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) {
5809         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5810         LDKPublicKey their_node_id_ref;
5811         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5812         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5813         LDKFundingSigned msg_conv;
5814         msg_conv.inner = (void*)(msg & (~1));
5815         msg_conv.is_owned = false;
5816         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5817 }
5818
5819 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) {
5820         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5821         LDKPublicKey their_node_id_ref;
5822         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5823         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5824         LDKFundingLocked msg_conv;
5825         msg_conv.inner = (void*)(msg & (~1));
5826         msg_conv.is_owned = false;
5827         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5828 }
5829
5830 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) {
5831         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5832         LDKPublicKey their_node_id_ref;
5833         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5834         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5835         LDKInitFeatures their_features_conv;
5836         their_features_conv.inner = (void*)(their_features & (~1));
5837         their_features_conv.is_owned = false;
5838         LDKShutdown msg_conv;
5839         msg_conv.inner = (void*)(msg & (~1));
5840         msg_conv.is_owned = false;
5841         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
5842 }
5843
5844 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) {
5845         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5846         LDKPublicKey their_node_id_ref;
5847         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5848         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5849         LDKClosingSigned msg_conv;
5850         msg_conv.inner = (void*)(msg & (~1));
5851         msg_conv.is_owned = false;
5852         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5853 }
5854
5855 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) {
5856         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5857         LDKPublicKey their_node_id_ref;
5858         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5859         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5860         LDKUpdateAddHTLC msg_conv;
5861         msg_conv.inner = (void*)(msg & (~1));
5862         msg_conv.is_owned = false;
5863         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5864 }
5865
5866 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) {
5867         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5868         LDKPublicKey their_node_id_ref;
5869         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5870         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5871         LDKUpdateFulfillHTLC msg_conv;
5872         msg_conv.inner = (void*)(msg & (~1));
5873         msg_conv.is_owned = false;
5874         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5875 }
5876
5877 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) {
5878         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5879         LDKPublicKey their_node_id_ref;
5880         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5881         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5882         LDKUpdateFailHTLC msg_conv;
5883         msg_conv.inner = (void*)(msg & (~1));
5884         msg_conv.is_owned = false;
5885         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5886 }
5887
5888 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) {
5889         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5890         LDKPublicKey their_node_id_ref;
5891         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5892         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5893         LDKUpdateFailMalformedHTLC msg_conv;
5894         msg_conv.inner = (void*)(msg & (~1));
5895         msg_conv.is_owned = false;
5896         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5897 }
5898
5899 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) {
5900         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5901         LDKPublicKey their_node_id_ref;
5902         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5903         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5904         LDKCommitmentSigned msg_conv;
5905         msg_conv.inner = (void*)(msg & (~1));
5906         msg_conv.is_owned = false;
5907         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5908 }
5909
5910 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) {
5911         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5912         LDKPublicKey their_node_id_ref;
5913         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5914         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5915         LDKRevokeAndACK msg_conv;
5916         msg_conv.inner = (void*)(msg & (~1));
5917         msg_conv.is_owned = false;
5918         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5919 }
5920
5921 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) {
5922         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5923         LDKPublicKey their_node_id_ref;
5924         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5925         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5926         LDKUpdateFee msg_conv;
5927         msg_conv.inner = (void*)(msg & (~1));
5928         msg_conv.is_owned = false;
5929         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5930 }
5931
5932 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) {
5933         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5934         LDKPublicKey their_node_id_ref;
5935         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5936         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5937         LDKAnnouncementSignatures msg_conv;
5938         msg_conv.inner = (void*)(msg & (~1));
5939         msg_conv.is_owned = false;
5940         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5941 }
5942
5943 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) {
5944         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5945         LDKPublicKey their_node_id_ref;
5946         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5947         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5948         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
5949 }
5950
5951 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) {
5952         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5953         LDKPublicKey their_node_id_ref;
5954         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5955         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5956         LDKInit msg_conv;
5957         msg_conv.inner = (void*)(msg & (~1));
5958         msg_conv.is_owned = false;
5959         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5960 }
5961
5962 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) {
5963         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5964         LDKPublicKey their_node_id_ref;
5965         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5966         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5967         LDKChannelReestablish msg_conv;
5968         msg_conv.inner = (void*)(msg & (~1));
5969         msg_conv.is_owned = false;
5970         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5971 }
5972
5973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
5974         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5975         LDKPublicKey their_node_id_ref;
5976         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5977         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5978         LDKChannelUpdate msg_conv;
5979         msg_conv.inner = (void*)(msg & (~1));
5980         msg_conv.is_owned = false;
5981         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5982 }
5983
5984 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) {
5985         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5986         LDKPublicKey their_node_id_ref;
5987         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5988         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5989         LDKErrorMessage msg_conv;
5990         msg_conv.inner = (void*)(msg & (~1));
5991         msg_conv.is_owned = false;
5992         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5993 }
5994
5995 typedef struct LDKRoutingMessageHandler_JCalls {
5996         atomic_size_t refcnt;
5997         JavaVM *vm;
5998         jweak o;
5999         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
6000         jmethodID handle_node_announcement_meth;
6001         jmethodID handle_channel_announcement_meth;
6002         jmethodID handle_channel_update_meth;
6003         jmethodID handle_htlc_fail_channel_update_meth;
6004         jmethodID get_next_channel_announcements_meth;
6005         jmethodID get_next_node_announcements_meth;
6006         jmethodID sync_routing_table_meth;
6007         jmethodID handle_reply_channel_range_meth;
6008         jmethodID handle_reply_short_channel_ids_end_meth;
6009         jmethodID handle_query_channel_range_meth;
6010         jmethodID handle_query_short_channel_ids_meth;
6011 } LDKRoutingMessageHandler_JCalls;
6012 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
6013         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6014         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6015                 JNIEnv *env;
6016                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6017                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6018                 FREE(j_calls);
6019         }
6020 }
6021 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
6022         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6023         JNIEnv *env;
6024         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6025         LDKNodeAnnouncement msg_var = *msg;
6026         msg_var = NodeAnnouncement_clone(msg);
6027         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6028         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6029         long msg_ref = (long)msg_var.inner;
6030         if (msg_var.is_owned) {
6031                 msg_ref |= 1;
6032         }
6033         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6034         CHECK(obj != NULL);
6035         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
6036         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6037         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6038         return ret_conv;
6039 }
6040 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
6041         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6042         JNIEnv *env;
6043         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6044         LDKChannelAnnouncement msg_var = *msg;
6045         msg_var = ChannelAnnouncement_clone(msg);
6046         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6047         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6048         long msg_ref = (long)msg_var.inner;
6049         if (msg_var.is_owned) {
6050                 msg_ref |= 1;
6051         }
6052         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6053         CHECK(obj != NULL);
6054         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
6055         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6056         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6057         return ret_conv;
6058 }
6059 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
6060         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6061         JNIEnv *env;
6062         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6063         LDKChannelUpdate msg_var = *msg;
6064         msg_var = ChannelUpdate_clone(msg);
6065         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6066         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6067         long msg_ref = (long)msg_var.inner;
6068         if (msg_var.is_owned) {
6069                 msg_ref |= 1;
6070         }
6071         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6072         CHECK(obj != NULL);
6073         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
6074         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6075         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6076         return ret_conv;
6077 }
6078 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
6079         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6080         JNIEnv *env;
6081         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6082         long ret_update = (long)update;
6083         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6084         CHECK(obj != NULL);
6085         return (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
6086 }
6087 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
6088         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6089         JNIEnv *env;
6090         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6091         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6092         CHECK(obj != NULL);
6093         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
6094         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
6095         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6096         if (ret_constr.datalen > 0)
6097                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
6098         else
6099                 ret_constr.data = NULL;
6100         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6101         for (size_t l = 0; l < ret_constr.datalen; l++) {
6102                 int64_t ret_conv_63 = ret_vals[l];
6103                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
6104                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
6105                 ret_constr.data[l] = ret_conv_63_conv;
6106         }
6107         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6108         return ret_constr;
6109 }
6110 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
6111         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6112         JNIEnv *env;
6113         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6114         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
6115         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
6116         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6117         CHECK(obj != NULL);
6118         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
6119         LDKCVec_NodeAnnouncementZ ret_constr;
6120         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6121         if (ret_constr.datalen > 0)
6122                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
6123         else
6124                 ret_constr.data = NULL;
6125         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6126         for (size_t s = 0; s < ret_constr.datalen; s++) {
6127                 int64_t ret_conv_18 = ret_vals[s];
6128                 LDKNodeAnnouncement ret_conv_18_conv;
6129                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
6130                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
6131                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
6132                 ret_constr.data[s] = ret_conv_18_conv;
6133         }
6134         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6135         return ret_constr;
6136 }
6137 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
6138         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6139         JNIEnv *env;
6140         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6141         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6142         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6143         LDKInit init_var = *init;
6144         init_var = Init_clone(init);
6145         CHECK((((long)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6146         CHECK((((long)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6147         long init_ref = (long)init_var.inner;
6148         if (init_var.is_owned) {
6149                 init_ref |= 1;
6150         }
6151         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6152         CHECK(obj != NULL);
6153         return (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
6154 }
6155 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
6156         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6157         JNIEnv *env;
6158         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6159         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6160         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6161         LDKReplyChannelRange msg_var = msg;
6162         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6163         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6164         long msg_ref = (long)msg_var.inner;
6165         if (msg_var.is_owned) {
6166                 msg_ref |= 1;
6167         }
6168         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6169         CHECK(obj != NULL);
6170         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
6171         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6172         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6173         return ret_conv;
6174 }
6175 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
6176         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6177         JNIEnv *env;
6178         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6179         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6180         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6181         LDKReplyShortChannelIdsEnd msg_var = msg;
6182         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6183         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6184         long msg_ref = (long)msg_var.inner;
6185         if (msg_var.is_owned) {
6186                 msg_ref |= 1;
6187         }
6188         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6189         CHECK(obj != NULL);
6190         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
6191         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6192         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6193         return ret_conv;
6194 }
6195 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
6196         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6197         JNIEnv *env;
6198         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6199         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6200         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6201         LDKQueryChannelRange msg_var = msg;
6202         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6203         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6204         long msg_ref = (long)msg_var.inner;
6205         if (msg_var.is_owned) {
6206                 msg_ref |= 1;
6207         }
6208         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6209         CHECK(obj != NULL);
6210         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
6211         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6212         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6213         return ret_conv;
6214 }
6215 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
6216         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6217         JNIEnv *env;
6218         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6219         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6220         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6221         LDKQueryShortChannelIds msg_var = msg;
6222         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6223         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6224         long msg_ref = (long)msg_var.inner;
6225         if (msg_var.is_owned) {
6226                 msg_ref |= 1;
6227         }
6228         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6229         CHECK(obj != NULL);
6230         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
6231         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6232         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6233         return ret_conv;
6234 }
6235 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
6236         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6237         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6238         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6239         return (void*) this_arg;
6240 }
6241 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
6242         jclass c = (*env)->GetObjectClass(env, o);
6243         CHECK(c != NULL);
6244         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
6245         atomic_init(&calls->refcnt, 1);
6246         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6247         calls->o = (*env)->NewWeakGlobalRef(env, o);
6248         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
6249         CHECK(calls->handle_node_announcement_meth != NULL);
6250         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
6251         CHECK(calls->handle_channel_announcement_meth != NULL);
6252         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
6253         CHECK(calls->handle_channel_update_meth != NULL);
6254         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
6255         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
6256         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
6257         CHECK(calls->get_next_channel_announcements_meth != NULL);
6258         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
6259         CHECK(calls->get_next_node_announcements_meth != NULL);
6260         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
6261         CHECK(calls->sync_routing_table_meth != NULL);
6262         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
6263         CHECK(calls->handle_reply_channel_range_meth != NULL);
6264         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
6265         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
6266         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
6267         CHECK(calls->handle_query_channel_range_meth != NULL);
6268         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
6269         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
6270
6271         LDKRoutingMessageHandler ret = {
6272                 .this_arg = (void*) calls,
6273                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
6274                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
6275                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
6276                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
6277                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
6278                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
6279                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
6280                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
6281                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
6282                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
6283                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
6284                 .free = LDKRoutingMessageHandler_JCalls_free,
6285                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
6286         };
6287         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6288         return ret;
6289 }
6290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
6291         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
6292         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
6293         return (long)res_ptr;
6294 }
6295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6296         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6297         LDKNodeAnnouncement msg_conv;
6298         msg_conv.inner = (void*)(msg & (~1));
6299         msg_conv.is_owned = false;
6300         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6301         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
6302         return (long)ret_conv;
6303 }
6304
6305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6306         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6307         LDKChannelAnnouncement msg_conv;
6308         msg_conv.inner = (void*)(msg & (~1));
6309         msg_conv.is_owned = false;
6310         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6311         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6312         return (long)ret_conv;
6313 }
6314
6315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6316         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6317         LDKChannelUpdate msg_conv;
6318         msg_conv.inner = (void*)(msg & (~1));
6319         msg_conv.is_owned = false;
6320         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6321         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
6322         return (long)ret_conv;
6323 }
6324
6325 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) {
6326         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6327         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
6328         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
6329 }
6330
6331 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) {
6332         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6333         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
6334         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6335         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6336         for (size_t l = 0; l < ret_var.datalen; l++) {
6337                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6338                 *ret_conv_63_ref = ret_var.data[l];
6339                 ret_arr_ptr[l] = (long)ret_conv_63_ref;
6340         }
6341         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6342         FREE(ret_var.data);
6343         return ret_arr;
6344 }
6345
6346 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) {
6347         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6348         LDKPublicKey starting_point_ref;
6349         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
6350         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
6351         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
6352         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6353         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6354         for (size_t s = 0; s < ret_var.datalen; s++) {
6355                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
6356                 CHECK((((long)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6357                 CHECK((((long)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6358                 long ret_conv_18_ref = (long)ret_conv_18_var.inner;
6359                 if (ret_conv_18_var.is_owned) {
6360                         ret_conv_18_ref |= 1;
6361                 }
6362                 ret_arr_ptr[s] = ret_conv_18_ref;
6363         }
6364         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6365         FREE(ret_var.data);
6366         return ret_arr;
6367 }
6368
6369 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) {
6370         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6371         LDKPublicKey their_node_id_ref;
6372         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6373         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6374         LDKInit init_conv;
6375         init_conv.inner = (void*)(init & (~1));
6376         init_conv.is_owned = false;
6377         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
6378 }
6379
6380 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) {
6381         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6382         LDKPublicKey their_node_id_ref;
6383         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6384         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6385         LDKReplyChannelRange msg_conv;
6386         msg_conv.inner = (void*)(msg & (~1));
6387         msg_conv.is_owned = (msg & 1) || (msg == 0);
6388         msg_conv = ReplyChannelRange_clone(&msg_conv);
6389         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6390         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6391         return (long)ret_conv;
6392 }
6393
6394 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) {
6395         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6396         LDKPublicKey their_node_id_ref;
6397         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6398         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6399         LDKReplyShortChannelIdsEnd msg_conv;
6400         msg_conv.inner = (void*)(msg & (~1));
6401         msg_conv.is_owned = (msg & 1) || (msg == 0);
6402         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
6403         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6404         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6405         return (long)ret_conv;
6406 }
6407
6408 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) {
6409         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6410         LDKPublicKey their_node_id_ref;
6411         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6412         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6413         LDKQueryChannelRange msg_conv;
6414         msg_conv.inner = (void*)(msg & (~1));
6415         msg_conv.is_owned = (msg & 1) || (msg == 0);
6416         msg_conv = QueryChannelRange_clone(&msg_conv);
6417         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6418         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6419         return (long)ret_conv;
6420 }
6421
6422 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) {
6423         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6424         LDKPublicKey their_node_id_ref;
6425         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6426         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6427         LDKQueryShortChannelIds msg_conv;
6428         msg_conv.inner = (void*)(msg & (~1));
6429         msg_conv.is_owned = (msg & 1) || (msg == 0);
6430         msg_conv = QueryShortChannelIds_clone(&msg_conv);
6431         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6432         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6433         return (long)ret_conv;
6434 }
6435
6436 typedef struct LDKSocketDescriptor_JCalls {
6437         atomic_size_t refcnt;
6438         JavaVM *vm;
6439         jweak o;
6440         jmethodID send_data_meth;
6441         jmethodID disconnect_socket_meth;
6442         jmethodID eq_meth;
6443         jmethodID hash_meth;
6444 } LDKSocketDescriptor_JCalls;
6445 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
6446         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6447         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6448                 JNIEnv *env;
6449                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6450                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6451                 FREE(j_calls);
6452         }
6453 }
6454 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
6455         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6456         JNIEnv *env;
6457         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6458         LDKu8slice data_var = data;
6459         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
6460         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
6461         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6462         CHECK(obj != NULL);
6463         return (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
6464 }
6465 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
6466         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6467         JNIEnv *env;
6468         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6469         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6470         CHECK(obj != NULL);
6471         return (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
6472 }
6473 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
6474         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6475         JNIEnv *env;
6476         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6477         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6478         *other_arg_clone = SocketDescriptor_clone(other_arg);
6479         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6480         CHECK(obj != NULL);
6481         return (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (long)other_arg_clone);
6482 }
6483 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
6484         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6485         JNIEnv *env;
6486         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6487         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6488         CHECK(obj != NULL);
6489         return (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
6490 }
6491 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
6492         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6493         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6494         return (void*) this_arg;
6495 }
6496 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
6497         jclass c = (*env)->GetObjectClass(env, o);
6498         CHECK(c != NULL);
6499         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
6500         atomic_init(&calls->refcnt, 1);
6501         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6502         calls->o = (*env)->NewWeakGlobalRef(env, o);
6503         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
6504         CHECK(calls->send_data_meth != NULL);
6505         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
6506         CHECK(calls->disconnect_socket_meth != NULL);
6507         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
6508         CHECK(calls->eq_meth != NULL);
6509         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
6510         CHECK(calls->hash_meth != NULL);
6511
6512         LDKSocketDescriptor ret = {
6513                 .this_arg = (void*) calls,
6514                 .send_data = send_data_LDKSocketDescriptor_jcall,
6515                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
6516                 .eq = eq_LDKSocketDescriptor_jcall,
6517                 .hash = hash_LDKSocketDescriptor_jcall,
6518                 .clone = LDKSocketDescriptor_JCalls_clone,
6519                 .free = LDKSocketDescriptor_JCalls_free,
6520         };
6521         return ret;
6522 }
6523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
6524         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6525         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
6526         return (long)res_ptr;
6527 }
6528 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) {
6529         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6530         LDKu8slice data_ref;
6531         data_ref.datalen = (*env)->GetArrayLength(env, data);
6532         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
6533         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
6534         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
6535         return ret_val;
6536 }
6537
6538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
6539         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6540         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
6541 }
6542
6543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
6544         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6545         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
6546         return ret_val;
6547 }
6548
6549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
6550         LDKTransaction _res_ref;
6551         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
6552         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
6553         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
6554         _res_ref.data_is_owned = true;
6555         Transaction_free(_res_ref);
6556 }
6557
6558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
6559         if ((_res & 1) != 0) return;
6560         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
6561         FREE((void*)_res);
6562         TxOut_free(_res_conv);
6563 }
6564
6565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6566         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
6567         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6568         *ret_ref = TxOut_clone(orig_conv);
6569         return (long)ret_ref;
6570 }
6571
6572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
6573         LDKSecretKey o_ref;
6574         CHECK((*env)->GetArrayLength(env, o) == 32);
6575         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
6576         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6577         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
6578         return (long)ret_conv;
6579 }
6580
6581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6582         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6583         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6584         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
6585         return (long)ret_conv;
6586 }
6587
6588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6589         if ((_res & 1) != 0) return;
6590         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
6591         FREE((void*)_res);
6592         CResult_SecretKeyErrorZ_free(_res_conv);
6593 }
6594
6595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
6596         LDKPublicKey o_ref;
6597         CHECK((*env)->GetArrayLength(env, o) == 33);
6598         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
6599         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6600         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
6601         return (long)ret_conv;
6602 }
6603
6604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6605         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6606         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6607         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
6608         return (long)ret_conv;
6609 }
6610
6611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6612         if ((_res & 1) != 0) return;
6613         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
6614         FREE((void*)_res);
6615         CResult_PublicKeyErrorZ_free(_res_conv);
6616 }
6617
6618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6619         LDKTxCreationKeys o_conv;
6620         o_conv.inner = (void*)(o & (~1));
6621         o_conv.is_owned = (o & 1) || (o == 0);
6622         o_conv = TxCreationKeys_clone(&o_conv);
6623         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6624         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
6625         return (long)ret_conv;
6626 }
6627
6628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6629         LDKDecodeError e_conv;
6630         e_conv.inner = (void*)(e & (~1));
6631         e_conv.is_owned = (e & 1) || (e == 0);
6632         e_conv = DecodeError_clone(&e_conv);
6633         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6634         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
6635         return (long)ret_conv;
6636 }
6637
6638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6639         if ((_res & 1) != 0) return;
6640         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6641         FREE((void*)_res);
6642         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
6643 }
6644
6645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6646         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
6647         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6648         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
6649         return (long)ret_conv;
6650 }
6651
6652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6653         LDKChannelPublicKeys o_conv;
6654         o_conv.inner = (void*)(o & (~1));
6655         o_conv.is_owned = (o & 1) || (o == 0);
6656         o_conv = ChannelPublicKeys_clone(&o_conv);
6657         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6658         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
6659         return (long)ret_conv;
6660 }
6661
6662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6663         LDKDecodeError e_conv;
6664         e_conv.inner = (void*)(e & (~1));
6665         e_conv.is_owned = (e & 1) || (e == 0);
6666         e_conv = DecodeError_clone(&e_conv);
6667         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6668         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
6669         return (long)ret_conv;
6670 }
6671
6672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6673         if ((_res & 1) != 0) return;
6674         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6675         FREE((void*)_res);
6676         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
6677 }
6678
6679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6680         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
6681         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6682         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
6683         return (long)ret_conv;
6684 }
6685
6686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6687         LDKTxCreationKeys o_conv;
6688         o_conv.inner = (void*)(o & (~1));
6689         o_conv.is_owned = (o & 1) || (o == 0);
6690         o_conv = TxCreationKeys_clone(&o_conv);
6691         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6692         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
6693         return (long)ret_conv;
6694 }
6695
6696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6697         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6698         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6699         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
6700         return (long)ret_conv;
6701 }
6702
6703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6704         if ((_res & 1) != 0) return;
6705         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
6706         FREE((void*)_res);
6707         CResult_TxCreationKeysErrorZ_free(_res_conv);
6708 }
6709
6710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
6711         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6712         *ret_copy = COption_u32Z_some(o);
6713         long ret_ref = (long)ret_copy;
6714         return ret_ref;
6715 }
6716
6717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
6718         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6719         *ret_copy = COption_u32Z_none();
6720         long ret_ref = (long)ret_copy;
6721         return ret_ref;
6722 }
6723
6724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
6725         if ((_res & 1) != 0) return;
6726         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
6727         FREE((void*)_res);
6728         COption_u32Z_free(_res_conv);
6729 }
6730
6731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6732         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
6733         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6734         *ret_copy = COption_u32Z_clone(orig_conv);
6735         long ret_ref = (long)ret_copy;
6736         return ret_ref;
6737 }
6738
6739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6740         LDKHTLCOutputInCommitment o_conv;
6741         o_conv.inner = (void*)(o & (~1));
6742         o_conv.is_owned = (o & 1) || (o == 0);
6743         o_conv = HTLCOutputInCommitment_clone(&o_conv);
6744         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6745         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
6746         return (long)ret_conv;
6747 }
6748
6749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6750         LDKDecodeError e_conv;
6751         e_conv.inner = (void*)(e & (~1));
6752         e_conv.is_owned = (e & 1) || (e == 0);
6753         e_conv = DecodeError_clone(&e_conv);
6754         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6755         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
6756         return (long)ret_conv;
6757 }
6758
6759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6760         if ((_res & 1) != 0) return;
6761         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
6762         FREE((void*)_res);
6763         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
6764 }
6765
6766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6767         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
6768         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6769         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
6770         return (long)ret_conv;
6771 }
6772
6773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6774         LDKCounterpartyChannelTransactionParameters o_conv;
6775         o_conv.inner = (void*)(o & (~1));
6776         o_conv.is_owned = (o & 1) || (o == 0);
6777         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
6778         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6779         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6780         return (long)ret_conv;
6781 }
6782
6783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6784         LDKDecodeError e_conv;
6785         e_conv.inner = (void*)(e & (~1));
6786         e_conv.is_owned = (e & 1) || (e == 0);
6787         e_conv = DecodeError_clone(&e_conv);
6788         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6789         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
6790         return (long)ret_conv;
6791 }
6792
6793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6794         if ((_res & 1) != 0) return;
6795         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6796         FREE((void*)_res);
6797         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6798 }
6799
6800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6801         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6802         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6803         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6804         return (long)ret_conv;
6805 }
6806
6807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6808         LDKChannelTransactionParameters o_conv;
6809         o_conv.inner = (void*)(o & (~1));
6810         o_conv.is_owned = (o & 1) || (o == 0);
6811         o_conv = ChannelTransactionParameters_clone(&o_conv);
6812         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6813         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6814         return (long)ret_conv;
6815 }
6816
6817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6818         LDKDecodeError e_conv;
6819         e_conv.inner = (void*)(e & (~1));
6820         e_conv.is_owned = (e & 1) || (e == 0);
6821         e_conv = DecodeError_clone(&e_conv);
6822         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6823         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
6824         return (long)ret_conv;
6825 }
6826
6827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6828         if ((_res & 1) != 0) return;
6829         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6830         FREE((void*)_res);
6831         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6832 }
6833
6834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6835         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6836         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6837         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6838         return (long)ret_conv;
6839 }
6840
6841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
6842         LDKCVec_SignatureZ _res_constr;
6843         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
6844         if (_res_constr.datalen > 0)
6845                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6846         else
6847                 _res_constr.data = NULL;
6848         for (size_t i = 0; i < _res_constr.datalen; i++) {
6849                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
6850                 LDKSignature _res_conv_8_ref;
6851                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
6852                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
6853                 _res_constr.data[i] = _res_conv_8_ref;
6854         }
6855         CVec_SignatureZ_free(_res_constr);
6856 }
6857
6858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6859         LDKHolderCommitmentTransaction o_conv;
6860         o_conv.inner = (void*)(o & (~1));
6861         o_conv.is_owned = (o & 1) || (o == 0);
6862         o_conv = HolderCommitmentTransaction_clone(&o_conv);
6863         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6864         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
6865         return (long)ret_conv;
6866 }
6867
6868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6869         LDKDecodeError e_conv;
6870         e_conv.inner = (void*)(e & (~1));
6871         e_conv.is_owned = (e & 1) || (e == 0);
6872         e_conv = DecodeError_clone(&e_conv);
6873         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6874         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
6875         return (long)ret_conv;
6876 }
6877
6878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6879         if ((_res & 1) != 0) return;
6880         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6881         FREE((void*)_res);
6882         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
6883 }
6884
6885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6886         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6887         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6888         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6889         return (long)ret_conv;
6890 }
6891
6892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6893         LDKBuiltCommitmentTransaction o_conv;
6894         o_conv.inner = (void*)(o & (~1));
6895         o_conv.is_owned = (o & 1) || (o == 0);
6896         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
6897         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6898         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
6899         return (long)ret_conv;
6900 }
6901
6902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6903         LDKDecodeError e_conv;
6904         e_conv.inner = (void*)(e & (~1));
6905         e_conv.is_owned = (e & 1) || (e == 0);
6906         e_conv = DecodeError_clone(&e_conv);
6907         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6908         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
6909         return (long)ret_conv;
6910 }
6911
6912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6913         if ((_res & 1) != 0) return;
6914         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6915         FREE((void*)_res);
6916         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
6917 }
6918
6919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6920         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6921         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6922         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6923         return (long)ret_conv;
6924 }
6925
6926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6927         LDKCommitmentTransaction o_conv;
6928         o_conv.inner = (void*)(o & (~1));
6929         o_conv.is_owned = (o & 1) || (o == 0);
6930         o_conv = CommitmentTransaction_clone(&o_conv);
6931         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6932         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
6933         return (long)ret_conv;
6934 }
6935
6936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6937         LDKDecodeError e_conv;
6938         e_conv.inner = (void*)(e & (~1));
6939         e_conv.is_owned = (e & 1) || (e == 0);
6940         e_conv = DecodeError_clone(&e_conv);
6941         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6942         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
6943         return (long)ret_conv;
6944 }
6945
6946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6947         if ((_res & 1) != 0) return;
6948         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6949         FREE((void*)_res);
6950         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
6951 }
6952
6953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6954         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
6955         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6956         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
6957         return (long)ret_conv;
6958 }
6959
6960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6961         LDKTrustedCommitmentTransaction o_conv;
6962         o_conv.inner = (void*)(o & (~1));
6963         o_conv.is_owned = (o & 1) || (o == 0);
6964         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
6965         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6966         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
6967         return (long)ret_conv;
6968 }
6969
6970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
6971         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6972         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
6973         return (long)ret_conv;
6974 }
6975
6976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6977         if ((_res & 1) != 0) return;
6978         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
6979         FREE((void*)_res);
6980         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
6981 }
6982
6983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
6984         LDKCVec_SignatureZ o_constr;
6985         o_constr.datalen = (*env)->GetArrayLength(env, o);
6986         if (o_constr.datalen > 0)
6987                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6988         else
6989                 o_constr.data = NULL;
6990         for (size_t i = 0; i < o_constr.datalen; i++) {
6991                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
6992                 LDKSignature o_conv_8_ref;
6993                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
6994                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
6995                 o_constr.data[i] = o_conv_8_ref;
6996         }
6997         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6998         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
6999         return (long)ret_conv;
7000 }
7001
7002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
7003         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7004         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
7005         return (long)ret_conv;
7006 }
7007
7008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7009         if ((_res & 1) != 0) return;
7010         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
7011         FREE((void*)_res);
7012         CResult_CVec_SignatureZNoneZ_free(_res_conv);
7013 }
7014
7015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7016         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
7017         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7018         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
7019         return (long)ret_conv;
7020 }
7021
7022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7023         LDKCVec_MessageSendEventZ _res_constr;
7024         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7025         if (_res_constr.datalen > 0)
7026                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7027         else
7028                 _res_constr.data = NULL;
7029         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7030         for (size_t s = 0; s < _res_constr.datalen; s++) {
7031                 int64_t _res_conv_18 = _res_vals[s];
7032                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
7033                 FREE((void*)_res_conv_18);
7034                 _res_constr.data[s] = _res_conv_18_conv;
7035         }
7036         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7037         CVec_MessageSendEventZ_free(_res_constr);
7038 }
7039
7040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
7041         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7042         *ret_conv = CResult_boolLightningErrorZ_ok(o);
7043         return (long)ret_conv;
7044 }
7045
7046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7047         LDKLightningError e_conv;
7048         e_conv.inner = (void*)(e & (~1));
7049         e_conv.is_owned = (e & 1) || (e == 0);
7050         e_conv = LightningError_clone(&e_conv);
7051         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7052         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
7053         return (long)ret_conv;
7054 }
7055
7056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7057         if ((_res & 1) != 0) return;
7058         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
7059         FREE((void*)_res);
7060         CResult_boolLightningErrorZ_free(_res_conv);
7061 }
7062
7063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7064         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
7065         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7066         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
7067         return (long)ret_conv;
7068 }
7069
7070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7071         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
7072         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
7073         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
7074         return (long)ret_ref;
7075 }
7076
7077 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) {
7078         LDKChannelAnnouncement a_conv;
7079         a_conv.inner = (void*)(a & (~1));
7080         a_conv.is_owned = (a & 1) || (a == 0);
7081         a_conv = ChannelAnnouncement_clone(&a_conv);
7082         LDKChannelUpdate b_conv;
7083         b_conv.inner = (void*)(b & (~1));
7084         b_conv.is_owned = (b & 1) || (b == 0);
7085         b_conv = ChannelUpdate_clone(&b_conv);
7086         LDKChannelUpdate c_conv;
7087         c_conv.inner = (void*)(c & (~1));
7088         c_conv.is_owned = (c & 1) || (c == 0);
7089         c_conv = ChannelUpdate_clone(&c_conv);
7090         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
7091         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
7092         return (long)ret_ref;
7093 }
7094
7095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7096         if ((_res & 1) != 0) return;
7097         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
7098         FREE((void*)_res);
7099         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
7100 }
7101
7102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7103         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
7104         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7105         if (_res_constr.datalen > 0)
7106                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
7107         else
7108                 _res_constr.data = NULL;
7109         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7110         for (size_t l = 0; l < _res_constr.datalen; l++) {
7111                 int64_t _res_conv_63 = _res_vals[l];
7112                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
7113                 FREE((void*)_res_conv_63);
7114                 _res_constr.data[l] = _res_conv_63_conv;
7115         }
7116         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7117         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
7118 }
7119
7120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7121         LDKCVec_NodeAnnouncementZ _res_constr;
7122         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7123         if (_res_constr.datalen > 0)
7124                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
7125         else
7126                 _res_constr.data = NULL;
7127         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7128         for (size_t s = 0; s < _res_constr.datalen; s++) {
7129                 int64_t _res_conv_18 = _res_vals[s];
7130                 LDKNodeAnnouncement _res_conv_18_conv;
7131                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
7132                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
7133                 _res_constr.data[s] = _res_conv_18_conv;
7134         }
7135         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7136         CVec_NodeAnnouncementZ_free(_res_constr);
7137 }
7138
7139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
7140         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7141         *ret_conv = CResult_NoneLightningErrorZ_ok();
7142         return (long)ret_conv;
7143 }
7144
7145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7146         LDKLightningError e_conv;
7147         e_conv.inner = (void*)(e & (~1));
7148         e_conv.is_owned = (e & 1) || (e == 0);
7149         e_conv = LightningError_clone(&e_conv);
7150         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7151         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
7152         return (long)ret_conv;
7153 }
7154
7155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7156         if ((_res & 1) != 0) return;
7157         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
7158         FREE((void*)_res);
7159         CResult_NoneLightningErrorZ_free(_res_conv);
7160 }
7161
7162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7163         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
7164         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7165         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
7166         return (long)ret_conv;
7167 }
7168
7169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
7170         LDKCVec_PublicKeyZ _res_constr;
7171         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7172         if (_res_constr.datalen > 0)
7173                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
7174         else
7175                 _res_constr.data = NULL;
7176         for (size_t i = 0; i < _res_constr.datalen; i++) {
7177                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
7178                 LDKPublicKey _res_conv_8_ref;
7179                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
7180                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
7181                 _res_constr.data[i] = _res_conv_8_ref;
7182         }
7183         CVec_PublicKeyZ_free(_res_constr);
7184 }
7185
7186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
7187         LDKCVec_u8Z _res_ref;
7188         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
7189         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
7190         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
7191         CVec_u8Z_free(_res_ref);
7192 }
7193
7194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
7195         LDKCVec_u8Z o_ref;
7196         o_ref.datalen = (*env)->GetArrayLength(env, o);
7197         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
7198         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
7199         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
7200         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
7201         return (long)ret_conv;
7202 }
7203
7204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7205         LDKPeerHandleError e_conv;
7206         e_conv.inner = (void*)(e & (~1));
7207         e_conv.is_owned = (e & 1) || (e == 0);
7208         e_conv = PeerHandleError_clone(&e_conv);
7209         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
7210         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
7211         return (long)ret_conv;
7212 }
7213
7214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7215         if ((_res & 1) != 0) return;
7216         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
7217         FREE((void*)_res);
7218         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
7219 }
7220
7221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7222         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
7223         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
7224         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
7225         return (long)ret_conv;
7226 }
7227
7228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
7229         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
7230         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
7231         return (long)ret_conv;
7232 }
7233
7234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7235         LDKPeerHandleError e_conv;
7236         e_conv.inner = (void*)(e & (~1));
7237         e_conv.is_owned = (e & 1) || (e == 0);
7238         e_conv = PeerHandleError_clone(&e_conv);
7239         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
7240         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
7241         return (long)ret_conv;
7242 }
7243
7244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7245         if ((_res & 1) != 0) return;
7246         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
7247         FREE((void*)_res);
7248         CResult_NonePeerHandleErrorZ_free(_res_conv);
7249 }
7250
7251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7252         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
7253         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
7254         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
7255         return (long)ret_conv;
7256 }
7257
7258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
7259         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
7260         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
7261         return (long)ret_conv;
7262 }
7263
7264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7265         LDKPeerHandleError e_conv;
7266         e_conv.inner = (void*)(e & (~1));
7267         e_conv.is_owned = (e & 1) || (e == 0);
7268         e_conv = PeerHandleError_clone(&e_conv);
7269         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
7270         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
7271         return (long)ret_conv;
7272 }
7273
7274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7275         if ((_res & 1) != 0) return;
7276         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
7277         FREE((void*)_res);
7278         CResult_boolPeerHandleErrorZ_free(_res_conv);
7279 }
7280
7281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7282         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
7283         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
7284         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
7285         return (long)ret_conv;
7286 }
7287
7288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7289         LDKInitFeatures o_conv;
7290         o_conv.inner = (void*)(o & (~1));
7291         o_conv.is_owned = (o & 1) || (o == 0);
7292         o_conv = InitFeatures_clone(&o_conv);
7293         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7294         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
7295         return (long)ret_conv;
7296 }
7297
7298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7299         LDKDecodeError e_conv;
7300         e_conv.inner = (void*)(e & (~1));
7301         e_conv.is_owned = (e & 1) || (e == 0);
7302         e_conv = DecodeError_clone(&e_conv);
7303         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7304         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
7305         return (long)ret_conv;
7306 }
7307
7308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7309         if ((_res & 1) != 0) return;
7310         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7311         FREE((void*)_res);
7312         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
7313 }
7314
7315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7316         LDKNodeFeatures o_conv;
7317         o_conv.inner = (void*)(o & (~1));
7318         o_conv.is_owned = (o & 1) || (o == 0);
7319         o_conv = NodeFeatures_clone(&o_conv);
7320         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7321         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
7322         return (long)ret_conv;
7323 }
7324
7325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7326         LDKDecodeError e_conv;
7327         e_conv.inner = (void*)(e & (~1));
7328         e_conv.is_owned = (e & 1) || (e == 0);
7329         e_conv = DecodeError_clone(&e_conv);
7330         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7331         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
7332         return (long)ret_conv;
7333 }
7334
7335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7336         if ((_res & 1) != 0) return;
7337         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7338         FREE((void*)_res);
7339         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
7340 }
7341
7342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7343         LDKChannelFeatures o_conv;
7344         o_conv.inner = (void*)(o & (~1));
7345         o_conv.is_owned = (o & 1) || (o == 0);
7346         o_conv = ChannelFeatures_clone(&o_conv);
7347         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7348         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
7349         return (long)ret_conv;
7350 }
7351
7352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7353         LDKDecodeError e_conv;
7354         e_conv.inner = (void*)(e & (~1));
7355         e_conv.is_owned = (e & 1) || (e == 0);
7356         e_conv = DecodeError_clone(&e_conv);
7357         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7358         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
7359         return (long)ret_conv;
7360 }
7361
7362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7363         if ((_res & 1) != 0) return;
7364         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7365         FREE((void*)_res);
7366         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
7367 }
7368
7369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7370         LDKInvoiceFeatures o_conv;
7371         o_conv.inner = (void*)(o & (~1));
7372         o_conv.is_owned = (o & 1) || (o == 0);
7373         o_conv = InvoiceFeatures_clone(&o_conv);
7374         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
7375         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
7376         return (long)ret_conv;
7377 }
7378
7379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7380         LDKDecodeError e_conv;
7381         e_conv.inner = (void*)(e & (~1));
7382         e_conv.is_owned = (e & 1) || (e == 0);
7383         e_conv = DecodeError_clone(&e_conv);
7384         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
7385         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
7386         return (long)ret_conv;
7387 }
7388
7389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7390         if ((_res & 1) != 0) return;
7391         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7392         FREE((void*)_res);
7393         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
7394 }
7395
7396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7397         LDKChannelConfig o_conv;
7398         o_conv.inner = (void*)(o & (~1));
7399         o_conv.is_owned = (o & 1) || (o == 0);
7400         o_conv = ChannelConfig_clone(&o_conv);
7401         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
7402         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
7403         return (long)ret_conv;
7404 }
7405
7406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7407         LDKDecodeError e_conv;
7408         e_conv.inner = (void*)(e & (~1));
7409         e_conv.is_owned = (e & 1) || (e == 0);
7410         e_conv = DecodeError_clone(&e_conv);
7411         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
7412         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
7413         return (long)ret_conv;
7414 }
7415
7416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7417         if ((_res & 1) != 0) return;
7418         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
7419         FREE((void*)_res);
7420         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
7421 }
7422
7423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7424         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
7425         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
7426         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
7427         return (long)ret_conv;
7428 }
7429
7430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
7431         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7432         *ret_copy = COption_u64Z_some(o);
7433         long ret_ref = (long)ret_copy;
7434         return ret_ref;
7435 }
7436
7437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
7438         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7439         *ret_copy = COption_u64Z_none();
7440         long ret_ref = (long)ret_copy;
7441         return ret_ref;
7442 }
7443
7444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
7445         if ((_res & 1) != 0) return;
7446         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
7447         FREE((void*)_res);
7448         COption_u64Z_free(_res_conv);
7449 }
7450
7451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7452         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
7453         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7454         *ret_copy = COption_u64Z_clone(orig_conv);
7455         long ret_ref = (long)ret_copy;
7456         return ret_ref;
7457 }
7458
7459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7460         LDKDirectionalChannelInfo o_conv;
7461         o_conv.inner = (void*)(o & (~1));
7462         o_conv.is_owned = (o & 1) || (o == 0);
7463         o_conv = DirectionalChannelInfo_clone(&o_conv);
7464         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
7465         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
7466         return (long)ret_conv;
7467 }
7468
7469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7470         LDKDecodeError e_conv;
7471         e_conv.inner = (void*)(e & (~1));
7472         e_conv.is_owned = (e & 1) || (e == 0);
7473         e_conv = DecodeError_clone(&e_conv);
7474         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
7475         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
7476         return (long)ret_conv;
7477 }
7478
7479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7480         if ((_res & 1) != 0) return;
7481         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7482         FREE((void*)_res);
7483         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
7484 }
7485
7486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7487         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
7488         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
7489         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
7490         return (long)ret_conv;
7491 }
7492
7493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7494         LDKChannelInfo o_conv;
7495         o_conv.inner = (void*)(o & (~1));
7496         o_conv.is_owned = (o & 1) || (o == 0);
7497         o_conv = ChannelInfo_clone(&o_conv);
7498         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
7499         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
7500         return (long)ret_conv;
7501 }
7502
7503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7504         LDKDecodeError e_conv;
7505         e_conv.inner = (void*)(e & (~1));
7506         e_conv.is_owned = (e & 1) || (e == 0);
7507         e_conv = DecodeError_clone(&e_conv);
7508         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
7509         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
7510         return (long)ret_conv;
7511 }
7512
7513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7514         if ((_res & 1) != 0) return;
7515         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7516         FREE((void*)_res);
7517         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
7518 }
7519
7520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7521         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
7522         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
7523         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
7524         return (long)ret_conv;
7525 }
7526
7527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7528         LDKRoutingFees o_conv;
7529         o_conv.inner = (void*)(o & (~1));
7530         o_conv.is_owned = (o & 1) || (o == 0);
7531         o_conv = RoutingFees_clone(&o_conv);
7532         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
7533         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
7534         return (long)ret_conv;
7535 }
7536
7537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7538         LDKDecodeError e_conv;
7539         e_conv.inner = (void*)(e & (~1));
7540         e_conv.is_owned = (e & 1) || (e == 0);
7541         e_conv = DecodeError_clone(&e_conv);
7542         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
7543         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
7544         return (long)ret_conv;
7545 }
7546
7547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7548         if ((_res & 1) != 0) return;
7549         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7550         FREE((void*)_res);
7551         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
7552 }
7553
7554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7555         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
7556         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
7557         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
7558         return (long)ret_conv;
7559 }
7560
7561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7562         LDKCVec_NetAddressZ _res_constr;
7563         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7564         if (_res_constr.datalen > 0)
7565                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
7566         else
7567                 _res_constr.data = NULL;
7568         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7569         for (size_t m = 0; m < _res_constr.datalen; m++) {
7570                 int64_t _res_conv_12 = _res_vals[m];
7571                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
7572                 FREE((void*)_res_conv_12);
7573                 _res_constr.data[m] = _res_conv_12_conv;
7574         }
7575         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7576         CVec_NetAddressZ_free(_res_constr);
7577 }
7578
7579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7580         LDKNodeAnnouncementInfo o_conv;
7581         o_conv.inner = (void*)(o & (~1));
7582         o_conv.is_owned = (o & 1) || (o == 0);
7583         o_conv = NodeAnnouncementInfo_clone(&o_conv);
7584         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
7585         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
7586         return (long)ret_conv;
7587 }
7588
7589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7590         LDKDecodeError e_conv;
7591         e_conv.inner = (void*)(e & (~1));
7592         e_conv.is_owned = (e & 1) || (e == 0);
7593         e_conv = DecodeError_clone(&e_conv);
7594         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
7595         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
7596         return (long)ret_conv;
7597 }
7598
7599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7600         if ((_res & 1) != 0) return;
7601         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7602         FREE((void*)_res);
7603         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
7604 }
7605
7606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7607         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
7608         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
7609         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
7610         return (long)ret_conv;
7611 }
7612
7613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7614         LDKCVec_u64Z _res_constr;
7615         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7616         if (_res_constr.datalen > 0)
7617                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
7618         else
7619                 _res_constr.data = NULL;
7620         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7621         for (size_t g = 0; g < _res_constr.datalen; g++) {
7622                 int64_t _res_conv_6 = _res_vals[g];
7623                 _res_constr.data[g] = _res_conv_6;
7624         }
7625         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7626         CVec_u64Z_free(_res_constr);
7627 }
7628
7629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7630         LDKNodeInfo o_conv;
7631         o_conv.inner = (void*)(o & (~1));
7632         o_conv.is_owned = (o & 1) || (o == 0);
7633         o_conv = NodeInfo_clone(&o_conv);
7634         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
7635         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
7636         return (long)ret_conv;
7637 }
7638
7639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7640         LDKDecodeError e_conv;
7641         e_conv.inner = (void*)(e & (~1));
7642         e_conv.is_owned = (e & 1) || (e == 0);
7643         e_conv = DecodeError_clone(&e_conv);
7644         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
7645         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
7646         return (long)ret_conv;
7647 }
7648
7649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7650         if ((_res & 1) != 0) return;
7651         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7652         FREE((void*)_res);
7653         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
7654 }
7655
7656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7657         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
7658         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
7659         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
7660         return (long)ret_conv;
7661 }
7662
7663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7664         LDKNetworkGraph o_conv;
7665         o_conv.inner = (void*)(o & (~1));
7666         o_conv.is_owned = (o & 1) || (o == 0);
7667         o_conv = NetworkGraph_clone(&o_conv);
7668         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
7669         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
7670         return (long)ret_conv;
7671 }
7672
7673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7674         LDKDecodeError e_conv;
7675         e_conv.inner = (void*)(e & (~1));
7676         e_conv.is_owned = (e & 1) || (e == 0);
7677         e_conv = DecodeError_clone(&e_conv);
7678         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
7679         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
7680         return (long)ret_conv;
7681 }
7682
7683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7684         if ((_res & 1) != 0) return;
7685         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
7686         FREE((void*)_res);
7687         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
7688 }
7689
7690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7691         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
7692         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
7693         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
7694         return (long)ret_conv;
7695 }
7696
7697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
7698         LDKTransaction b_ref;
7699         b_ref.datalen = (*env)->GetArrayLength(env, b);
7700         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
7701         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7702         b_ref.data_is_owned = true;
7703         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7704         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
7705         return (long)ret_ref;
7706 }
7707
7708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7709         if ((_res & 1) != 0) return;
7710         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
7711         FREE((void*)_res);
7712         C2Tuple_usizeTransactionZ_free(_res_conv);
7713 }
7714
7715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7716         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
7717         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7718         if (_res_constr.datalen > 0)
7719                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7720         else
7721                 _res_constr.data = NULL;
7722         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7723         for (size_t y = 0; y < _res_constr.datalen; y++) {
7724                 int64_t _res_conv_24 = _res_vals[y];
7725                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
7726                 FREE((void*)_res_conv_24);
7727                 _res_constr.data[y] = _res_conv_24_conv;
7728         }
7729         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7730         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
7731 }
7732
7733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
7734         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7735         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
7736         return (long)ret_conv;
7737 }
7738
7739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
7740         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
7741         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7742         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
7743         return (long)ret_conv;
7744 }
7745
7746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7747         if ((_res & 1) != 0) return;
7748         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
7749         FREE((void*)_res);
7750         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
7751 }
7752
7753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7754         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
7755         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7756         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
7757         return (long)ret_conv;
7758 }
7759
7760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7761         LDKCVec_MonitorEventZ _res_constr;
7762         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7763         if (_res_constr.datalen > 0)
7764                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
7765         else
7766                 _res_constr.data = NULL;
7767         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7768         for (size_t o = 0; o < _res_constr.datalen; o++) {
7769                 int64_t _res_conv_14 = _res_vals[o];
7770                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
7771                 FREE((void*)_res_conv_14);
7772                 _res_constr.data[o] = _res_conv_14_conv;
7773         }
7774         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7775         CVec_MonitorEventZ_free(_res_constr);
7776 }
7777
7778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7779         LDKCVec_EventZ _res_constr;
7780         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7781         if (_res_constr.datalen > 0)
7782                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
7783         else
7784                 _res_constr.data = NULL;
7785         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7786         for (size_t h = 0; h < _res_constr.datalen; h++) {
7787                 int64_t _res_conv_7 = _res_vals[h];
7788                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
7789                 FREE((void*)_res_conv_7);
7790                 _res_constr.data[h] = _res_conv_7_conv;
7791         }
7792         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7793         CVec_EventZ_free(_res_constr);
7794 }
7795
7796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7797         LDKOutPoint o_conv;
7798         o_conv.inner = (void*)(o & (~1));
7799         o_conv.is_owned = (o & 1) || (o == 0);
7800         o_conv = OutPoint_clone(&o_conv);
7801         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
7802         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
7803         return (long)ret_conv;
7804 }
7805
7806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7807         LDKDecodeError e_conv;
7808         e_conv.inner = (void*)(e & (~1));
7809         e_conv.is_owned = (e & 1) || (e == 0);
7810         e_conv = DecodeError_clone(&e_conv);
7811         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
7812         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
7813         return (long)ret_conv;
7814 }
7815
7816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7817         if ((_res & 1) != 0) return;
7818         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
7819         FREE((void*)_res);
7820         CResult_OutPointDecodeErrorZ_free(_res_conv);
7821 }
7822
7823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7824         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
7825         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
7826         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
7827         return (long)ret_conv;
7828 }
7829
7830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7831         LDKChannelMonitorUpdate o_conv;
7832         o_conv.inner = (void*)(o & (~1));
7833         o_conv.is_owned = (o & 1) || (o == 0);
7834         o_conv = ChannelMonitorUpdate_clone(&o_conv);
7835         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7836         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
7837         return (long)ret_conv;
7838 }
7839
7840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7841         LDKDecodeError e_conv;
7842         e_conv.inner = (void*)(e & (~1));
7843         e_conv.is_owned = (e & 1) || (e == 0);
7844         e_conv = DecodeError_clone(&e_conv);
7845         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7846         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
7847         return (long)ret_conv;
7848 }
7849
7850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7851         if ((_res & 1) != 0) return;
7852         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
7853         FREE((void*)_res);
7854         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
7855 }
7856
7857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7858         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
7859         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7860         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
7861         return (long)ret_conv;
7862 }
7863
7864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7865         LDKHTLCUpdate o_conv;
7866         o_conv.inner = (void*)(o & (~1));
7867         o_conv.is_owned = (o & 1) || (o == 0);
7868         o_conv = HTLCUpdate_clone(&o_conv);
7869         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7870         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
7871         return (long)ret_conv;
7872 }
7873
7874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7875         LDKDecodeError e_conv;
7876         e_conv.inner = (void*)(e & (~1));
7877         e_conv.is_owned = (e & 1) || (e == 0);
7878         e_conv = DecodeError_clone(&e_conv);
7879         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7880         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
7881         return (long)ret_conv;
7882 }
7883
7884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7885         if ((_res & 1) != 0) return;
7886         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
7887         FREE((void*)_res);
7888         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
7889 }
7890
7891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7892         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
7893         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7894         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
7895         return (long)ret_conv;
7896 }
7897
7898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
7899         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7900         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
7901         return (long)ret_conv;
7902 }
7903
7904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7905         LDKMonitorUpdateError e_conv;
7906         e_conv.inner = (void*)(e & (~1));
7907         e_conv.is_owned = (e & 1) || (e == 0);
7908         e_conv = MonitorUpdateError_clone(&e_conv);
7909         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7910         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
7911         return (long)ret_conv;
7912 }
7913
7914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7915         if ((_res & 1) != 0) return;
7916         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
7917         FREE((void*)_res);
7918         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
7919 }
7920
7921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7922         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
7923         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7924         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
7925         return (long)ret_conv;
7926 }
7927
7928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7929         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
7930         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
7931         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
7932         return (long)ret_ref;
7933 }
7934
7935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
7936         LDKOutPoint a_conv;
7937         a_conv.inner = (void*)(a & (~1));
7938         a_conv.is_owned = (a & 1) || (a == 0);
7939         a_conv = OutPoint_clone(&a_conv);
7940         LDKCVec_u8Z b_ref;
7941         b_ref.datalen = (*env)->GetArrayLength(env, b);
7942         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
7943         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7944         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
7945         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
7946         return (long)ret_ref;
7947 }
7948
7949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7950         if ((_res & 1) != 0) return;
7951         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
7952         FREE((void*)_res);
7953         C2Tuple_OutPointScriptZ_free(_res_conv);
7954 }
7955
7956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7957         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
7958         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
7959         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
7960         return (long)ret_ref;
7961 }
7962
7963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
7964         LDKCVec_u8Z b_ref;
7965         b_ref.datalen = (*env)->GetArrayLength(env, b);
7966         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
7967         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7968         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
7969         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
7970         return (long)ret_ref;
7971 }
7972
7973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7974         if ((_res & 1) != 0) return;
7975         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
7976         FREE((void*)_res);
7977         C2Tuple_u32ScriptZ_free(_res_conv);
7978 }
7979
7980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7981         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
7982         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7983         if (_res_constr.datalen > 0)
7984                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
7985         else
7986                 _res_constr.data = NULL;
7987         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7988         for (size_t b = 0; b < _res_constr.datalen; b++) {
7989                 int64_t _res_conv_27 = _res_vals[b];
7990                 LDKC2Tuple_u32ScriptZ _res_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_27) & ~1);
7991                 FREE((void*)_res_conv_27);
7992                 _res_constr.data[b] = _res_conv_27_conv;
7993         }
7994         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7995         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
7996 }
7997
7998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
7999         LDKThirtyTwoBytes a_ref;
8000         CHECK((*env)->GetArrayLength(env, a) == 32);
8001         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
8002         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
8003         b_constr.datalen = (*env)->GetArrayLength(env, b);
8004         if (b_constr.datalen > 0)
8005                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
8006         else
8007                 b_constr.data = NULL;
8008         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
8009         for (size_t b = 0; b < b_constr.datalen; b++) {
8010                 int64_t b_conv_27 = b_vals[b];
8011                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
8012                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
8013                 b_constr.data[b] = b_conv_27_conv;
8014         }
8015         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
8016         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
8017         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
8018         return (long)ret_ref;
8019 }
8020
8021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8022         if ((_res & 1) != 0) return;
8023         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
8024         FREE((void*)_res);
8025         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
8026 }
8027
8028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8029         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
8030         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8031         if (_res_constr.datalen > 0)
8032                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
8033         else
8034                 _res_constr.data = NULL;
8035         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8036         for (size_t v = 0; v < _res_constr.datalen; v++) {
8037                 int64_t _res_conv_47 = _res_vals[v];
8038                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_47_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_47) & ~1);
8039                 FREE((void*)_res_conv_47);
8040                 _res_constr.data[v] = _res_conv_47_conv;
8041         }
8042         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8043         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
8044 }
8045
8046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
8047         LDKCVec_TransactionZ _res_constr;
8048         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8049         if (_res_constr.datalen > 0)
8050                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
8051         else
8052                 _res_constr.data = NULL;
8053         for (size_t i = 0; i < _res_constr.datalen; i++) {
8054                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
8055                 LDKTransaction _res_conv_8_ref;
8056                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
8057                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
8058                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
8059                 _res_conv_8_ref.data_is_owned = true;
8060                 _res_constr.data[i] = _res_conv_8_ref;
8061         }
8062         CVec_TransactionZ_free(_res_constr);
8063 }
8064
8065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8066         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
8067         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8068         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
8069         return (long)ret_ref;
8070 }
8071
8072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
8073         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
8074         FREE((void*)b);
8075         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8076         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
8077         return (long)ret_ref;
8078 }
8079
8080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8081         if ((_res & 1) != 0) return;
8082         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
8083         FREE((void*)_res);
8084         C2Tuple_u32TxOutZ_free(_res_conv);
8085 }
8086
8087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8088         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
8089         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8090         if (_res_constr.datalen > 0)
8091                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
8092         else
8093                 _res_constr.data = NULL;
8094         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8095         for (size_t a = 0; a < _res_constr.datalen; a++) {
8096                 int64_t _res_conv_26 = _res_vals[a];
8097                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
8098                 FREE((void*)_res_conv_26);
8099                 _res_constr.data[a] = _res_conv_26_conv;
8100         }
8101         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8102         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
8103 }
8104
8105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
8106         LDKThirtyTwoBytes a_ref;
8107         CHECK((*env)->GetArrayLength(env, a) == 32);
8108         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
8109         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
8110         b_constr.datalen = (*env)->GetArrayLength(env, b);
8111         if (b_constr.datalen > 0)
8112                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
8113         else
8114                 b_constr.data = NULL;
8115         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
8116         for (size_t a = 0; a < b_constr.datalen; a++) {
8117                 int64_t b_conv_26 = b_vals[a];
8118                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
8119                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
8120                 b_constr.data[a] = b_conv_26_conv;
8121         }
8122         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
8123         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
8124         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
8125         return (long)ret_ref;
8126 }
8127
8128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8129         if ((_res & 1) != 0) return;
8130         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
8131         FREE((void*)_res);
8132         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
8133 }
8134
8135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8136         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
8137         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8138         if (_res_constr.datalen > 0)
8139                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
8140         else
8141                 _res_constr.data = NULL;
8142         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8143         for (size_t u = 0; u < _res_constr.datalen; u++) {
8144                 int64_t _res_conv_46 = _res_vals[u];
8145                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
8146                 FREE((void*)_res_conv_46);
8147                 _res_constr.data[u] = _res_conv_46_conv;
8148         }
8149         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8150         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
8151 }
8152
8153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
8154         LDKThirtyTwoBytes a_ref;
8155         CHECK((*env)->GetArrayLength(env, a) == 32);
8156         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
8157         LDKChannelMonitor b_conv;
8158         b_conv.inner = (void*)(b & (~1));
8159         b_conv.is_owned = (b & 1) || (b == 0);
8160         b_conv = ChannelMonitor_clone(&b_conv);
8161         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8162         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
8163         return (long)ret_ref;
8164 }
8165
8166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8167         if ((_res & 1) != 0) return;
8168         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
8169         FREE((void*)_res);
8170         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
8171 }
8172
8173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8174         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
8175         FREE((void*)o);
8176         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
8177         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
8178         return (long)ret_conv;
8179 }
8180
8181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8182         LDKDecodeError e_conv;
8183         e_conv.inner = (void*)(e & (~1));
8184         e_conv.is_owned = (e & 1) || (e == 0);
8185         e_conv = DecodeError_clone(&e_conv);
8186         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
8187         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
8188         return (long)ret_conv;
8189 }
8190
8191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8192         if ((_res & 1) != 0) return;
8193         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8194         FREE((void*)_res);
8195         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
8196 }
8197
8198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8199         LDKCVec_SpendableOutputDescriptorZ _res_constr;
8200         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8201         if (_res_constr.datalen > 0)
8202                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
8203         else
8204                 _res_constr.data = NULL;
8205         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8206         for (size_t b = 0; b < _res_constr.datalen; b++) {
8207                 int64_t _res_conv_27 = _res_vals[b];
8208                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
8209                 FREE((void*)_res_conv_27);
8210                 _res_constr.data[b] = _res_conv_27_conv;
8211         }
8212         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8213         CVec_SpendableOutputDescriptorZ_free(_res_constr);
8214 }
8215
8216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8217         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
8218         FREE((void*)o);
8219         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8220         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
8221         return (long)ret_conv;
8222 }
8223
8224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
8225         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
8226         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8227         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
8228         return (long)ret_conv;
8229 }
8230
8231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8232         if ((_res & 1) != 0) return;
8233         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
8234         FREE((void*)_res);
8235         CResult_TxOutAccessErrorZ_free(_res_conv);
8236 }
8237
8238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8239         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
8240         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8241         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
8242         return (long)ret_conv;
8243 }
8244
8245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
8246         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
8247         FREE((void*)o);
8248         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8249         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
8250         long ret_ref = (long)ret_copy;
8251         return ret_ref;
8252 }
8253
8254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
8255         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8256         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
8257         long ret_ref = (long)ret_copy;
8258         return ret_ref;
8259 }
8260
8261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8262         if ((_res & 1) != 0) return;
8263         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
8264         FREE((void*)_res);
8265         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
8266 }
8267
8268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
8269         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8270         *ret_conv = CResult_NoneAPIErrorZ_ok();
8271         return (long)ret_conv;
8272 }
8273
8274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8275         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
8276         FREE((void*)e);
8277         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8278         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
8279         return (long)ret_conv;
8280 }
8281
8282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8283         if ((_res & 1) != 0) return;
8284         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
8285         FREE((void*)_res);
8286         CResult_NoneAPIErrorZ_free(_res_conv);
8287 }
8288
8289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8290         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
8291         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8292         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
8293         return (long)ret_conv;
8294 }
8295
8296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8297         LDKCVec_CResult_NoneAPIErrorZZ _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(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
8301         else
8302                 _res_constr.data = NULL;
8303         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8304         for (size_t w = 0; w < _res_constr.datalen; w++) {
8305                 int64_t _res_conv_22 = _res_vals[w];
8306                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
8307                 FREE((void*)_res_conv_22);
8308                 _res_constr.data[w] = _res_conv_22_conv;
8309         }
8310         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8311         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
8312 }
8313
8314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8315         LDKCVec_APIErrorZ _res_constr;
8316         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8317         if (_res_constr.datalen > 0)
8318                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
8319         else
8320                 _res_constr.data = NULL;
8321         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8322         for (size_t k = 0; k < _res_constr.datalen; k++) {
8323                 int64_t _res_conv_10 = _res_vals[k];
8324                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
8325                 FREE((void*)_res_conv_10);
8326                 _res_constr.data[k] = _res_conv_10_conv;
8327         }
8328         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8329         CVec_APIErrorZ_free(_res_constr);
8330 }
8331
8332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8333         LDKCVec_ChannelDetailsZ _res_constr;
8334         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8335         if (_res_constr.datalen > 0)
8336                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
8337         else
8338                 _res_constr.data = NULL;
8339         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8340         for (size_t q = 0; q < _res_constr.datalen; q++) {
8341                 int64_t _res_conv_16 = _res_vals[q];
8342                 LDKChannelDetails _res_conv_16_conv;
8343                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8344                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8345                 _res_constr.data[q] = _res_conv_16_conv;
8346         }
8347         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8348         CVec_ChannelDetailsZ_free(_res_constr);
8349 }
8350
8351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
8352         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8353         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
8354         return (long)ret_conv;
8355 }
8356
8357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8358         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
8359         FREE((void*)e);
8360         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8361         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
8362         return (long)ret_conv;
8363 }
8364
8365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8366         if ((_res & 1) != 0) return;
8367         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
8368         FREE((void*)_res);
8369         CResult_NonePaymentSendFailureZ_free(_res_conv);
8370 }
8371
8372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8373         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
8374         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8375         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
8376         return (long)ret_conv;
8377 }
8378
8379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8380         LDKCVec_ChannelMonitorZ _res_constr;
8381         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8382         if (_res_constr.datalen > 0)
8383                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
8384         else
8385                 _res_constr.data = NULL;
8386         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8387         for (size_t q = 0; q < _res_constr.datalen; q++) {
8388                 int64_t _res_conv_16 = _res_vals[q];
8389                 LDKChannelMonitor _res_conv_16_conv;
8390                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8391                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8392                 _res_constr.data[q] = _res_conv_16_conv;
8393         }
8394         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8395         CVec_ChannelMonitorZ_free(_res_constr);
8396 }
8397
8398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
8399         LDKThirtyTwoBytes a_ref;
8400         CHECK((*env)->GetArrayLength(env, a) == 32);
8401         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
8402         LDKChannelManager b_conv;
8403         b_conv.inner = (void*)(b & (~1));
8404         b_conv.is_owned = (b & 1) || (b == 0);
8405         // Warning: we need a move here but no clone is available for LDKChannelManager
8406         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
8407         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
8408         return (long)ret_ref;
8409 }
8410
8411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8412         if ((_res & 1) != 0) return;
8413         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
8414         FREE((void*)_res);
8415         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
8416 }
8417
8418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8419         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
8420         FREE((void*)o);
8421         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8422         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
8423         return (long)ret_conv;
8424 }
8425
8426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8427         LDKDecodeError e_conv;
8428         e_conv.inner = (void*)(e & (~1));
8429         e_conv.is_owned = (e & 1) || (e == 0);
8430         e_conv = DecodeError_clone(&e_conv);
8431         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8432         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
8433         return (long)ret_conv;
8434 }
8435
8436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8437         if ((_res & 1) != 0) return;
8438         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8439         FREE((void*)_res);
8440         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
8441 }
8442
8443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8444         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
8445         FREE((void*)o);
8446         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8447         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
8448         return (long)ret_conv;
8449 }
8450
8451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8452         LDKDecodeError e_conv;
8453         e_conv.inner = (void*)(e & (~1));
8454         e_conv.is_owned = (e & 1) || (e == 0);
8455         e_conv = DecodeError_clone(&e_conv);
8456         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8457         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
8458         return (long)ret_conv;
8459 }
8460
8461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8462         if ((_res & 1) != 0) return;
8463         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
8464         FREE((void*)_res);
8465         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
8466 }
8467
8468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8469         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
8470         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8471         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
8472         return (long)ret_conv;
8473 }
8474
8475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8476         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
8477         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
8478         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
8479         return (long)ret_ref;
8480 }
8481
8482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
8483         LDKSignature a_ref;
8484         CHECK((*env)->GetArrayLength(env, a) == 64);
8485         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
8486         LDKCVec_SignatureZ b_constr;
8487         b_constr.datalen = (*env)->GetArrayLength(env, b);
8488         if (b_constr.datalen > 0)
8489                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8490         else
8491                 b_constr.data = NULL;
8492         for (size_t i = 0; i < b_constr.datalen; i++) {
8493                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
8494                 LDKSignature b_conv_8_ref;
8495                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
8496                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
8497                 b_constr.data[i] = b_conv_8_ref;
8498         }
8499         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
8500         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
8501         return (long)ret_ref;
8502 }
8503
8504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8505         if ((_res & 1) != 0) return;
8506         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
8507         FREE((void*)_res);
8508         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
8509 }
8510
8511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8512         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
8513         FREE((void*)o);
8514         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8515         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
8516         return (long)ret_conv;
8517 }
8518
8519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
8520         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8521         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
8522         return (long)ret_conv;
8523 }
8524
8525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8526         if ((_res & 1) != 0) return;
8527         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
8528         FREE((void*)_res);
8529         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
8530 }
8531
8532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8533         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
8534         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8535         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
8536         return (long)ret_conv;
8537 }
8538
8539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8540         LDKSignature o_ref;
8541         CHECK((*env)->GetArrayLength(env, o) == 64);
8542         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
8543         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8544         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
8545         return (long)ret_conv;
8546 }
8547
8548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
8549         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8550         *ret_conv = CResult_SignatureNoneZ_err();
8551         return (long)ret_conv;
8552 }
8553
8554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8555         if ((_res & 1) != 0) return;
8556         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
8557         FREE((void*)_res);
8558         CResult_SignatureNoneZ_free(_res_conv);
8559 }
8560
8561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8562         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
8563         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8564         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
8565         return (long)ret_conv;
8566 }
8567
8568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8569         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
8570         if (o_conv.free == LDKSign_JCalls_free) {
8571                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8572                 LDKSign_JCalls_clone(o_conv.this_arg);
8573         }
8574         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8575         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
8576         return (long)ret_conv;
8577 }
8578
8579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8580         LDKDecodeError e_conv;
8581         e_conv.inner = (void*)(e & (~1));
8582         e_conv.is_owned = (e & 1) || (e == 0);
8583         e_conv = DecodeError_clone(&e_conv);
8584         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8585         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
8586         return (long)ret_conv;
8587 }
8588
8589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8590         if ((_res & 1) != 0) return;
8591         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
8592         FREE((void*)_res);
8593         CResult_SignDecodeErrorZ_free(_res_conv);
8594 }
8595
8596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8597         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
8598         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8599         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
8600         return (long)ret_conv;
8601 }
8602
8603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
8604         LDKCVec_CVec_u8ZZ _res_constr;
8605         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8606         if (_res_constr.datalen > 0)
8607                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
8608         else
8609                 _res_constr.data = NULL;
8610         for (size_t i = 0; i < _res_constr.datalen; i++) {
8611                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
8612                 LDKCVec_u8Z _res_conv_8_ref;
8613                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
8614                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
8615                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
8616                 _res_constr.data[i] = _res_conv_8_ref;
8617         }
8618         CVec_CVec_u8ZZ_free(_res_constr);
8619 }
8620
8621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
8622         LDKCVec_CVec_u8ZZ o_constr;
8623         o_constr.datalen = (*env)->GetArrayLength(env, o);
8624         if (o_constr.datalen > 0)
8625                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
8626         else
8627                 o_constr.data = NULL;
8628         for (size_t i = 0; i < o_constr.datalen; i++) {
8629                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
8630                 LDKCVec_u8Z o_conv_8_ref;
8631                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
8632                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
8633                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
8634                 o_constr.data[i] = o_conv_8_ref;
8635         }
8636         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8637         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
8638         return (long)ret_conv;
8639 }
8640
8641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
8642         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8643         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
8644         return (long)ret_conv;
8645 }
8646
8647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8648         if ((_res & 1) != 0) return;
8649         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
8650         FREE((void*)_res);
8651         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
8652 }
8653
8654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8655         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
8656         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8657         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
8658         return (long)ret_conv;
8659 }
8660
8661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8662         LDKInMemorySigner o_conv;
8663         o_conv.inner = (void*)(o & (~1));
8664         o_conv.is_owned = (o & 1) || (o == 0);
8665         o_conv = InMemorySigner_clone(&o_conv);
8666         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8667         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
8668         return (long)ret_conv;
8669 }
8670
8671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8672         LDKDecodeError e_conv;
8673         e_conv.inner = (void*)(e & (~1));
8674         e_conv.is_owned = (e & 1) || (e == 0);
8675         e_conv = DecodeError_clone(&e_conv);
8676         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8677         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
8678         return (long)ret_conv;
8679 }
8680
8681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8682         if ((_res & 1) != 0) return;
8683         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
8684         FREE((void*)_res);
8685         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
8686 }
8687
8688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8689         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
8690         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8691         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
8692         return (long)ret_conv;
8693 }
8694
8695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8696         LDKCVec_TxOutZ _res_constr;
8697         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8698         if (_res_constr.datalen > 0)
8699                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
8700         else
8701                 _res_constr.data = NULL;
8702         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8703         for (size_t h = 0; h < _res_constr.datalen; h++) {
8704                 int64_t _res_conv_7 = _res_vals[h];
8705                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
8706                 FREE((void*)_res_conv_7);
8707                 _res_constr.data[h] = _res_conv_7_conv;
8708         }
8709         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8710         CVec_TxOutZ_free(_res_constr);
8711 }
8712
8713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8714         LDKTransaction o_ref;
8715         o_ref.datalen = (*env)->GetArrayLength(env, o);
8716         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
8717         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
8718         o_ref.data_is_owned = true;
8719         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8720         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
8721         return (long)ret_conv;
8722 }
8723
8724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
8725         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8726         *ret_conv = CResult_TransactionNoneZ_err();
8727         return (long)ret_conv;
8728 }
8729
8730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8731         if ((_res & 1) != 0) return;
8732         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
8733         FREE((void*)_res);
8734         CResult_TransactionNoneZ_free(_res_conv);
8735 }
8736
8737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8738         LDKCVec_RouteHopZ _res_constr;
8739         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8740         if (_res_constr.datalen > 0)
8741                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8742         else
8743                 _res_constr.data = NULL;
8744         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8745         for (size_t k = 0; k < _res_constr.datalen; k++) {
8746                 int64_t _res_conv_10 = _res_vals[k];
8747                 LDKRouteHop _res_conv_10_conv;
8748                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
8749                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
8750                 _res_constr.data[k] = _res_conv_10_conv;
8751         }
8752         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8753         CVec_RouteHopZ_free(_res_constr);
8754 }
8755
8756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
8757         LDKCVec_CVec_RouteHopZZ _res_constr;
8758         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8759         if (_res_constr.datalen > 0)
8760                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
8761         else
8762                 _res_constr.data = NULL;
8763         for (size_t m = 0; m < _res_constr.datalen; m++) {
8764                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
8765                 LDKCVec_RouteHopZ _res_conv_12_constr;
8766                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
8767                 if (_res_conv_12_constr.datalen > 0)
8768                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8769                 else
8770                         _res_conv_12_constr.data = NULL;
8771                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
8772                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
8773                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
8774                         LDKRouteHop _res_conv_12_conv_10_conv;
8775                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
8776                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
8777                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
8778                 }
8779                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
8780                 _res_constr.data[m] = _res_conv_12_constr;
8781         }
8782         CVec_CVec_RouteHopZZ_free(_res_constr);
8783 }
8784
8785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8786         LDKRoute o_conv;
8787         o_conv.inner = (void*)(o & (~1));
8788         o_conv.is_owned = (o & 1) || (o == 0);
8789         o_conv = Route_clone(&o_conv);
8790         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8791         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
8792         return (long)ret_conv;
8793 }
8794
8795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8796         LDKDecodeError e_conv;
8797         e_conv.inner = (void*)(e & (~1));
8798         e_conv.is_owned = (e & 1) || (e == 0);
8799         e_conv = DecodeError_clone(&e_conv);
8800         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8801         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
8802         return (long)ret_conv;
8803 }
8804
8805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8806         if ((_res & 1) != 0) return;
8807         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
8808         FREE((void*)_res);
8809         CResult_RouteDecodeErrorZ_free(_res_conv);
8810 }
8811
8812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8813         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
8814         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8815         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
8816         return (long)ret_conv;
8817 }
8818
8819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8820         LDKCVec_RouteHintZ _res_constr;
8821         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8822         if (_res_constr.datalen > 0)
8823                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
8824         else
8825                 _res_constr.data = NULL;
8826         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8827         for (size_t l = 0; l < _res_constr.datalen; l++) {
8828                 int64_t _res_conv_11 = _res_vals[l];
8829                 LDKRouteHint _res_conv_11_conv;
8830                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
8831                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
8832                 _res_constr.data[l] = _res_conv_11_conv;
8833         }
8834         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8835         CVec_RouteHintZ_free(_res_constr);
8836 }
8837
8838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8839         LDKRoute o_conv;
8840         o_conv.inner = (void*)(o & (~1));
8841         o_conv.is_owned = (o & 1) || (o == 0);
8842         o_conv = Route_clone(&o_conv);
8843         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8844         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
8845         return (long)ret_conv;
8846 }
8847
8848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8849         LDKLightningError e_conv;
8850         e_conv.inner = (void*)(e & (~1));
8851         e_conv.is_owned = (e & 1) || (e == 0);
8852         e_conv = LightningError_clone(&e_conv);
8853         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8854         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
8855         return (long)ret_conv;
8856 }
8857
8858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8859         if ((_res & 1) != 0) return;
8860         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
8861         FREE((void*)_res);
8862         CResult_RouteLightningErrorZ_free(_res_conv);
8863 }
8864
8865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8866         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
8867         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8868         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
8869         return (long)ret_conv;
8870 }
8871
8872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
8873         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
8874         FREE((void*)o);
8875         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8876         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
8877         return (long)ret_conv;
8878 }
8879
8880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
8881         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8882         *ret_conv = CResult_NetAddressu8Z_err(e);
8883         return (long)ret_conv;
8884 }
8885
8886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
8887         if ((_res & 1) != 0) return;
8888         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
8889         FREE((void*)_res);
8890         CResult_NetAddressu8Z_free(_res_conv);
8891 }
8892
8893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8894         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
8895         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8896         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
8897         return (long)ret_conv;
8898 }
8899
8900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8901         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
8902         FREE((void*)o);
8903         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8904         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
8905         return (long)ret_conv;
8906 }
8907
8908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8909         LDKDecodeError e_conv;
8910         e_conv.inner = (void*)(e & (~1));
8911         e_conv.is_owned = (e & 1) || (e == 0);
8912         e_conv = DecodeError_clone(&e_conv);
8913         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8914         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
8915         return (long)ret_conv;
8916 }
8917
8918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8919         if ((_res & 1) != 0) return;
8920         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8921         FREE((void*)_res);
8922         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
8923 }
8924
8925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8926         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
8927         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8928         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
8929         return (long)ret_conv;
8930 }
8931
8932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8933         LDKCVec_UpdateAddHTLCZ _res_constr;
8934         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8935         if (_res_constr.datalen > 0)
8936                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
8937         else
8938                 _res_constr.data = NULL;
8939         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8940         for (size_t p = 0; p < _res_constr.datalen; p++) {
8941                 int64_t _res_conv_15 = _res_vals[p];
8942                 LDKUpdateAddHTLC _res_conv_15_conv;
8943                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
8944                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
8945                 _res_constr.data[p] = _res_conv_15_conv;
8946         }
8947         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8948         CVec_UpdateAddHTLCZ_free(_res_constr);
8949 }
8950
8951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8952         LDKCVec_UpdateFulfillHTLCZ _res_constr;
8953         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8954         if (_res_constr.datalen > 0)
8955                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
8956         else
8957                 _res_constr.data = NULL;
8958         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8959         for (size_t t = 0; t < _res_constr.datalen; t++) {
8960                 int64_t _res_conv_19 = _res_vals[t];
8961                 LDKUpdateFulfillHTLC _res_conv_19_conv;
8962                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
8963                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
8964                 _res_constr.data[t] = _res_conv_19_conv;
8965         }
8966         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8967         CVec_UpdateFulfillHTLCZ_free(_res_constr);
8968 }
8969
8970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8971         LDKCVec_UpdateFailHTLCZ _res_constr;
8972         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8973         if (_res_constr.datalen > 0)
8974                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
8975         else
8976                 _res_constr.data = NULL;
8977         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8978         for (size_t q = 0; q < _res_constr.datalen; q++) {
8979                 int64_t _res_conv_16 = _res_vals[q];
8980                 LDKUpdateFailHTLC _res_conv_16_conv;
8981                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8982                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8983                 _res_constr.data[q] = _res_conv_16_conv;
8984         }
8985         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8986         CVec_UpdateFailHTLCZ_free(_res_constr);
8987 }
8988
8989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8990         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
8991         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8992         if (_res_constr.datalen > 0)
8993                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
8994         else
8995                 _res_constr.data = NULL;
8996         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8997         for (size_t z = 0; z < _res_constr.datalen; z++) {
8998                 int64_t _res_conv_25 = _res_vals[z];
8999                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
9000                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
9001                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
9002                 _res_constr.data[z] = _res_conv_25_conv;
9003         }
9004         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9005         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
9006 }
9007
9008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9009         LDKAcceptChannel o_conv;
9010         o_conv.inner = (void*)(o & (~1));
9011         o_conv.is_owned = (o & 1) || (o == 0);
9012         o_conv = AcceptChannel_clone(&o_conv);
9013         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9014         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
9015         return (long)ret_conv;
9016 }
9017
9018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9019         LDKDecodeError e_conv;
9020         e_conv.inner = (void*)(e & (~1));
9021         e_conv.is_owned = (e & 1) || (e == 0);
9022         e_conv = DecodeError_clone(&e_conv);
9023         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9024         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
9025         return (long)ret_conv;
9026 }
9027
9028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9029         if ((_res & 1) != 0) return;
9030         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
9031         FREE((void*)_res);
9032         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
9033 }
9034
9035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9036         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
9037         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9038         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
9039         return (long)ret_conv;
9040 }
9041
9042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9043         LDKAnnouncementSignatures o_conv;
9044         o_conv.inner = (void*)(o & (~1));
9045         o_conv.is_owned = (o & 1) || (o == 0);
9046         o_conv = AnnouncementSignatures_clone(&o_conv);
9047         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9048         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
9049         return (long)ret_conv;
9050 }
9051
9052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9053         LDKDecodeError e_conv;
9054         e_conv.inner = (void*)(e & (~1));
9055         e_conv.is_owned = (e & 1) || (e == 0);
9056         e_conv = DecodeError_clone(&e_conv);
9057         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9058         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
9059         return (long)ret_conv;
9060 }
9061
9062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9063         if ((_res & 1) != 0) return;
9064         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9065         FREE((void*)_res);
9066         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
9067 }
9068
9069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9070         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
9071         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9072         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
9073         return (long)ret_conv;
9074 }
9075
9076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9077         LDKChannelReestablish o_conv;
9078         o_conv.inner = (void*)(o & (~1));
9079         o_conv.is_owned = (o & 1) || (o == 0);
9080         o_conv = ChannelReestablish_clone(&o_conv);
9081         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9082         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
9083         return (long)ret_conv;
9084 }
9085
9086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9087         LDKDecodeError e_conv;
9088         e_conv.inner = (void*)(e & (~1));
9089         e_conv.is_owned = (e & 1) || (e == 0);
9090         e_conv = DecodeError_clone(&e_conv);
9091         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9092         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
9093         return (long)ret_conv;
9094 }
9095
9096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9097         if ((_res & 1) != 0) return;
9098         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
9099         FREE((void*)_res);
9100         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
9101 }
9102
9103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9104         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
9105         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9106         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
9107         return (long)ret_conv;
9108 }
9109
9110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9111         LDKClosingSigned o_conv;
9112         o_conv.inner = (void*)(o & (~1));
9113         o_conv.is_owned = (o & 1) || (o == 0);
9114         o_conv = ClosingSigned_clone(&o_conv);
9115         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9116         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
9117         return (long)ret_conv;
9118 }
9119
9120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9121         LDKDecodeError e_conv;
9122         e_conv.inner = (void*)(e & (~1));
9123         e_conv.is_owned = (e & 1) || (e == 0);
9124         e_conv = DecodeError_clone(&e_conv);
9125         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9126         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
9127         return (long)ret_conv;
9128 }
9129
9130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9131         if ((_res & 1) != 0) return;
9132         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9133         FREE((void*)_res);
9134         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
9135 }
9136
9137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9138         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
9139         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9140         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
9141         return (long)ret_conv;
9142 }
9143
9144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9145         LDKCommitmentSigned o_conv;
9146         o_conv.inner = (void*)(o & (~1));
9147         o_conv.is_owned = (o & 1) || (o == 0);
9148         o_conv = CommitmentSigned_clone(&o_conv);
9149         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
9150         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
9151         return (long)ret_conv;
9152 }
9153
9154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9155         LDKDecodeError e_conv;
9156         e_conv.inner = (void*)(e & (~1));
9157         e_conv.is_owned = (e & 1) || (e == 0);
9158         e_conv = DecodeError_clone(&e_conv);
9159         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
9160         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
9161         return (long)ret_conv;
9162 }
9163
9164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9165         if ((_res & 1) != 0) return;
9166         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9167         FREE((void*)_res);
9168         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
9169 }
9170
9171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9172         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
9173         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
9174         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
9175         return (long)ret_conv;
9176 }
9177
9178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9179         LDKFundingCreated o_conv;
9180         o_conv.inner = (void*)(o & (~1));
9181         o_conv.is_owned = (o & 1) || (o == 0);
9182         o_conv = FundingCreated_clone(&o_conv);
9183         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
9184         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
9185         return (long)ret_conv;
9186 }
9187
9188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9189         LDKDecodeError e_conv;
9190         e_conv.inner = (void*)(e & (~1));
9191         e_conv.is_owned = (e & 1) || (e == 0);
9192         e_conv = DecodeError_clone(&e_conv);
9193         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
9194         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
9195         return (long)ret_conv;
9196 }
9197
9198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9199         if ((_res & 1) != 0) return;
9200         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9201         FREE((void*)_res);
9202         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
9203 }
9204
9205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9206         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
9207         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
9208         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
9209         return (long)ret_conv;
9210 }
9211
9212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9213         LDKFundingSigned o_conv;
9214         o_conv.inner = (void*)(o & (~1));
9215         o_conv.is_owned = (o & 1) || (o == 0);
9216         o_conv = FundingSigned_clone(&o_conv);
9217         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9218         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
9219         return (long)ret_conv;
9220 }
9221
9222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9223         LDKDecodeError e_conv;
9224         e_conv.inner = (void*)(e & (~1));
9225         e_conv.is_owned = (e & 1) || (e == 0);
9226         e_conv = DecodeError_clone(&e_conv);
9227         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9228         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
9229         return (long)ret_conv;
9230 }
9231
9232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9233         if ((_res & 1) != 0) return;
9234         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9235         FREE((void*)_res);
9236         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
9237 }
9238
9239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9240         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
9241         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9242         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
9243         return (long)ret_conv;
9244 }
9245
9246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9247         LDKFundingLocked o_conv;
9248         o_conv.inner = (void*)(o & (~1));
9249         o_conv.is_owned = (o & 1) || (o == 0);
9250         o_conv = FundingLocked_clone(&o_conv);
9251         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9252         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
9253         return (long)ret_conv;
9254 }
9255
9256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9257         LDKDecodeError e_conv;
9258         e_conv.inner = (void*)(e & (~1));
9259         e_conv.is_owned = (e & 1) || (e == 0);
9260         e_conv = DecodeError_clone(&e_conv);
9261         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9262         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
9263         return (long)ret_conv;
9264 }
9265
9266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9267         if ((_res & 1) != 0) return;
9268         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9269         FREE((void*)_res);
9270         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
9271 }
9272
9273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9274         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
9275         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9276         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
9277         return (long)ret_conv;
9278 }
9279
9280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9281         LDKInit o_conv;
9282         o_conv.inner = (void*)(o & (~1));
9283         o_conv.is_owned = (o & 1) || (o == 0);
9284         o_conv = Init_clone(&o_conv);
9285         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9286         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
9287         return (long)ret_conv;
9288 }
9289
9290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9291         LDKDecodeError e_conv;
9292         e_conv.inner = (void*)(e & (~1));
9293         e_conv.is_owned = (e & 1) || (e == 0);
9294         e_conv = DecodeError_clone(&e_conv);
9295         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9296         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
9297         return (long)ret_conv;
9298 }
9299
9300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9301         if ((_res & 1) != 0) return;
9302         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
9303         FREE((void*)_res);
9304         CResult_InitDecodeErrorZ_free(_res_conv);
9305 }
9306
9307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9308         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
9309         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9310         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
9311         return (long)ret_conv;
9312 }
9313
9314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9315         LDKOpenChannel o_conv;
9316         o_conv.inner = (void*)(o & (~1));
9317         o_conv.is_owned = (o & 1) || (o == 0);
9318         o_conv = OpenChannel_clone(&o_conv);
9319         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9320         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
9321         return (long)ret_conv;
9322 }
9323
9324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9325         LDKDecodeError e_conv;
9326         e_conv.inner = (void*)(e & (~1));
9327         e_conv.is_owned = (e & 1) || (e == 0);
9328         e_conv = DecodeError_clone(&e_conv);
9329         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9330         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
9331         return (long)ret_conv;
9332 }
9333
9334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9335         if ((_res & 1) != 0) return;
9336         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
9337         FREE((void*)_res);
9338         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
9339 }
9340
9341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9342         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
9343         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9344         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
9345         return (long)ret_conv;
9346 }
9347
9348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9349         LDKRevokeAndACK o_conv;
9350         o_conv.inner = (void*)(o & (~1));
9351         o_conv.is_owned = (o & 1) || (o == 0);
9352         o_conv = RevokeAndACK_clone(&o_conv);
9353         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9354         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
9355         return (long)ret_conv;
9356 }
9357
9358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9359         LDKDecodeError e_conv;
9360         e_conv.inner = (void*)(e & (~1));
9361         e_conv.is_owned = (e & 1) || (e == 0);
9362         e_conv = DecodeError_clone(&e_conv);
9363         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9364         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
9365         return (long)ret_conv;
9366 }
9367
9368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9369         if ((_res & 1) != 0) return;
9370         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
9371         FREE((void*)_res);
9372         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
9373 }
9374
9375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9376         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
9377         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9378         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
9379         return (long)ret_conv;
9380 }
9381
9382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9383         LDKShutdown o_conv;
9384         o_conv.inner = (void*)(o & (~1));
9385         o_conv.is_owned = (o & 1) || (o == 0);
9386         o_conv = Shutdown_clone(&o_conv);
9387         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9388         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
9389         return (long)ret_conv;
9390 }
9391
9392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9393         LDKDecodeError e_conv;
9394         e_conv.inner = (void*)(e & (~1));
9395         e_conv.is_owned = (e & 1) || (e == 0);
9396         e_conv = DecodeError_clone(&e_conv);
9397         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9398         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
9399         return (long)ret_conv;
9400 }
9401
9402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9403         if ((_res & 1) != 0) return;
9404         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
9405         FREE((void*)_res);
9406         CResult_ShutdownDecodeErrorZ_free(_res_conv);
9407 }
9408
9409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9410         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
9411         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9412         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
9413         return (long)ret_conv;
9414 }
9415
9416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9417         LDKUpdateFailHTLC o_conv;
9418         o_conv.inner = (void*)(o & (~1));
9419         o_conv.is_owned = (o & 1) || (o == 0);
9420         o_conv = UpdateFailHTLC_clone(&o_conv);
9421         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9422         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
9423         return (long)ret_conv;
9424 }
9425
9426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9427         LDKDecodeError e_conv;
9428         e_conv.inner = (void*)(e & (~1));
9429         e_conv.is_owned = (e & 1) || (e == 0);
9430         e_conv = DecodeError_clone(&e_conv);
9431         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9432         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
9433         return (long)ret_conv;
9434 }
9435
9436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9437         if ((_res & 1) != 0) return;
9438         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9439         FREE((void*)_res);
9440         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
9441 }
9442
9443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9444         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
9445         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9446         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
9447         return (long)ret_conv;
9448 }
9449
9450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9451         LDKUpdateFailMalformedHTLC o_conv;
9452         o_conv.inner = (void*)(o & (~1));
9453         o_conv.is_owned = (o & 1) || (o == 0);
9454         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
9455         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
9456         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
9457         return (long)ret_conv;
9458 }
9459
9460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9461         LDKDecodeError e_conv;
9462         e_conv.inner = (void*)(e & (~1));
9463         e_conv.is_owned = (e & 1) || (e == 0);
9464         e_conv = DecodeError_clone(&e_conv);
9465         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
9466         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
9467         return (long)ret_conv;
9468 }
9469
9470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9471         if ((_res & 1) != 0) return;
9472         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9473         FREE((void*)_res);
9474         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
9475 }
9476
9477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9478         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
9479         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
9480         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
9481         return (long)ret_conv;
9482 }
9483
9484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9485         LDKUpdateFee o_conv;
9486         o_conv.inner = (void*)(o & (~1));
9487         o_conv.is_owned = (o & 1) || (o == 0);
9488         o_conv = UpdateFee_clone(&o_conv);
9489         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
9490         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
9491         return (long)ret_conv;
9492 }
9493
9494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9495         LDKDecodeError e_conv;
9496         e_conv.inner = (void*)(e & (~1));
9497         e_conv.is_owned = (e & 1) || (e == 0);
9498         e_conv = DecodeError_clone(&e_conv);
9499         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
9500         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
9501         return (long)ret_conv;
9502 }
9503
9504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9505         if ((_res & 1) != 0) return;
9506         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9507         FREE((void*)_res);
9508         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
9509 }
9510
9511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9512         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
9513         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
9514         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
9515         return (long)ret_conv;
9516 }
9517
9518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9519         LDKUpdateFulfillHTLC o_conv;
9520         o_conv.inner = (void*)(o & (~1));
9521         o_conv.is_owned = (o & 1) || (o == 0);
9522         o_conv = UpdateFulfillHTLC_clone(&o_conv);
9523         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
9524         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
9525         return (long)ret_conv;
9526 }
9527
9528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9529         LDKDecodeError e_conv;
9530         e_conv.inner = (void*)(e & (~1));
9531         e_conv.is_owned = (e & 1) || (e == 0);
9532         e_conv = DecodeError_clone(&e_conv);
9533         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
9534         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
9535         return (long)ret_conv;
9536 }
9537
9538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9539         if ((_res & 1) != 0) return;
9540         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9541         FREE((void*)_res);
9542         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
9543 }
9544
9545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9546         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
9547         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
9548         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
9549         return (long)ret_conv;
9550 }
9551
9552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9553         LDKUpdateAddHTLC o_conv;
9554         o_conv.inner = (void*)(o & (~1));
9555         o_conv.is_owned = (o & 1) || (o == 0);
9556         o_conv = UpdateAddHTLC_clone(&o_conv);
9557         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
9558         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
9559         return (long)ret_conv;
9560 }
9561
9562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9563         LDKDecodeError e_conv;
9564         e_conv.inner = (void*)(e & (~1));
9565         e_conv.is_owned = (e & 1) || (e == 0);
9566         e_conv = DecodeError_clone(&e_conv);
9567         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
9568         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
9569         return (long)ret_conv;
9570 }
9571
9572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9573         if ((_res & 1) != 0) return;
9574         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9575         FREE((void*)_res);
9576         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
9577 }
9578
9579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9580         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
9581         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
9582         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
9583         return (long)ret_conv;
9584 }
9585
9586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9587         LDKPing o_conv;
9588         o_conv.inner = (void*)(o & (~1));
9589         o_conv.is_owned = (o & 1) || (o == 0);
9590         o_conv = Ping_clone(&o_conv);
9591         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
9592         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
9593         return (long)ret_conv;
9594 }
9595
9596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9597         LDKDecodeError e_conv;
9598         e_conv.inner = (void*)(e & (~1));
9599         e_conv.is_owned = (e & 1) || (e == 0);
9600         e_conv = DecodeError_clone(&e_conv);
9601         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
9602         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
9603         return (long)ret_conv;
9604 }
9605
9606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9607         if ((_res & 1) != 0) return;
9608         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
9609         FREE((void*)_res);
9610         CResult_PingDecodeErrorZ_free(_res_conv);
9611 }
9612
9613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9614         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
9615         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
9616         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
9617         return (long)ret_conv;
9618 }
9619
9620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9621         LDKPong o_conv;
9622         o_conv.inner = (void*)(o & (~1));
9623         o_conv.is_owned = (o & 1) || (o == 0);
9624         o_conv = Pong_clone(&o_conv);
9625         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
9626         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
9627         return (long)ret_conv;
9628 }
9629
9630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9631         LDKDecodeError e_conv;
9632         e_conv.inner = (void*)(e & (~1));
9633         e_conv.is_owned = (e & 1) || (e == 0);
9634         e_conv = DecodeError_clone(&e_conv);
9635         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
9636         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
9637         return (long)ret_conv;
9638 }
9639
9640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9641         if ((_res & 1) != 0) return;
9642         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
9643         FREE((void*)_res);
9644         CResult_PongDecodeErrorZ_free(_res_conv);
9645 }
9646
9647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9648         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
9649         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
9650         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
9651         return (long)ret_conv;
9652 }
9653
9654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9655         LDKUnsignedChannelAnnouncement o_conv;
9656         o_conv.inner = (void*)(o & (~1));
9657         o_conv.is_owned = (o & 1) || (o == 0);
9658         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
9659         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
9660         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
9661         return (long)ret_conv;
9662 }
9663
9664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9665         LDKDecodeError e_conv;
9666         e_conv.inner = (void*)(e & (~1));
9667         e_conv.is_owned = (e & 1) || (e == 0);
9668         e_conv = DecodeError_clone(&e_conv);
9669         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
9670         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
9671         return (long)ret_conv;
9672 }
9673
9674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9675         if ((_res & 1) != 0) return;
9676         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9677         FREE((void*)_res);
9678         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
9679 }
9680
9681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9682         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
9683         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
9684         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
9685         return (long)ret_conv;
9686 }
9687
9688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9689         LDKChannelAnnouncement o_conv;
9690         o_conv.inner = (void*)(o & (~1));
9691         o_conv.is_owned = (o & 1) || (o == 0);
9692         o_conv = ChannelAnnouncement_clone(&o_conv);
9693         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
9694         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
9695         return (long)ret_conv;
9696 }
9697
9698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9699         LDKDecodeError e_conv;
9700         e_conv.inner = (void*)(e & (~1));
9701         e_conv.is_owned = (e & 1) || (e == 0);
9702         e_conv = DecodeError_clone(&e_conv);
9703         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
9704         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
9705         return (long)ret_conv;
9706 }
9707
9708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9709         if ((_res & 1) != 0) return;
9710         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9711         FREE((void*)_res);
9712         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
9713 }
9714
9715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9716         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
9717         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
9718         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
9719         return (long)ret_conv;
9720 }
9721
9722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9723         LDKUnsignedChannelUpdate o_conv;
9724         o_conv.inner = (void*)(o & (~1));
9725         o_conv.is_owned = (o & 1) || (o == 0);
9726         o_conv = UnsignedChannelUpdate_clone(&o_conv);
9727         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
9728         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
9729         return (long)ret_conv;
9730 }
9731
9732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9733         LDKDecodeError e_conv;
9734         e_conv.inner = (void*)(e & (~1));
9735         e_conv.is_owned = (e & 1) || (e == 0);
9736         e_conv = DecodeError_clone(&e_conv);
9737         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
9738         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
9739         return (long)ret_conv;
9740 }
9741
9742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9743         if ((_res & 1) != 0) return;
9744         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
9745         FREE((void*)_res);
9746         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
9747 }
9748
9749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9750         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
9751         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
9752         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
9753         return (long)ret_conv;
9754 }
9755
9756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9757         LDKChannelUpdate o_conv;
9758         o_conv.inner = (void*)(o & (~1));
9759         o_conv.is_owned = (o & 1) || (o == 0);
9760         o_conv = ChannelUpdate_clone(&o_conv);
9761         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
9762         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
9763         return (long)ret_conv;
9764 }
9765
9766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9767         LDKDecodeError e_conv;
9768         e_conv.inner = (void*)(e & (~1));
9769         e_conv.is_owned = (e & 1) || (e == 0);
9770         e_conv = DecodeError_clone(&e_conv);
9771         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
9772         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
9773         return (long)ret_conv;
9774 }
9775
9776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9777         if ((_res & 1) != 0) return;
9778         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
9779         FREE((void*)_res);
9780         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
9781 }
9782
9783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9784         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
9785         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
9786         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
9787         return (long)ret_conv;
9788 }
9789
9790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9791         LDKErrorMessage o_conv;
9792         o_conv.inner = (void*)(o & (~1));
9793         o_conv.is_owned = (o & 1) || (o == 0);
9794         o_conv = ErrorMessage_clone(&o_conv);
9795         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
9796         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
9797         return (long)ret_conv;
9798 }
9799
9800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9801         LDKDecodeError e_conv;
9802         e_conv.inner = (void*)(e & (~1));
9803         e_conv.is_owned = (e & 1) || (e == 0);
9804         e_conv = DecodeError_clone(&e_conv);
9805         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
9806         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
9807         return (long)ret_conv;
9808 }
9809
9810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9811         if ((_res & 1) != 0) return;
9812         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
9813         FREE((void*)_res);
9814         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
9815 }
9816
9817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9818         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
9819         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
9820         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
9821         return (long)ret_conv;
9822 }
9823
9824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9825         LDKUnsignedNodeAnnouncement o_conv;
9826         o_conv.inner = (void*)(o & (~1));
9827         o_conv.is_owned = (o & 1) || (o == 0);
9828         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
9829         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
9830         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
9831         return (long)ret_conv;
9832 }
9833
9834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9835         LDKDecodeError e_conv;
9836         e_conv.inner = (void*)(e & (~1));
9837         e_conv.is_owned = (e & 1) || (e == 0);
9838         e_conv = DecodeError_clone(&e_conv);
9839         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
9840         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
9841         return (long)ret_conv;
9842 }
9843
9844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9845         if ((_res & 1) != 0) return;
9846         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9847         FREE((void*)_res);
9848         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
9849 }
9850
9851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9852         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
9853         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
9854         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
9855         return (long)ret_conv;
9856 }
9857
9858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9859         LDKNodeAnnouncement o_conv;
9860         o_conv.inner = (void*)(o & (~1));
9861         o_conv.is_owned = (o & 1) || (o == 0);
9862         o_conv = NodeAnnouncement_clone(&o_conv);
9863         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9864         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
9865         return (long)ret_conv;
9866 }
9867
9868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9869         LDKDecodeError e_conv;
9870         e_conv.inner = (void*)(e & (~1));
9871         e_conv.is_owned = (e & 1) || (e == 0);
9872         e_conv = DecodeError_clone(&e_conv);
9873         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9874         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
9875         return (long)ret_conv;
9876 }
9877
9878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9879         if ((_res & 1) != 0) return;
9880         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9881         FREE((void*)_res);
9882         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
9883 }
9884
9885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9886         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
9887         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9888         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
9889         return (long)ret_conv;
9890 }
9891
9892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9893         LDKQueryShortChannelIds o_conv;
9894         o_conv.inner = (void*)(o & (~1));
9895         o_conv.is_owned = (o & 1) || (o == 0);
9896         o_conv = QueryShortChannelIds_clone(&o_conv);
9897         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9898         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
9899         return (long)ret_conv;
9900 }
9901
9902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9903         LDKDecodeError e_conv;
9904         e_conv.inner = (void*)(e & (~1));
9905         e_conv.is_owned = (e & 1) || (e == 0);
9906         e_conv = DecodeError_clone(&e_conv);
9907         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9908         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
9909         return (long)ret_conv;
9910 }
9911
9912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9913         if ((_res & 1) != 0) return;
9914         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
9915         FREE((void*)_res);
9916         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
9917 }
9918
9919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9920         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
9921         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9922         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
9923         return (long)ret_conv;
9924 }
9925
9926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9927         LDKReplyShortChannelIdsEnd o_conv;
9928         o_conv.inner = (void*)(o & (~1));
9929         o_conv.is_owned = (o & 1) || (o == 0);
9930         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
9931         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9932         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
9933         return (long)ret_conv;
9934 }
9935
9936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9937         LDKDecodeError e_conv;
9938         e_conv.inner = (void*)(e & (~1));
9939         e_conv.is_owned = (e & 1) || (e == 0);
9940         e_conv = DecodeError_clone(&e_conv);
9941         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9942         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
9943         return (long)ret_conv;
9944 }
9945
9946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9947         if ((_res & 1) != 0) return;
9948         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
9949         FREE((void*)_res);
9950         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
9951 }
9952
9953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9954         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
9955         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9956         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
9957         return (long)ret_conv;
9958 }
9959
9960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9961         LDKQueryChannelRange o_conv;
9962         o_conv.inner = (void*)(o & (~1));
9963         o_conv.is_owned = (o & 1) || (o == 0);
9964         o_conv = QueryChannelRange_clone(&o_conv);
9965         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9966         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
9967         return (long)ret_conv;
9968 }
9969
9970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9971         LDKDecodeError e_conv;
9972         e_conv.inner = (void*)(e & (~1));
9973         e_conv.is_owned = (e & 1) || (e == 0);
9974         e_conv = DecodeError_clone(&e_conv);
9975         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9976         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
9977         return (long)ret_conv;
9978 }
9979
9980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9981         if ((_res & 1) != 0) return;
9982         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9983         FREE((void*)_res);
9984         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
9985 }
9986
9987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9988         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
9989         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9990         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
9991         return (long)ret_conv;
9992 }
9993
9994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9995         LDKReplyChannelRange o_conv;
9996         o_conv.inner = (void*)(o & (~1));
9997         o_conv.is_owned = (o & 1) || (o == 0);
9998         o_conv = ReplyChannelRange_clone(&o_conv);
9999         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10000         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
10001         return (long)ret_conv;
10002 }
10003
10004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10005         LDKDecodeError e_conv;
10006         e_conv.inner = (void*)(e & (~1));
10007         e_conv.is_owned = (e & 1) || (e == 0);
10008         e_conv = DecodeError_clone(&e_conv);
10009         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10010         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
10011         return (long)ret_conv;
10012 }
10013
10014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10015         if ((_res & 1) != 0) return;
10016         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10017         FREE((void*)_res);
10018         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
10019 }
10020
10021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10022         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
10023         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10024         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
10025         return (long)ret_conv;
10026 }
10027
10028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10029         LDKGossipTimestampFilter o_conv;
10030         o_conv.inner = (void*)(o & (~1));
10031         o_conv.is_owned = (o & 1) || (o == 0);
10032         o_conv = GossipTimestampFilter_clone(&o_conv);
10033         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10034         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
10035         return (long)ret_conv;
10036 }
10037
10038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10039         LDKDecodeError e_conv;
10040         e_conv.inner = (void*)(e & (~1));
10041         e_conv.is_owned = (e & 1) || (e == 0);
10042         e_conv = DecodeError_clone(&e_conv);
10043         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10044         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
10045         return (long)ret_conv;
10046 }
10047
10048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10049         if ((_res & 1) != 0) return;
10050         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
10051         FREE((void*)_res);
10052         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
10053 }
10054
10055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10056         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
10057         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10058         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
10059         return (long)ret_conv;
10060 }
10061
10062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10063         if ((this_ptr & 1) != 0) return;
10064         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
10065         FREE((void*)this_ptr);
10066         Event_free(this_ptr_conv);
10067 }
10068
10069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10070         LDKEvent* orig_conv = (LDKEvent*)orig;
10071         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
10072         *ret_copy = Event_clone(orig_conv);
10073         long ret_ref = (long)ret_copy;
10074         return ret_ref;
10075 }
10076
10077 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
10078         LDKEvent* obj_conv = (LDKEvent*)obj;
10079         LDKCVec_u8Z ret_var = Event_write(obj_conv);
10080         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10081         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10082         CVec_u8Z_free(ret_var);
10083         return ret_arr;
10084 }
10085
10086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10087         if ((this_ptr & 1) != 0) return;
10088         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
10089         FREE((void*)this_ptr);
10090         MessageSendEvent_free(this_ptr_conv);
10091 }
10092
10093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10094         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
10095         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10096         *ret_copy = MessageSendEvent_clone(orig_conv);
10097         long ret_ref = (long)ret_copy;
10098         return ret_ref;
10099 }
10100
10101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10102         if ((this_ptr & 1) != 0) return;
10103         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
10104         FREE((void*)this_ptr);
10105         MessageSendEventsProvider_free(this_ptr_conv);
10106 }
10107
10108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10109         if ((this_ptr & 1) != 0) return;
10110         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
10111         FREE((void*)this_ptr);
10112         EventsProvider_free(this_ptr_conv);
10113 }
10114
10115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10116         if ((this_ptr & 1) != 0) return;
10117         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
10118         FREE((void*)this_ptr);
10119         APIError_free(this_ptr_conv);
10120 }
10121
10122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10123         LDKAPIError* orig_conv = (LDKAPIError*)orig;
10124         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
10125         *ret_copy = APIError_clone(orig_conv);
10126         long ret_ref = (long)ret_copy;
10127         return ret_ref;
10128 }
10129
10130 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10131         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
10132         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
10133         return ret_conv;
10134 }
10135
10136 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
10137         jclass ret_conv = LDKLevel_to_java(env, Level_max());
10138         return ret_conv;
10139 }
10140
10141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10142         if ((this_ptr & 1) != 0) return;
10143         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
10144         FREE((void*)this_ptr);
10145         Logger_free(this_ptr_conv);
10146 }
10147
10148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10149         LDKChannelHandshakeConfig this_obj_conv;
10150         this_obj_conv.inner = (void*)(this_obj & (~1));
10151         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10152         ChannelHandshakeConfig_free(this_obj_conv);
10153 }
10154
10155 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
10156         LDKChannelHandshakeConfig this_ptr_conv;
10157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10158         this_ptr_conv.is_owned = false;
10159         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
10160         return ret_val;
10161 }
10162
10163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
10164         LDKChannelHandshakeConfig this_ptr_conv;
10165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10166         this_ptr_conv.is_owned = false;
10167         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
10168 }
10169
10170 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
10171         LDKChannelHandshakeConfig this_ptr_conv;
10172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10173         this_ptr_conv.is_owned = false;
10174         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
10175         return ret_val;
10176 }
10177
10178 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) {
10179         LDKChannelHandshakeConfig this_ptr_conv;
10180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10181         this_ptr_conv.is_owned = false;
10182         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
10183 }
10184
10185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
10186         LDKChannelHandshakeConfig this_ptr_conv;
10187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10188         this_ptr_conv.is_owned = false;
10189         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
10190         return ret_val;
10191 }
10192
10193 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) {
10194         LDKChannelHandshakeConfig this_ptr_conv;
10195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10196         this_ptr_conv.is_owned = false;
10197         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
10198 }
10199
10200 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) {
10201         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
10202         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10203         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10204         long ret_ref = (long)ret_var.inner;
10205         if (ret_var.is_owned) {
10206                 ret_ref |= 1;
10207         }
10208         return ret_ref;
10209 }
10210
10211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10212         LDKChannelHandshakeConfig orig_conv;
10213         orig_conv.inner = (void*)(orig & (~1));
10214         orig_conv.is_owned = false;
10215         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
10216         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10217         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10218         long ret_ref = (long)ret_var.inner;
10219         if (ret_var.is_owned) {
10220                 ret_ref |= 1;
10221         }
10222         return ret_ref;
10223 }
10224
10225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
10226         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
10227         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10228         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10229         long ret_ref = (long)ret_var.inner;
10230         if (ret_var.is_owned) {
10231                 ret_ref |= 1;
10232         }
10233         return ret_ref;
10234 }
10235
10236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10237         LDKChannelHandshakeLimits this_obj_conv;
10238         this_obj_conv.inner = (void*)(this_obj & (~1));
10239         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10240         ChannelHandshakeLimits_free(this_obj_conv);
10241 }
10242
10243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10244         LDKChannelHandshakeLimits this_ptr_conv;
10245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10246         this_ptr_conv.is_owned = false;
10247         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
10248         return ret_val;
10249 }
10250
10251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10252         LDKChannelHandshakeLimits this_ptr_conv;
10253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10254         this_ptr_conv.is_owned = false;
10255         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
10256 }
10257
10258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
10259         LDKChannelHandshakeLimits this_ptr_conv;
10260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10261         this_ptr_conv.is_owned = false;
10262         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
10263         return ret_val;
10264 }
10265
10266 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) {
10267         LDKChannelHandshakeLimits this_ptr_conv;
10268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10269         this_ptr_conv.is_owned = false;
10270         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
10271 }
10272
10273 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) {
10274         LDKChannelHandshakeLimits this_ptr_conv;
10275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10276         this_ptr_conv.is_owned = false;
10277         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
10278         return ret_val;
10279 }
10280
10281 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) {
10282         LDKChannelHandshakeLimits this_ptr_conv;
10283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10284         this_ptr_conv.is_owned = false;
10285         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
10286 }
10287
10288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10289         LDKChannelHandshakeLimits this_ptr_conv;
10290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10291         this_ptr_conv.is_owned = false;
10292         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
10293         return ret_val;
10294 }
10295
10296 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) {
10297         LDKChannelHandshakeLimits this_ptr_conv;
10298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10299         this_ptr_conv.is_owned = false;
10300         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
10301 }
10302
10303 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
10304         LDKChannelHandshakeLimits this_ptr_conv;
10305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10306         this_ptr_conv.is_owned = false;
10307         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
10308         return ret_val;
10309 }
10310
10311 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) {
10312         LDKChannelHandshakeLimits this_ptr_conv;
10313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10314         this_ptr_conv.is_owned = false;
10315         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
10316 }
10317
10318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10319         LDKChannelHandshakeLimits this_ptr_conv;
10320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10321         this_ptr_conv.is_owned = false;
10322         int64_t ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
10323         return ret_val;
10324 }
10325
10326 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) {
10327         LDKChannelHandshakeLimits this_ptr_conv;
10328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10329         this_ptr_conv.is_owned = false;
10330         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
10331 }
10332
10333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10334         LDKChannelHandshakeLimits this_ptr_conv;
10335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10336         this_ptr_conv.is_owned = false;
10337         int64_t ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
10338         return ret_val;
10339 }
10340
10341 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) {
10342         LDKChannelHandshakeLimits this_ptr_conv;
10343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10344         this_ptr_conv.is_owned = false;
10345         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
10346 }
10347
10348 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
10349         LDKChannelHandshakeLimits this_ptr_conv;
10350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10351         this_ptr_conv.is_owned = false;
10352         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
10353         return ret_val;
10354 }
10355
10356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
10357         LDKChannelHandshakeLimits this_ptr_conv;
10358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10359         this_ptr_conv.is_owned = false;
10360         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
10361 }
10362
10363 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
10364         LDKChannelHandshakeLimits this_ptr_conv;
10365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10366         this_ptr_conv.is_owned = false;
10367         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
10368         return ret_val;
10369 }
10370
10371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
10372         LDKChannelHandshakeLimits this_ptr_conv;
10373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10374         this_ptr_conv.is_owned = false;
10375         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
10376 }
10377
10378 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
10379         LDKChannelHandshakeLimits this_ptr_conv;
10380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10381         this_ptr_conv.is_owned = false;
10382         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
10383         return ret_val;
10384 }
10385
10386 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) {
10387         LDKChannelHandshakeLimits this_ptr_conv;
10388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10389         this_ptr_conv.is_owned = false;
10390         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
10391 }
10392
10393 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) {
10394         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);
10395         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10396         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10397         long ret_ref = (long)ret_var.inner;
10398         if (ret_var.is_owned) {
10399                 ret_ref |= 1;
10400         }
10401         return ret_ref;
10402 }
10403
10404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10405         LDKChannelHandshakeLimits orig_conv;
10406         orig_conv.inner = (void*)(orig & (~1));
10407         orig_conv.is_owned = false;
10408         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
10409         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10410         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10411         long ret_ref = (long)ret_var.inner;
10412         if (ret_var.is_owned) {
10413                 ret_ref |= 1;
10414         }
10415         return ret_ref;
10416 }
10417
10418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
10419         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
10420         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10421         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10422         long ret_ref = (long)ret_var.inner;
10423         if (ret_var.is_owned) {
10424                 ret_ref |= 1;
10425         }
10426         return ret_ref;
10427 }
10428
10429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10430         LDKChannelConfig this_obj_conv;
10431         this_obj_conv.inner = (void*)(this_obj & (~1));
10432         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10433         ChannelConfig_free(this_obj_conv);
10434 }
10435
10436 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
10437         LDKChannelConfig this_ptr_conv;
10438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10439         this_ptr_conv.is_owned = false;
10440         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
10441         return ret_val;
10442 }
10443
10444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
10445         LDKChannelConfig this_ptr_conv;
10446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10447         this_ptr_conv.is_owned = false;
10448         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
10449 }
10450
10451 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
10452         LDKChannelConfig this_ptr_conv;
10453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10454         this_ptr_conv.is_owned = false;
10455         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
10456         return ret_val;
10457 }
10458
10459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
10460         LDKChannelConfig this_ptr_conv;
10461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10462         this_ptr_conv.is_owned = false;
10463         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
10464 }
10465
10466 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
10467         LDKChannelConfig this_ptr_conv;
10468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10469         this_ptr_conv.is_owned = false;
10470         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
10471         return ret_val;
10472 }
10473
10474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
10475         LDKChannelConfig this_ptr_conv;
10476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10477         this_ptr_conv.is_owned = false;
10478         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
10479 }
10480
10481 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
10482         LDKChannelConfig this_ptr_conv;
10483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10484         this_ptr_conv.is_owned = false;
10485         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
10486         return ret_val;
10487 }
10488
10489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
10490         LDKChannelConfig this_ptr_conv;
10491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10492         this_ptr_conv.is_owned = false;
10493         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
10494 }
10495
10496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
10497         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
10498         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10499         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10500         long ret_ref = (long)ret_var.inner;
10501         if (ret_var.is_owned) {
10502                 ret_ref |= 1;
10503         }
10504         return ret_ref;
10505 }
10506
10507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10508         LDKChannelConfig orig_conv;
10509         orig_conv.inner = (void*)(orig & (~1));
10510         orig_conv.is_owned = false;
10511         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
10512         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10513         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10514         long ret_ref = (long)ret_var.inner;
10515         if (ret_var.is_owned) {
10516                 ret_ref |= 1;
10517         }
10518         return ret_ref;
10519 }
10520
10521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
10522         LDKChannelConfig ret_var = ChannelConfig_default();
10523         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10524         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10525         long ret_ref = (long)ret_var.inner;
10526         if (ret_var.is_owned) {
10527                 ret_ref |= 1;
10528         }
10529         return ret_ref;
10530 }
10531
10532 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
10533         LDKChannelConfig obj_conv;
10534         obj_conv.inner = (void*)(obj & (~1));
10535         obj_conv.is_owned = false;
10536         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
10537         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10538         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10539         CVec_u8Z_free(ret_var);
10540         return ret_arr;
10541 }
10542
10543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10544         LDKu8slice ser_ref;
10545         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10546         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10547         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10548         *ret_conv = ChannelConfig_read(ser_ref);
10549         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10550         return (long)ret_conv;
10551 }
10552
10553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10554         LDKUserConfig this_obj_conv;
10555         this_obj_conv.inner = (void*)(this_obj & (~1));
10556         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10557         UserConfig_free(this_obj_conv);
10558 }
10559
10560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
10561         LDKUserConfig this_ptr_conv;
10562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10563         this_ptr_conv.is_owned = false;
10564         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
10565         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10566         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10567         long ret_ref = (long)ret_var.inner;
10568         if (ret_var.is_owned) {
10569                 ret_ref |= 1;
10570         }
10571         return ret_ref;
10572 }
10573
10574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10575         LDKUserConfig this_ptr_conv;
10576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10577         this_ptr_conv.is_owned = false;
10578         LDKChannelHandshakeConfig val_conv;
10579         val_conv.inner = (void*)(val & (~1));
10580         val_conv.is_owned = (val & 1) || (val == 0);
10581         val_conv = ChannelHandshakeConfig_clone(&val_conv);
10582         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
10583 }
10584
10585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
10586         LDKUserConfig this_ptr_conv;
10587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10588         this_ptr_conv.is_owned = false;
10589         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
10590         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10591         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10592         long ret_ref = (long)ret_var.inner;
10593         if (ret_var.is_owned) {
10594                 ret_ref |= 1;
10595         }
10596         return ret_ref;
10597 }
10598
10599 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) {
10600         LDKUserConfig this_ptr_conv;
10601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10602         this_ptr_conv.is_owned = false;
10603         LDKChannelHandshakeLimits val_conv;
10604         val_conv.inner = (void*)(val & (~1));
10605         val_conv.is_owned = (val & 1) || (val == 0);
10606         val_conv = ChannelHandshakeLimits_clone(&val_conv);
10607         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
10608 }
10609
10610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
10611         LDKUserConfig this_ptr_conv;
10612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10613         this_ptr_conv.is_owned = false;
10614         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
10615         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10616         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10617         long ret_ref = (long)ret_var.inner;
10618         if (ret_var.is_owned) {
10619                 ret_ref |= 1;
10620         }
10621         return ret_ref;
10622 }
10623
10624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10625         LDKUserConfig this_ptr_conv;
10626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10627         this_ptr_conv.is_owned = false;
10628         LDKChannelConfig val_conv;
10629         val_conv.inner = (void*)(val & (~1));
10630         val_conv.is_owned = (val & 1) || (val == 0);
10631         val_conv = ChannelConfig_clone(&val_conv);
10632         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
10633 }
10634
10635 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) {
10636         LDKChannelHandshakeConfig own_channel_config_arg_conv;
10637         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
10638         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
10639         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
10640         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
10641         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
10642         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
10643         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
10644         LDKChannelConfig channel_options_arg_conv;
10645         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
10646         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
10647         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
10648         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
10649         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10650         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10651         long ret_ref = (long)ret_var.inner;
10652         if (ret_var.is_owned) {
10653                 ret_ref |= 1;
10654         }
10655         return ret_ref;
10656 }
10657
10658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10659         LDKUserConfig orig_conv;
10660         orig_conv.inner = (void*)(orig & (~1));
10661         orig_conv.is_owned = false;
10662         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
10663         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10664         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10665         long ret_ref = (long)ret_var.inner;
10666         if (ret_var.is_owned) {
10667                 ret_ref |= 1;
10668         }
10669         return ret_ref;
10670 }
10671
10672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
10673         LDKUserConfig ret_var = UserConfig_default();
10674         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10675         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10676         long ret_ref = (long)ret_var.inner;
10677         if (ret_var.is_owned) {
10678                 ret_ref |= 1;
10679         }
10680         return ret_ref;
10681 }
10682
10683 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10684         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
10685         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
10686         return ret_conv;
10687 }
10688
10689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10690         if ((this_ptr & 1) != 0) return;
10691         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
10692         FREE((void*)this_ptr);
10693         Access_free(this_ptr_conv);
10694 }
10695
10696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10697         if ((this_ptr & 1) != 0) return;
10698         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
10699         FREE((void*)this_ptr);
10700         Listen_free(this_ptr_conv);
10701 }
10702
10703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10704         if ((this_ptr & 1) != 0) return;
10705         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
10706         FREE((void*)this_ptr);
10707         Watch_free(this_ptr_conv);
10708 }
10709
10710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10711         if ((this_ptr & 1) != 0) return;
10712         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
10713         FREE((void*)this_ptr);
10714         Filter_free(this_ptr_conv);
10715 }
10716
10717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10718         LDKWatchedOutput this_obj_conv;
10719         this_obj_conv.inner = (void*)(this_obj & (~1));
10720         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10721         WatchedOutput_free(this_obj_conv);
10722 }
10723
10724 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
10725         LDKWatchedOutput this_ptr_conv;
10726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10727         this_ptr_conv.is_owned = false;
10728         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10729         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
10730         return ret_arr;
10731 }
10732
10733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10734         LDKWatchedOutput this_ptr_conv;
10735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10736         this_ptr_conv.is_owned = false;
10737         LDKThirtyTwoBytes val_ref;
10738         CHECK((*env)->GetArrayLength(env, val) == 32);
10739         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
10740         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
10741 }
10742
10743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
10744         LDKWatchedOutput this_ptr_conv;
10745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10746         this_ptr_conv.is_owned = false;
10747         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
10748         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10749         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10750         long ret_ref = (long)ret_var.inner;
10751         if (ret_var.is_owned) {
10752                 ret_ref |= 1;
10753         }
10754         return ret_ref;
10755 }
10756
10757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10758         LDKWatchedOutput this_ptr_conv;
10759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10760         this_ptr_conv.is_owned = false;
10761         LDKOutPoint val_conv;
10762         val_conv.inner = (void*)(val & (~1));
10763         val_conv.is_owned = (val & 1) || (val == 0);
10764         val_conv = OutPoint_clone(&val_conv);
10765         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
10766 }
10767
10768 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
10769         LDKWatchedOutput this_ptr_conv;
10770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10771         this_ptr_conv.is_owned = false;
10772         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
10773         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10774         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10775         return ret_arr;
10776 }
10777
10778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10779         LDKWatchedOutput this_ptr_conv;
10780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10781         this_ptr_conv.is_owned = false;
10782         LDKCVec_u8Z val_ref;
10783         val_ref.datalen = (*env)->GetArrayLength(env, val);
10784         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
10785         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
10786         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
10787 }
10788
10789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1new(JNIEnv *env, jclass clz, int8_tArray block_hash_arg, int64_t outpoint_arg, int8_tArray script_pubkey_arg) {
10790         LDKThirtyTwoBytes block_hash_arg_ref;
10791         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
10792         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
10793         LDKOutPoint outpoint_arg_conv;
10794         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
10795         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
10796         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
10797         LDKCVec_u8Z script_pubkey_arg_ref;
10798         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
10799         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
10800         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
10801         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
10802         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10803         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10804         long ret_ref = (long)ret_var.inner;
10805         if (ret_var.is_owned) {
10806                 ret_ref |= 1;
10807         }
10808         return ret_ref;
10809 }
10810
10811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10812         if ((this_ptr & 1) != 0) return;
10813         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
10814         FREE((void*)this_ptr);
10815         BroadcasterInterface_free(this_ptr_conv);
10816 }
10817
10818 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10819         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
10820         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
10821         return ret_conv;
10822 }
10823
10824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10825         if ((this_ptr & 1) != 0) return;
10826         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
10827         FREE((void*)this_ptr);
10828         FeeEstimator_free(this_ptr_conv);
10829 }
10830
10831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10832         LDKChainMonitor this_obj_conv;
10833         this_obj_conv.inner = (void*)(this_obj & (~1));
10834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10835         ChainMonitor_free(this_obj_conv);
10836 }
10837
10838 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) {
10839         LDKChainMonitor this_arg_conv;
10840         this_arg_conv.inner = (void*)(this_arg & (~1));
10841         this_arg_conv.is_owned = false;
10842         unsigned char header_arr[80];
10843         CHECK((*env)->GetArrayLength(env, header) == 80);
10844         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10845         unsigned char (*header_ref)[80] = &header_arr;
10846         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10847         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
10848         if (txdata_constr.datalen > 0)
10849                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10850         else
10851                 txdata_constr.data = NULL;
10852         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
10853         for (size_t y = 0; y < txdata_constr.datalen; y++) {
10854                 int64_t txdata_conv_24 = txdata_vals[y];
10855                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
10856                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
10857                 txdata_constr.data[y] = txdata_conv_24_conv;
10858         }
10859         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
10860         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
10861 }
10862
10863 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) {
10864         LDKChainMonitor this_arg_conv;
10865         this_arg_conv.inner = (void*)(this_arg & (~1));
10866         this_arg_conv.is_owned = false;
10867         unsigned char header_arr[80];
10868         CHECK((*env)->GetArrayLength(env, header) == 80);
10869         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10870         unsigned char (*header_ref)[80] = &header_arr;
10871         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
10872 }
10873
10874 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) {
10875         LDKFilter *chain_source_conv_ptr = NULL;
10876         if (chain_source != 0) {
10877                 LDKFilter chain_source_conv;
10878                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
10879                 if (chain_source_conv.free == LDKFilter_JCalls_free) {
10880                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10881                         LDKFilter_JCalls_clone(chain_source_conv.this_arg);
10882                 }
10883                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
10884                 *chain_source_conv_ptr = chain_source_conv;
10885         }
10886         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10887         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
10888                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10889                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
10890         }
10891         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10892         if (logger_conv.free == LDKLogger_JCalls_free) {
10893                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10894                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10895         }
10896         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
10897         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
10898                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10899                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
10900         }
10901         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
10902         if (persister_conv.free == LDKPersist_JCalls_free) {
10903                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10904                 LDKPersist_JCalls_clone(persister_conv.this_arg);
10905         }
10906         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
10907         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10908         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10909         long ret_ref = (long)ret_var.inner;
10910         if (ret_var.is_owned) {
10911                 ret_ref |= 1;
10912         }
10913         return ret_ref;
10914 }
10915
10916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
10917         LDKChainMonitor this_arg_conv;
10918         this_arg_conv.inner = (void*)(this_arg & (~1));
10919         this_arg_conv.is_owned = false;
10920         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
10921         *ret = ChainMonitor_as_Watch(&this_arg_conv);
10922         return (long)ret;
10923 }
10924
10925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
10926         LDKChainMonitor this_arg_conv;
10927         this_arg_conv.inner = (void*)(this_arg & (~1));
10928         this_arg_conv.is_owned = false;
10929         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10930         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
10931         return (long)ret;
10932 }
10933
10934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10935         LDKChannelMonitorUpdate this_obj_conv;
10936         this_obj_conv.inner = (void*)(this_obj & (~1));
10937         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10938         ChannelMonitorUpdate_free(this_obj_conv);
10939 }
10940
10941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
10942         LDKChannelMonitorUpdate this_ptr_conv;
10943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10944         this_ptr_conv.is_owned = false;
10945         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
10946         return ret_val;
10947 }
10948
10949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10950         LDKChannelMonitorUpdate this_ptr_conv;
10951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10952         this_ptr_conv.is_owned = false;
10953         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
10954 }
10955
10956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10957         LDKChannelMonitorUpdate orig_conv;
10958         orig_conv.inner = (void*)(orig & (~1));
10959         orig_conv.is_owned = false;
10960         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
10961         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10962         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10963         long ret_ref = (long)ret_var.inner;
10964         if (ret_var.is_owned) {
10965                 ret_ref |= 1;
10966         }
10967         return ret_ref;
10968 }
10969
10970 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
10971         LDKChannelMonitorUpdate obj_conv;
10972         obj_conv.inner = (void*)(obj & (~1));
10973         obj_conv.is_owned = false;
10974         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
10975         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10976         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10977         CVec_u8Z_free(ret_var);
10978         return ret_arr;
10979 }
10980
10981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10982         LDKu8slice ser_ref;
10983         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10984         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10985         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10986         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
10987         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10988         return (long)ret_conv;
10989 }
10990
10991 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10992         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
10993         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
10994         return ret_conv;
10995 }
10996
10997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10998         LDKMonitorUpdateError this_obj_conv;
10999         this_obj_conv.inner = (void*)(this_obj & (~1));
11000         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11001         MonitorUpdateError_free(this_obj_conv);
11002 }
11003
11004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11005         LDKMonitorUpdateError orig_conv;
11006         orig_conv.inner = (void*)(orig & (~1));
11007         orig_conv.is_owned = false;
11008         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
11009         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11010         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11011         long ret_ref = (long)ret_var.inner;
11012         if (ret_var.is_owned) {
11013                 ret_ref |= 1;
11014         }
11015         return ret_ref;
11016 }
11017
11018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11019         if ((this_ptr & 1) != 0) return;
11020         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
11021         FREE((void*)this_ptr);
11022         MonitorEvent_free(this_ptr_conv);
11023 }
11024
11025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11026         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
11027         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
11028         *ret_copy = MonitorEvent_clone(orig_conv);
11029         long ret_ref = (long)ret_copy;
11030         return ret_ref;
11031 }
11032
11033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11034         LDKHTLCUpdate this_obj_conv;
11035         this_obj_conv.inner = (void*)(this_obj & (~1));
11036         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11037         HTLCUpdate_free(this_obj_conv);
11038 }
11039
11040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11041         LDKHTLCUpdate orig_conv;
11042         orig_conv.inner = (void*)(orig & (~1));
11043         orig_conv.is_owned = false;
11044         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
11045         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11046         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11047         long ret_ref = (long)ret_var.inner;
11048         if (ret_var.is_owned) {
11049                 ret_ref |= 1;
11050         }
11051         return ret_ref;
11052 }
11053
11054 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
11055         LDKHTLCUpdate obj_conv;
11056         obj_conv.inner = (void*)(obj & (~1));
11057         obj_conv.is_owned = false;
11058         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
11059         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11060         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11061         CVec_u8Z_free(ret_var);
11062         return ret_arr;
11063 }
11064
11065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
11066         LDKu8slice ser_ref;
11067         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11068         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11069         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11070         *ret_conv = HTLCUpdate_read(ser_ref);
11071         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11072         return (long)ret_conv;
11073 }
11074
11075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11076         LDKChannelMonitor this_obj_conv;
11077         this_obj_conv.inner = (void*)(this_obj & (~1));
11078         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11079         ChannelMonitor_free(this_obj_conv);
11080 }
11081
11082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11083         LDKChannelMonitor orig_conv;
11084         orig_conv.inner = (void*)(orig & (~1));
11085         orig_conv.is_owned = false;
11086         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
11087         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11088         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11089         long ret_ref = (long)ret_var.inner;
11090         if (ret_var.is_owned) {
11091                 ret_ref |= 1;
11092         }
11093         return ret_ref;
11094 }
11095
11096 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
11097         LDKChannelMonitor obj_conv;
11098         obj_conv.inner = (void*)(obj & (~1));
11099         obj_conv.is_owned = false;
11100         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
11101         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11102         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11103         CVec_u8Z_free(ret_var);
11104         return ret_arr;
11105 }
11106
11107 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) {
11108         LDKChannelMonitor this_arg_conv;
11109         this_arg_conv.inner = (void*)(this_arg & (~1));
11110         this_arg_conv.is_owned = false;
11111         LDKChannelMonitorUpdate updates_conv;
11112         updates_conv.inner = (void*)(updates & (~1));
11113         updates_conv.is_owned = false;
11114         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11115         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11116         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
11117         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11118         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
11119         return (long)ret_conv;
11120 }
11121
11122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
11123         LDKChannelMonitor this_arg_conv;
11124         this_arg_conv.inner = (void*)(this_arg & (~1));
11125         this_arg_conv.is_owned = false;
11126         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
11127         return ret_val;
11128 }
11129
11130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
11131         LDKChannelMonitor this_arg_conv;
11132         this_arg_conv.inner = (void*)(this_arg & (~1));
11133         this_arg_conv.is_owned = false;
11134         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11135         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
11136         return (long)ret_ref;
11137 }
11138
11139 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
11140         LDKChannelMonitor this_arg_conv;
11141         this_arg_conv.inner = (void*)(this_arg & (~1));
11142         this_arg_conv.is_owned = false;
11143         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
11144         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11145         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11146         for (size_t v = 0; v < ret_var.datalen; v++) {
11147                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_47_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11148                 *ret_conv_47_ref = ret_var.data[v];
11149                 ret_arr_ptr[v] = (long)ret_conv_47_ref;
11150         }
11151         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11152         FREE(ret_var.data);
11153         return ret_arr;
11154 }
11155
11156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
11157         LDKChannelMonitor this_arg_conv;
11158         this_arg_conv.inner = (void*)(this_arg & (~1));
11159         this_arg_conv.is_owned = false;
11160         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
11161         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
11162 }
11163
11164 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
11165         LDKChannelMonitor this_arg_conv;
11166         this_arg_conv.inner = (void*)(this_arg & (~1));
11167         this_arg_conv.is_owned = false;
11168         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
11169         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11170         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11171         for (size_t o = 0; o < ret_var.datalen; o++) {
11172                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
11173                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
11174                 long ret_conv_14_ref = (long)ret_conv_14_copy;
11175                 ret_arr_ptr[o] = ret_conv_14_ref;
11176         }
11177         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11178         FREE(ret_var.data);
11179         return ret_arr;
11180 }
11181
11182 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
11183         LDKChannelMonitor this_arg_conv;
11184         this_arg_conv.inner = (void*)(this_arg & (~1));
11185         this_arg_conv.is_owned = false;
11186         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
11187         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11188         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11189         for (size_t h = 0; h < ret_var.datalen; h++) {
11190                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11191                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
11192                 long ret_conv_7_ref = (long)ret_conv_7_copy;
11193                 ret_arr_ptr[h] = ret_conv_7_ref;
11194         }
11195         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11196         FREE(ret_var.data);
11197         return ret_arr;
11198 }
11199
11200 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) {
11201         LDKChannelMonitor this_arg_conv;
11202         this_arg_conv.inner = (void*)(this_arg & (~1));
11203         this_arg_conv.is_owned = false;
11204         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
11205         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
11206         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11207         ;
11208         for (size_t i = 0; i < ret_var.datalen; i++) {
11209                 LDKTransaction ret_conv_8_var = ret_var.data[i];
11210                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
11211                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
11212                 Transaction_free(ret_conv_8_var);
11213                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11214         }
11215         FREE(ret_var.data);
11216         return ret_arr;
11217 }
11218
11219 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) {
11220         LDKChannelMonitor this_arg_conv;
11221         this_arg_conv.inner = (void*)(this_arg & (~1));
11222         this_arg_conv.is_owned = false;
11223         unsigned char header_arr[80];
11224         CHECK((*env)->GetArrayLength(env, header) == 80);
11225         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11226         unsigned char (*header_ref)[80] = &header_arr;
11227         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11228         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11229         if (txdata_constr.datalen > 0)
11230                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11231         else
11232                 txdata_constr.data = NULL;
11233         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11234         for (size_t y = 0; y < txdata_constr.datalen; y++) {
11235                 int64_t txdata_conv_24 = txdata_vals[y];
11236                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
11237                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
11238                 txdata_constr.data[y] = txdata_conv_24_conv;
11239         }
11240         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11241         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11242         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11243                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11244                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
11245         }
11246         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11247         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
11248                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11249                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
11250         }
11251         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11252         if (logger_conv.free == LDKLogger_JCalls_free) {
11253                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11254                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11255         }
11256         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);
11257         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11258         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11259         for (size_t u = 0; u < ret_var.datalen; u++) {
11260                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11261                 *ret_conv_46_ref = ret_var.data[u];
11262                 ret_arr_ptr[u] = (long)ret_conv_46_ref;
11263         }
11264         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11265         FREE(ret_var.data);
11266         return ret_arr;
11267 }
11268
11269 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) {
11270         LDKChannelMonitor this_arg_conv;
11271         this_arg_conv.inner = (void*)(this_arg & (~1));
11272         this_arg_conv.is_owned = false;
11273         unsigned char header_arr[80];
11274         CHECK((*env)->GetArrayLength(env, header) == 80);
11275         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11276         unsigned char (*header_ref)[80] = &header_arr;
11277         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11278         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11279                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11280                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
11281         }
11282         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11283         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
11284                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11285                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
11286         }
11287         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11288         if (logger_conv.free == LDKLogger_JCalls_free) {
11289                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11290                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11291         }
11292         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
11293 }
11294
11295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11296         if ((this_ptr & 1) != 0) return;
11297         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
11298         FREE((void*)this_ptr);
11299         Persist_free(this_ptr_conv);
11300 }
11301
11302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
11303         LDKu8slice ser_ref;
11304         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11305         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11306         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
11307         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11308         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
11309         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11310         return (long)ret_conv;
11311 }
11312
11313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11314         LDKOutPoint this_obj_conv;
11315         this_obj_conv.inner = (void*)(this_obj & (~1));
11316         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11317         OutPoint_free(this_obj_conv);
11318 }
11319
11320 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
11321         LDKOutPoint this_ptr_conv;
11322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11323         this_ptr_conv.is_owned = false;
11324         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11325         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
11326         return ret_arr;
11327 }
11328
11329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11330         LDKOutPoint this_ptr_conv;
11331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11332         this_ptr_conv.is_owned = false;
11333         LDKThirtyTwoBytes val_ref;
11334         CHECK((*env)->GetArrayLength(env, val) == 32);
11335         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11336         OutPoint_set_txid(&this_ptr_conv, val_ref);
11337 }
11338
11339 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
11340         LDKOutPoint this_ptr_conv;
11341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11342         this_ptr_conv.is_owned = false;
11343         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
11344         return ret_val;
11345 }
11346
11347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
11348         LDKOutPoint this_ptr_conv;
11349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11350         this_ptr_conv.is_owned = false;
11351         OutPoint_set_index(&this_ptr_conv, val);
11352 }
11353
11354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
11355         LDKThirtyTwoBytes txid_arg_ref;
11356         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
11357         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
11358         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
11359         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11360         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11361         long ret_ref = (long)ret_var.inner;
11362         if (ret_var.is_owned) {
11363                 ret_ref |= 1;
11364         }
11365         return ret_ref;
11366 }
11367
11368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11369         LDKOutPoint orig_conv;
11370         orig_conv.inner = (void*)(orig & (~1));
11371         orig_conv.is_owned = false;
11372         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
11373         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11374         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11375         long ret_ref = (long)ret_var.inner;
11376         if (ret_var.is_owned) {
11377                 ret_ref |= 1;
11378         }
11379         return ret_ref;
11380 }
11381
11382 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
11383         LDKOutPoint this_arg_conv;
11384         this_arg_conv.inner = (void*)(this_arg & (~1));
11385         this_arg_conv.is_owned = false;
11386         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11387         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
11388         return ret_arr;
11389 }
11390
11391 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
11392         LDKOutPoint obj_conv;
11393         obj_conv.inner = (void*)(obj & (~1));
11394         obj_conv.is_owned = false;
11395         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
11396         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11397         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11398         CVec_u8Z_free(ret_var);
11399         return ret_arr;
11400 }
11401
11402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
11403         LDKu8slice ser_ref;
11404         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11405         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11406         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
11407         *ret_conv = OutPoint_read(ser_ref);
11408         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11409         return (long)ret_conv;
11410 }
11411
11412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11413         LDKDelayedPaymentOutputDescriptor this_obj_conv;
11414         this_obj_conv.inner = (void*)(this_obj & (~1));
11415         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11416         DelayedPaymentOutputDescriptor_free(this_obj_conv);
11417 }
11418
11419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
11420         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11422         this_ptr_conv.is_owned = false;
11423         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
11424         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11425         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11426         long ret_ref = (long)ret_var.inner;
11427         if (ret_var.is_owned) {
11428                 ret_ref |= 1;
11429         }
11430         return ret_ref;
11431 }
11432
11433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11434         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11436         this_ptr_conv.is_owned = false;
11437         LDKOutPoint val_conv;
11438         val_conv.inner = (void*)(val & (~1));
11439         val_conv.is_owned = (val & 1) || (val == 0);
11440         val_conv = OutPoint_clone(&val_conv);
11441         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
11442 }
11443
11444 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
11445         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11447         this_ptr_conv.is_owned = false;
11448         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
11449         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
11450         return ret_arr;
11451 }
11452
11453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11454         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11456         this_ptr_conv.is_owned = false;
11457         LDKPublicKey val_ref;
11458         CHECK((*env)->GetArrayLength(env, val) == 33);
11459         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11460         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
11461 }
11462
11463 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
11464         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11466         this_ptr_conv.is_owned = false;
11467         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
11468         return ret_val;
11469 }
11470
11471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
11472         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11474         this_ptr_conv.is_owned = false;
11475         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
11476 }
11477
11478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11479         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11481         this_ptr_conv.is_owned = false;
11482         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
11483         FREE((void*)val);
11484         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
11485 }
11486
11487 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
11488         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11490         this_ptr_conv.is_owned = false;
11491         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
11492         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
11493         return ret_arr;
11494 }
11495
11496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11497         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11499         this_ptr_conv.is_owned = false;
11500         LDKPublicKey val_ref;
11501         CHECK((*env)->GetArrayLength(env, val) == 33);
11502         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11503         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
11504 }
11505
11506 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11507         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11509         this_ptr_conv.is_owned = false;
11510         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11511         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
11512         return ret_arr;
11513 }
11514
11515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11516         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11518         this_ptr_conv.is_owned = false;
11519         LDKThirtyTwoBytes val_ref;
11520         CHECK((*env)->GetArrayLength(env, val) == 32);
11521         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11522         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
11523 }
11524
11525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
11526         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11528         this_ptr_conv.is_owned = false;
11529         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
11530         return ret_val;
11531 }
11532
11533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11534         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11536         this_ptr_conv.is_owned = false;
11537         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
11538 }
11539
11540 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) {
11541         LDKOutPoint outpoint_arg_conv;
11542         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
11543         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
11544         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
11545         LDKPublicKey per_commitment_point_arg_ref;
11546         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
11547         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
11548         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
11549         FREE((void*)output_arg);
11550         LDKPublicKey revocation_pubkey_arg_ref;
11551         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
11552         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
11553         LDKThirtyTwoBytes channel_keys_id_arg_ref;
11554         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
11555         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
11556         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);
11557         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11558         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11559         long ret_ref = (long)ret_var.inner;
11560         if (ret_var.is_owned) {
11561                 ret_ref |= 1;
11562         }
11563         return ret_ref;
11564 }
11565
11566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11567         LDKDelayedPaymentOutputDescriptor orig_conv;
11568         orig_conv.inner = (void*)(orig & (~1));
11569         orig_conv.is_owned = false;
11570         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
11571         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11572         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11573         long ret_ref = (long)ret_var.inner;
11574         if (ret_var.is_owned) {
11575                 ret_ref |= 1;
11576         }
11577         return ret_ref;
11578 }
11579
11580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11581         LDKStaticPaymentOutputDescriptor this_obj_conv;
11582         this_obj_conv.inner = (void*)(this_obj & (~1));
11583         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11584         StaticPaymentOutputDescriptor_free(this_obj_conv);
11585 }
11586
11587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
11588         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11590         this_ptr_conv.is_owned = false;
11591         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
11592         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11593         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11594         long ret_ref = (long)ret_var.inner;
11595         if (ret_var.is_owned) {
11596                 ret_ref |= 1;
11597         }
11598         return ret_ref;
11599 }
11600
11601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11602         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11604         this_ptr_conv.is_owned = false;
11605         LDKOutPoint val_conv;
11606         val_conv.inner = (void*)(val & (~1));
11607         val_conv.is_owned = (val & 1) || (val == 0);
11608         val_conv = OutPoint_clone(&val_conv);
11609         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
11610 }
11611
11612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11613         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11615         this_ptr_conv.is_owned = false;
11616         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
11617         FREE((void*)val);
11618         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
11619 }
11620
11621 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11622         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11624         this_ptr_conv.is_owned = false;
11625         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11626         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
11627         return ret_arr;
11628 }
11629
11630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11631         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11633         this_ptr_conv.is_owned = false;
11634         LDKThirtyTwoBytes val_ref;
11635         CHECK((*env)->GetArrayLength(env, val) == 32);
11636         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11637         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
11638 }
11639
11640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
11641         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11643         this_ptr_conv.is_owned = false;
11644         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
11645         return ret_val;
11646 }
11647
11648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11649         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11651         this_ptr_conv.is_owned = false;
11652         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
11653 }
11654
11655 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) {
11656         LDKOutPoint outpoint_arg_conv;
11657         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
11658         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
11659         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
11660         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
11661         FREE((void*)output_arg);
11662         LDKThirtyTwoBytes channel_keys_id_arg_ref;
11663         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
11664         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
11665         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
11666         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11667         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11668         long ret_ref = (long)ret_var.inner;
11669         if (ret_var.is_owned) {
11670                 ret_ref |= 1;
11671         }
11672         return ret_ref;
11673 }
11674
11675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11676         LDKStaticPaymentOutputDescriptor orig_conv;
11677         orig_conv.inner = (void*)(orig & (~1));
11678         orig_conv.is_owned = false;
11679         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
11680         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11681         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11682         long ret_ref = (long)ret_var.inner;
11683         if (ret_var.is_owned) {
11684                 ret_ref |= 1;
11685         }
11686         return ret_ref;
11687 }
11688
11689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11690         if ((this_ptr & 1) != 0) return;
11691         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
11692         FREE((void*)this_ptr);
11693         SpendableOutputDescriptor_free(this_ptr_conv);
11694 }
11695
11696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11697         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
11698         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
11699         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
11700         long ret_ref = (long)ret_copy;
11701         return ret_ref;
11702 }
11703
11704 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
11705         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
11706         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
11707         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11708         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11709         CVec_u8Z_free(ret_var);
11710         return ret_arr;
11711 }
11712
11713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
11714         LDKu8slice ser_ref;
11715         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11716         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11717         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
11718         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
11719         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11720         return (long)ret_conv;
11721 }
11722
11723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11724         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
11725         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
11726         *ret = Sign_clone(orig_conv);
11727         return (long)ret;
11728 }
11729
11730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11731         if ((this_ptr & 1) != 0) return;
11732         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
11733         FREE((void*)this_ptr);
11734         Sign_free(this_ptr_conv);
11735 }
11736
11737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11738         if ((this_ptr & 1) != 0) return;
11739         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
11740         FREE((void*)this_ptr);
11741         KeysInterface_free(this_ptr_conv);
11742 }
11743
11744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11745         LDKInMemorySigner this_obj_conv;
11746         this_obj_conv.inner = (void*)(this_obj & (~1));
11747         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11748         InMemorySigner_free(this_obj_conv);
11749 }
11750
11751 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
11752         LDKInMemorySigner this_ptr_conv;
11753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11754         this_ptr_conv.is_owned = false;
11755         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11756         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
11757         return ret_arr;
11758 }
11759
11760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11761         LDKInMemorySigner this_ptr_conv;
11762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11763         this_ptr_conv.is_owned = false;
11764         LDKSecretKey val_ref;
11765         CHECK((*env)->GetArrayLength(env, val) == 32);
11766         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
11767         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
11768 }
11769
11770 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
11771         LDKInMemorySigner this_ptr_conv;
11772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11773         this_ptr_conv.is_owned = false;
11774         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11775         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
11776         return ret_arr;
11777 }
11778
11779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11780         LDKInMemorySigner this_ptr_conv;
11781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11782         this_ptr_conv.is_owned = false;
11783         LDKSecretKey val_ref;
11784         CHECK((*env)->GetArrayLength(env, val) == 32);
11785         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
11786         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
11787 }
11788
11789 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
11790         LDKInMemorySigner this_ptr_conv;
11791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11792         this_ptr_conv.is_owned = false;
11793         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11794         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
11795         return ret_arr;
11796 }
11797
11798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11799         LDKInMemorySigner this_ptr_conv;
11800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11801         this_ptr_conv.is_owned = false;
11802         LDKSecretKey val_ref;
11803         CHECK((*env)->GetArrayLength(env, val) == 32);
11804         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
11805         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
11806 }
11807
11808 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
11809         LDKInMemorySigner this_ptr_conv;
11810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11811         this_ptr_conv.is_owned = false;
11812         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11813         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
11814         return ret_arr;
11815 }
11816
11817 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) {
11818         LDKInMemorySigner this_ptr_conv;
11819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11820         this_ptr_conv.is_owned = false;
11821         LDKSecretKey val_ref;
11822         CHECK((*env)->GetArrayLength(env, val) == 32);
11823         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
11824         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
11825 }
11826
11827 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
11828         LDKInMemorySigner this_ptr_conv;
11829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11830         this_ptr_conv.is_owned = false;
11831         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11832         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
11833         return ret_arr;
11834 }
11835
11836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11837         LDKInMemorySigner this_ptr_conv;
11838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11839         this_ptr_conv.is_owned = false;
11840         LDKSecretKey val_ref;
11841         CHECK((*env)->GetArrayLength(env, val) == 32);
11842         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
11843         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
11844 }
11845
11846 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
11847         LDKInMemorySigner this_ptr_conv;
11848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11849         this_ptr_conv.is_owned = false;
11850         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11851         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
11852         return ret_arr;
11853 }
11854
11855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11856         LDKInMemorySigner this_ptr_conv;
11857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11858         this_ptr_conv.is_owned = false;
11859         LDKThirtyTwoBytes val_ref;
11860         CHECK((*env)->GetArrayLength(env, val) == 32);
11861         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11862         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
11863 }
11864
11865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11866         LDKInMemorySigner orig_conv;
11867         orig_conv.inner = (void*)(orig & (~1));
11868         orig_conv.is_owned = false;
11869         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
11870         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11871         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11872         long ret_ref = (long)ret_var.inner;
11873         if (ret_var.is_owned) {
11874                 ret_ref |= 1;
11875         }
11876         return ret_ref;
11877 }
11878
11879 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) {
11880         LDKSecretKey funding_key_ref;
11881         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
11882         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
11883         LDKSecretKey revocation_base_key_ref;
11884         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
11885         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
11886         LDKSecretKey payment_key_ref;
11887         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
11888         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
11889         LDKSecretKey delayed_payment_base_key_ref;
11890         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
11891         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
11892         LDKSecretKey htlc_base_key_ref;
11893         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
11894         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
11895         LDKThirtyTwoBytes commitment_seed_ref;
11896         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
11897         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
11898         LDKThirtyTwoBytes channel_keys_id_ref;
11899         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
11900         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
11901         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);
11902         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11903         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11904         long ret_ref = (long)ret_var.inner;
11905         if (ret_var.is_owned) {
11906                 ret_ref |= 1;
11907         }
11908         return ret_ref;
11909 }
11910
11911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
11912         LDKInMemorySigner this_arg_conv;
11913         this_arg_conv.inner = (void*)(this_arg & (~1));
11914         this_arg_conv.is_owned = false;
11915         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
11916         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11917         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11918         long ret_ref = (long)ret_var.inner;
11919         if (ret_var.is_owned) {
11920                 ret_ref |= 1;
11921         }
11922         return ret_ref;
11923 }
11924
11925 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
11926         LDKInMemorySigner this_arg_conv;
11927         this_arg_conv.inner = (void*)(this_arg & (~1));
11928         this_arg_conv.is_owned = false;
11929         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
11930         return ret_val;
11931 }
11932
11933 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
11934         LDKInMemorySigner this_arg_conv;
11935         this_arg_conv.inner = (void*)(this_arg & (~1));
11936         this_arg_conv.is_owned = false;
11937         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
11938         return ret_val;
11939 }
11940
11941 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
11942         LDKInMemorySigner this_arg_conv;
11943         this_arg_conv.inner = (void*)(this_arg & (~1));
11944         this_arg_conv.is_owned = false;
11945         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
11946         return ret_val;
11947 }
11948
11949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
11950         LDKInMemorySigner this_arg_conv;
11951         this_arg_conv.inner = (void*)(this_arg & (~1));
11952         this_arg_conv.is_owned = false;
11953         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
11954         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11955         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11956         long ret_ref = (long)ret_var.inner;
11957         if (ret_var.is_owned) {
11958                 ret_ref |= 1;
11959         }
11960         return ret_ref;
11961 }
11962
11963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
11964         LDKInMemorySigner this_arg_conv;
11965         this_arg_conv.inner = (void*)(this_arg & (~1));
11966         this_arg_conv.is_owned = false;
11967         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
11968         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11969         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11970         long ret_ref = (long)ret_var.inner;
11971         if (ret_var.is_owned) {
11972                 ret_ref |= 1;
11973         }
11974         return ret_ref;
11975 }
11976
11977 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) {
11978         LDKInMemorySigner this_arg_conv;
11979         this_arg_conv.inner = (void*)(this_arg & (~1));
11980         this_arg_conv.is_owned = false;
11981         LDKTransaction spend_tx_ref;
11982         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
11983         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
11984         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
11985         spend_tx_ref.data_is_owned = true;
11986         LDKStaticPaymentOutputDescriptor descriptor_conv;
11987         descriptor_conv.inner = (void*)(descriptor & (~1));
11988         descriptor_conv.is_owned = false;
11989         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
11990         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
11991         return (long)ret_conv;
11992 }
11993
11994 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) {
11995         LDKInMemorySigner this_arg_conv;
11996         this_arg_conv.inner = (void*)(this_arg & (~1));
11997         this_arg_conv.is_owned = false;
11998         LDKTransaction spend_tx_ref;
11999         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
12000         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
12001         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
12002         spend_tx_ref.data_is_owned = true;
12003         LDKDelayedPaymentOutputDescriptor descriptor_conv;
12004         descriptor_conv.inner = (void*)(descriptor & (~1));
12005         descriptor_conv.is_owned = false;
12006         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12007         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
12008         return (long)ret_conv;
12009 }
12010
12011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
12012         LDKInMemorySigner this_arg_conv;
12013         this_arg_conv.inner = (void*)(this_arg & (~1));
12014         this_arg_conv.is_owned = false;
12015         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
12016         *ret = InMemorySigner_as_Sign(&this_arg_conv);
12017         return (long)ret;
12018 }
12019
12020 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
12021         LDKInMemorySigner obj_conv;
12022         obj_conv.inner = (void*)(obj & (~1));
12023         obj_conv.is_owned = false;
12024         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
12025         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
12026         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
12027         CVec_u8Z_free(ret_var);
12028         return ret_arr;
12029 }
12030
12031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
12032         LDKu8slice ser_ref;
12033         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
12034         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
12035         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
12036         *ret_conv = InMemorySigner_read(ser_ref);
12037         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
12038         return (long)ret_conv;
12039 }
12040
12041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12042         LDKKeysManager this_obj_conv;
12043         this_obj_conv.inner = (void*)(this_obj & (~1));
12044         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12045         KeysManager_free(this_obj_conv);
12046 }
12047
12048 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) {
12049         unsigned char seed_arr[32];
12050         CHECK((*env)->GetArrayLength(env, seed) == 32);
12051         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
12052         unsigned char (*seed_ref)[32] = &seed_arr;
12053         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
12054         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12055         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12056         long ret_ref = (long)ret_var.inner;
12057         if (ret_var.is_owned) {
12058                 ret_ref |= 1;
12059         }
12060         return ret_ref;
12061 }
12062
12063 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) {
12064         LDKKeysManager this_arg_conv;
12065         this_arg_conv.inner = (void*)(this_arg & (~1));
12066         this_arg_conv.is_owned = false;
12067         unsigned char params_arr[32];
12068         CHECK((*env)->GetArrayLength(env, params) == 32);
12069         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
12070         unsigned char (*params_ref)[32] = &params_arr;
12071         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
12072         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12073         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12074         long ret_ref = (long)ret_var.inner;
12075         if (ret_var.is_owned) {
12076                 ret_ref |= 1;
12077         }
12078         return ret_ref;
12079 }
12080
12081 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) {
12082         LDKKeysManager this_arg_conv;
12083         this_arg_conv.inner = (void*)(this_arg & (~1));
12084         this_arg_conv.is_owned = false;
12085         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
12086         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
12087         if (descriptors_constr.datalen > 0)
12088                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12089         else
12090                 descriptors_constr.data = NULL;
12091         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
12092         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
12093                 int64_t descriptors_conv_27 = descriptors_vals[b];
12094                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
12095                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
12096                 descriptors_constr.data[b] = descriptors_conv_27_conv;
12097         }
12098         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
12099         LDKCVec_TxOutZ outputs_constr;
12100         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
12101         if (outputs_constr.datalen > 0)
12102                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
12103         else
12104                 outputs_constr.data = NULL;
12105         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
12106         for (size_t h = 0; h < outputs_constr.datalen; h++) {
12107                 int64_t outputs_conv_7 = outputs_vals[h];
12108                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
12109                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
12110                 outputs_constr.data[h] = outputs_conv_7_conv;
12111         }
12112         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
12113         LDKCVec_u8Z change_destination_script_ref;
12114         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
12115         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
12116         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
12117         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
12118         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
12119         return (long)ret_conv;
12120 }
12121
12122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
12123         LDKKeysManager this_arg_conv;
12124         this_arg_conv.inner = (void*)(this_arg & (~1));
12125         this_arg_conv.is_owned = false;
12126         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
12127         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
12128         return (long)ret;
12129 }
12130
12131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12132         LDKChannelManager this_obj_conv;
12133         this_obj_conv.inner = (void*)(this_obj & (~1));
12134         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12135         ChannelManager_free(this_obj_conv);
12136 }
12137
12138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12139         LDKChainParameters this_obj_conv;
12140         this_obj_conv.inner = (void*)(this_obj & (~1));
12141         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12142         ChainParameters_free(this_obj_conv);
12143 }
12144
12145 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
12146         LDKChainParameters this_ptr_conv;
12147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12148         this_ptr_conv.is_owned = false;
12149         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
12150         return ret_conv;
12151 }
12152
12153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
12154         LDKChainParameters this_ptr_conv;
12155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12156         this_ptr_conv.is_owned = false;
12157         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
12158         ChainParameters_set_network(&this_ptr_conv, val_conv);
12159 }
12160
12161 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1latest_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
12162         LDKChainParameters this_ptr_conv;
12163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12164         this_ptr_conv.is_owned = false;
12165         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12166         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChainParameters_get_latest_hash(&this_ptr_conv));
12167         return ret_arr;
12168 }
12169
12170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1latest_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12171         LDKChainParameters this_ptr_conv;
12172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12173         this_ptr_conv.is_owned = false;
12174         LDKThirtyTwoBytes val_ref;
12175         CHECK((*env)->GetArrayLength(env, val) == 32);
12176         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12177         ChainParameters_set_latest_hash(&this_ptr_conv, val_ref);
12178 }
12179
12180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1latest_1height(JNIEnv *env, jclass clz, int64_t this_ptr) {
12181         LDKChainParameters this_ptr_conv;
12182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12183         this_ptr_conv.is_owned = false;
12184         int64_t ret_val = ChainParameters_get_latest_height(&this_ptr_conv);
12185         return ret_val;
12186 }
12187
12188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1latest_1height(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12189         LDKChainParameters this_ptr_conv;
12190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12191         this_ptr_conv.is_owned = false;
12192         ChainParameters_set_latest_height(&this_ptr_conv, val);
12193 }
12194
12195 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) {
12196         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
12197         LDKThirtyTwoBytes latest_hash_arg_ref;
12198         CHECK((*env)->GetArrayLength(env, latest_hash_arg) == 32);
12199         (*env)->GetByteArrayRegion(env, latest_hash_arg, 0, 32, latest_hash_arg_ref.data);
12200         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, latest_hash_arg_ref, latest_height_arg);
12201         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12202         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12203         long ret_ref = (long)ret_var.inner;
12204         if (ret_var.is_owned) {
12205                 ret_ref |= 1;
12206         }
12207         return ret_ref;
12208 }
12209
12210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12211         LDKChannelDetails this_obj_conv;
12212         this_obj_conv.inner = (void*)(this_obj & (~1));
12213         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12214         ChannelDetails_free(this_obj_conv);
12215 }
12216
12217 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12218         LDKChannelDetails this_ptr_conv;
12219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12220         this_ptr_conv.is_owned = false;
12221         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12222         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
12223         return ret_arr;
12224 }
12225
12226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12227         LDKChannelDetails this_ptr_conv;
12228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12229         this_ptr_conv.is_owned = false;
12230         LDKThirtyTwoBytes val_ref;
12231         CHECK((*env)->GetArrayLength(env, val) == 32);
12232         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12233         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
12234 }
12235
12236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12237         LDKChannelDetails this_ptr_conv;
12238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12239         this_ptr_conv.is_owned = false;
12240         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12241         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
12242         long ret_ref = (long)ret_copy;
12243         return ret_ref;
12244 }
12245
12246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12247         LDKChannelDetails this_ptr_conv;
12248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12249         this_ptr_conv.is_owned = false;
12250         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
12251         FREE((void*)val);
12252         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
12253 }
12254
12255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12256         LDKChannelDetails this_ptr_conv;
12257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12258         this_ptr_conv.is_owned = false;
12259         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
12260         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form);
12261         return ret_arr;
12262 }
12263
12264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12265         LDKChannelDetails this_ptr_conv;
12266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12267         this_ptr_conv.is_owned = false;
12268         LDKPublicKey val_ref;
12269         CHECK((*env)->GetArrayLength(env, val) == 33);
12270         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12271         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
12272 }
12273
12274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
12275         LDKChannelDetails this_ptr_conv;
12276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12277         this_ptr_conv.is_owned = false;
12278         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
12279         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12280         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12281         long ret_ref = (long)ret_var.inner;
12282         if (ret_var.is_owned) {
12283                 ret_ref |= 1;
12284         }
12285         return ret_ref;
12286 }
12287
12288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12289         LDKChannelDetails this_ptr_conv;
12290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12291         this_ptr_conv.is_owned = false;
12292         LDKInitFeatures val_conv;
12293         val_conv.inner = (void*)(val & (~1));
12294         val_conv.is_owned = (val & 1) || (val == 0);
12295         val_conv = InitFeatures_clone(&val_conv);
12296         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
12297 }
12298
12299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12300         LDKChannelDetails this_ptr_conv;
12301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12302         this_ptr_conv.is_owned = false;
12303         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
12304         return ret_val;
12305 }
12306
12307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12308         LDKChannelDetails this_ptr_conv;
12309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12310         this_ptr_conv.is_owned = false;
12311         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
12312 }
12313
12314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12315         LDKChannelDetails this_ptr_conv;
12316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12317         this_ptr_conv.is_owned = false;
12318         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
12319         return ret_val;
12320 }
12321
12322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12323         LDKChannelDetails this_ptr_conv;
12324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12325         this_ptr_conv.is_owned = false;
12326         ChannelDetails_set_user_id(&this_ptr_conv, val);
12327 }
12328
12329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
12330         LDKChannelDetails this_ptr_conv;
12331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12332         this_ptr_conv.is_owned = false;
12333         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
12334         return ret_val;
12335 }
12336
12337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12338         LDKChannelDetails this_ptr_conv;
12339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12340         this_ptr_conv.is_owned = false;
12341         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
12342 }
12343
12344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
12345         LDKChannelDetails this_ptr_conv;
12346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12347         this_ptr_conv.is_owned = false;
12348         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
12349         return ret_val;
12350 }
12351
12352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12353         LDKChannelDetails this_ptr_conv;
12354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12355         this_ptr_conv.is_owned = false;
12356         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
12357 }
12358
12359 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1live(JNIEnv *env, jclass clz, int64_t this_ptr) {
12360         LDKChannelDetails this_ptr_conv;
12361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12362         this_ptr_conv.is_owned = false;
12363         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
12364         return ret_val;
12365 }
12366
12367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1live(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
12368         LDKChannelDetails this_ptr_conv;
12369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12370         this_ptr_conv.is_owned = false;
12371         ChannelDetails_set_is_live(&this_ptr_conv, val);
12372 }
12373
12374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12375         LDKChannelDetails orig_conv;
12376         orig_conv.inner = (void*)(orig & (~1));
12377         orig_conv.is_owned = false;
12378         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
12379         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12380         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12381         long ret_ref = (long)ret_var.inner;
12382         if (ret_var.is_owned) {
12383                 ret_ref |= 1;
12384         }
12385         return ret_ref;
12386 }
12387
12388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12389         if ((this_ptr & 1) != 0) return;
12390         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
12391         FREE((void*)this_ptr);
12392         PaymentSendFailure_free(this_ptr_conv);
12393 }
12394
12395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12396         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
12397         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
12398         *ret_copy = PaymentSendFailure_clone(orig_conv);
12399         long ret_ref = (long)ret_copy;
12400         return ret_ref;
12401 }
12402
12403 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) {
12404         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
12405         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
12406                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12407                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
12408         }
12409         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
12410         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
12411                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12412                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
12413         }
12414         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
12415         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
12416                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12417                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
12418         }
12419         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12420         if (logger_conv.free == LDKLogger_JCalls_free) {
12421                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12422                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12423         }
12424         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
12425         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
12426                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12427                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
12428         }
12429         LDKUserConfig config_conv;
12430         config_conv.inner = (void*)(config & (~1));
12431         config_conv.is_owned = (config & 1) || (config == 0);
12432         config_conv = UserConfig_clone(&config_conv);
12433         LDKChainParameters params_conv;
12434         params_conv.inner = (void*)(params & (~1));
12435         params_conv.is_owned = (params & 1) || (params == 0);
12436         // Warning: we need a move here but no clone is available for LDKChainParameters
12437         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
12438         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12439         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12440         long ret_ref = (long)ret_var.inner;
12441         if (ret_var.is_owned) {
12442                 ret_ref |= 1;
12443         }
12444         return ret_ref;
12445 }
12446
12447 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) {
12448         LDKChannelManager this_arg_conv;
12449         this_arg_conv.inner = (void*)(this_arg & (~1));
12450         this_arg_conv.is_owned = false;
12451         LDKPublicKey their_network_key_ref;
12452         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
12453         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
12454         LDKUserConfig override_config_conv;
12455         override_config_conv.inner = (void*)(override_config & (~1));
12456         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
12457         override_config_conv = UserConfig_clone(&override_config_conv);
12458         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
12459         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
12460         return (long)ret_conv;
12461 }
12462
12463 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
12464         LDKChannelManager this_arg_conv;
12465         this_arg_conv.inner = (void*)(this_arg & (~1));
12466         this_arg_conv.is_owned = false;
12467         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
12468         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12469         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12470         for (size_t q = 0; q < ret_var.datalen; q++) {
12471                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
12472                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12473                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12474                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
12475                 if (ret_conv_16_var.is_owned) {
12476                         ret_conv_16_ref |= 1;
12477                 }
12478                 ret_arr_ptr[q] = ret_conv_16_ref;
12479         }
12480         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12481         FREE(ret_var.data);
12482         return ret_arr;
12483 }
12484
12485 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
12486         LDKChannelManager this_arg_conv;
12487         this_arg_conv.inner = (void*)(this_arg & (~1));
12488         this_arg_conv.is_owned = false;
12489         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
12490         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12491         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12492         for (size_t q = 0; q < ret_var.datalen; q++) {
12493                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
12494                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12495                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12496                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
12497                 if (ret_conv_16_var.is_owned) {
12498                         ret_conv_16_ref |= 1;
12499                 }
12500                 ret_arr_ptr[q] = ret_conv_16_ref;
12501         }
12502         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12503         FREE(ret_var.data);
12504         return ret_arr;
12505 }
12506
12507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
12508         LDKChannelManager this_arg_conv;
12509         this_arg_conv.inner = (void*)(this_arg & (~1));
12510         this_arg_conv.is_owned = false;
12511         unsigned char channel_id_arr[32];
12512         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
12513         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
12514         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
12515         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
12516         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
12517         return (long)ret_conv;
12518 }
12519
12520 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) {
12521         LDKChannelManager this_arg_conv;
12522         this_arg_conv.inner = (void*)(this_arg & (~1));
12523         this_arg_conv.is_owned = false;
12524         unsigned char channel_id_arr[32];
12525         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
12526         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
12527         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
12528         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
12529         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
12530         return (long)ret_conv;
12531 }
12532
12533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
12534         LDKChannelManager this_arg_conv;
12535         this_arg_conv.inner = (void*)(this_arg & (~1));
12536         this_arg_conv.is_owned = false;
12537         ChannelManager_force_close_all_channels(&this_arg_conv);
12538 }
12539
12540 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) {
12541         LDKChannelManager this_arg_conv;
12542         this_arg_conv.inner = (void*)(this_arg & (~1));
12543         this_arg_conv.is_owned = false;
12544         LDKRoute route_conv;
12545         route_conv.inner = (void*)(route & (~1));
12546         route_conv.is_owned = false;
12547         LDKThirtyTwoBytes payment_hash_ref;
12548         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
12549         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
12550         LDKThirtyTwoBytes payment_secret_ref;
12551         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
12552         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
12553         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
12554         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
12555         return (long)ret_conv;
12556 }
12557
12558 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) {
12559         LDKChannelManager this_arg_conv;
12560         this_arg_conv.inner = (void*)(this_arg & (~1));
12561         this_arg_conv.is_owned = false;
12562         unsigned char temporary_channel_id_arr[32];
12563         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
12564         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
12565         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
12566         LDKOutPoint funding_txo_conv;
12567         funding_txo_conv.inner = (void*)(funding_txo & (~1));
12568         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
12569         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
12570         ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
12571 }
12572
12573 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) {
12574         LDKChannelManager this_arg_conv;
12575         this_arg_conv.inner = (void*)(this_arg & (~1));
12576         this_arg_conv.is_owned = false;
12577         LDKThreeBytes rgb_ref;
12578         CHECK((*env)->GetArrayLength(env, rgb) == 3);
12579         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
12580         LDKThirtyTwoBytes alias_ref;
12581         CHECK((*env)->GetArrayLength(env, alias) == 32);
12582         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
12583         LDKCVec_NetAddressZ addresses_constr;
12584         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
12585         if (addresses_constr.datalen > 0)
12586                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12587         else
12588                 addresses_constr.data = NULL;
12589         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
12590         for (size_t m = 0; m < addresses_constr.datalen; m++) {
12591                 int64_t addresses_conv_12 = addresses_vals[m];
12592                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
12593                 FREE((void*)addresses_conv_12);
12594                 addresses_constr.data[m] = addresses_conv_12_conv;
12595         }
12596         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
12597         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
12598 }
12599
12600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
12601         LDKChannelManager this_arg_conv;
12602         this_arg_conv.inner = (void*)(this_arg & (~1));
12603         this_arg_conv.is_owned = false;
12604         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
12605 }
12606
12607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1chan_1freshness_1every_1min(JNIEnv *env, jclass clz, int64_t this_arg) {
12608         LDKChannelManager this_arg_conv;
12609         this_arg_conv.inner = (void*)(this_arg & (~1));
12610         this_arg_conv.is_owned = false;
12611         ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
12612 }
12613
12614 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) {
12615         LDKChannelManager this_arg_conv;
12616         this_arg_conv.inner = (void*)(this_arg & (~1));
12617         this_arg_conv.is_owned = false;
12618         unsigned char payment_hash_arr[32];
12619         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
12620         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
12621         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
12622         LDKThirtyTwoBytes payment_secret_ref;
12623         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
12624         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
12625         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
12626         return ret_val;
12627 }
12628
12629 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) {
12630         LDKChannelManager this_arg_conv;
12631         this_arg_conv.inner = (void*)(this_arg & (~1));
12632         this_arg_conv.is_owned = false;
12633         LDKThirtyTwoBytes payment_preimage_ref;
12634         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
12635         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
12636         LDKThirtyTwoBytes payment_secret_ref;
12637         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
12638         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
12639         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
12640         return ret_val;
12641 }
12642
12643 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
12644         LDKChannelManager this_arg_conv;
12645         this_arg_conv.inner = (void*)(this_arg & (~1));
12646         this_arg_conv.is_owned = false;
12647         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
12648         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
12649         return ret_arr;
12650 }
12651
12652 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) {
12653         LDKChannelManager this_arg_conv;
12654         this_arg_conv.inner = (void*)(this_arg & (~1));
12655         this_arg_conv.is_owned = false;
12656         LDKOutPoint funding_txo_conv;
12657         funding_txo_conv.inner = (void*)(funding_txo & (~1));
12658         funding_txo_conv.is_owned = false;
12659         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
12660 }
12661
12662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
12663         LDKChannelManager this_arg_conv;
12664         this_arg_conv.inner = (void*)(this_arg & (~1));
12665         this_arg_conv.is_owned = false;
12666         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
12667         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
12668         return (long)ret;
12669 }
12670
12671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
12672         LDKChannelManager this_arg_conv;
12673         this_arg_conv.inner = (void*)(this_arg & (~1));
12674         this_arg_conv.is_owned = false;
12675         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
12676         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
12677         return (long)ret;
12678 }
12679
12680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
12681         LDKChannelManager this_arg_conv;
12682         this_arg_conv.inner = (void*)(this_arg & (~1));
12683         this_arg_conv.is_owned = false;
12684         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
12685         *ret = ChannelManager_as_Listen(&this_arg_conv);
12686         return (long)ret;
12687 }
12688
12689 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) {
12690         LDKChannelManager this_arg_conv;
12691         this_arg_conv.inner = (void*)(this_arg & (~1));
12692         this_arg_conv.is_owned = false;
12693         unsigned char header_arr[80];
12694         CHECK((*env)->GetArrayLength(env, header) == 80);
12695         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12696         unsigned char (*header_ref)[80] = &header_arr;
12697         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12698         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
12699         if (txdata_constr.datalen > 0)
12700                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12701         else
12702                 txdata_constr.data = NULL;
12703         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
12704         for (size_t y = 0; y < txdata_constr.datalen; y++) {
12705                 int64_t txdata_conv_24 = txdata_vals[y];
12706                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
12707                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
12708                 txdata_constr.data[y] = txdata_conv_24_conv;
12709         }
12710         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
12711         ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
12712 }
12713
12714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header) {
12715         LDKChannelManager this_arg_conv;
12716         this_arg_conv.inner = (void*)(this_arg & (~1));
12717         this_arg_conv.is_owned = false;
12718         unsigned char header_arr[80];
12719         CHECK((*env)->GetArrayLength(env, header) == 80);
12720         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12721         unsigned char (*header_ref)[80] = &header_arr;
12722         ChannelManager_block_disconnected(&this_arg_conv, header_ref);
12723 }
12724
12725 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) {
12726         LDKChannelManager this_arg_conv;
12727         this_arg_conv.inner = (void*)(this_arg & (~1));
12728         this_arg_conv.is_owned = false;
12729         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
12730         return ret_val;
12731 }
12732
12733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
12734         LDKChannelManager this_arg_conv;
12735         this_arg_conv.inner = (void*)(this_arg & (~1));
12736         this_arg_conv.is_owned = false;
12737         ChannelManager_await_persistable_update(&this_arg_conv);
12738 }
12739
12740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
12741         LDKChannelManager this_arg_conv;
12742         this_arg_conv.inner = (void*)(this_arg & (~1));
12743         this_arg_conv.is_owned = false;
12744         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
12745         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
12746         return (long)ret;
12747 }
12748
12749 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
12750         LDKChannelManager obj_conv;
12751         obj_conv.inner = (void*)(obj & (~1));
12752         obj_conv.is_owned = false;
12753         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
12754         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
12755         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
12756         CVec_u8Z_free(ret_var);
12757         return ret_arr;
12758 }
12759
12760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12761         LDKChannelManagerReadArgs this_obj_conv;
12762         this_obj_conv.inner = (void*)(this_obj & (~1));
12763         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12764         ChannelManagerReadArgs_free(this_obj_conv);
12765 }
12766
12767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
12768         LDKChannelManagerReadArgs this_ptr_conv;
12769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12770         this_ptr_conv.is_owned = false;
12771         long ret_ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
12772         return ret_ret;
12773 }
12774
12775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12776         LDKChannelManagerReadArgs this_ptr_conv;
12777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12778         this_ptr_conv.is_owned = false;
12779         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
12780         if (val_conv.free == LDKKeysInterface_JCalls_free) {
12781                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12782                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
12783         }
12784         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
12785 }
12786
12787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
12788         LDKChannelManagerReadArgs this_ptr_conv;
12789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12790         this_ptr_conv.is_owned = false;
12791         long ret_ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
12792         return ret_ret;
12793 }
12794
12795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12796         LDKChannelManagerReadArgs this_ptr_conv;
12797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12798         this_ptr_conv.is_owned = false;
12799         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
12800         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
12801                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12802                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
12803         }
12804         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
12805 }
12806
12807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
12808         LDKChannelManagerReadArgs this_ptr_conv;
12809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12810         this_ptr_conv.is_owned = false;
12811         long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
12812         return ret_ret;
12813 }
12814
12815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12816         LDKChannelManagerReadArgs this_ptr_conv;
12817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12818         this_ptr_conv.is_owned = false;
12819         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
12820         if (val_conv.free == LDKWatch_JCalls_free) {
12821                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12822                 LDKWatch_JCalls_clone(val_conv.this_arg);
12823         }
12824         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
12825 }
12826
12827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
12828         LDKChannelManagerReadArgs this_ptr_conv;
12829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12830         this_ptr_conv.is_owned = false;
12831         long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
12832         return ret_ret;
12833 }
12834
12835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12836         LDKChannelManagerReadArgs this_ptr_conv;
12837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12838         this_ptr_conv.is_owned = false;
12839         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
12840         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
12841                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12842                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
12843         }
12844         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
12845 }
12846
12847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
12848         LDKChannelManagerReadArgs this_ptr_conv;
12849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12850         this_ptr_conv.is_owned = false;
12851         long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
12852         return ret_ret;
12853 }
12854
12855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12856         LDKChannelManagerReadArgs this_ptr_conv;
12857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12858         this_ptr_conv.is_owned = false;
12859         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
12860         if (val_conv.free == LDKLogger_JCalls_free) {
12861                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12862                 LDKLogger_JCalls_clone(val_conv.this_arg);
12863         }
12864         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
12865 }
12866
12867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
12868         LDKChannelManagerReadArgs this_ptr_conv;
12869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12870         this_ptr_conv.is_owned = false;
12871         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
12872         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12873         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12874         long ret_ref = (long)ret_var.inner;
12875         if (ret_var.is_owned) {
12876                 ret_ref |= 1;
12877         }
12878         return ret_ref;
12879 }
12880
12881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12882         LDKChannelManagerReadArgs this_ptr_conv;
12883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12884         this_ptr_conv.is_owned = false;
12885         LDKUserConfig val_conv;
12886         val_conv.inner = (void*)(val & (~1));
12887         val_conv.is_owned = (val & 1) || (val == 0);
12888         val_conv = UserConfig_clone(&val_conv);
12889         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
12890 }
12891
12892 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) {
12893         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
12894         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
12895                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12896                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
12897         }
12898         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12899         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
12900                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12901                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
12902         }
12903         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
12904         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
12905                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12906                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
12907         }
12908         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
12909         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
12910                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12911                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
12912         }
12913         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12914         if (logger_conv.free == LDKLogger_JCalls_free) {
12915                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12916                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12917         }
12918         LDKUserConfig default_config_conv;
12919         default_config_conv.inner = (void*)(default_config & (~1));
12920         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
12921         default_config_conv = UserConfig_clone(&default_config_conv);
12922         LDKCVec_ChannelMonitorZ channel_monitors_constr;
12923         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
12924         if (channel_monitors_constr.datalen > 0)
12925                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
12926         else
12927                 channel_monitors_constr.data = NULL;
12928         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
12929         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
12930                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
12931                 LDKChannelMonitor channel_monitors_conv_16_conv;
12932                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
12933                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
12934                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
12935         }
12936         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
12937         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);
12938         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12939         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12940         long ret_ref = (long)ret_var.inner;
12941         if (ret_var.is_owned) {
12942                 ret_ref |= 1;
12943         }
12944         return ret_ref;
12945 }
12946
12947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
12948         LDKu8slice ser_ref;
12949         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
12950         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
12951         LDKChannelManagerReadArgs arg_conv;
12952         arg_conv.inner = (void*)(arg & (~1));
12953         arg_conv.is_owned = (arg & 1) || (arg == 0);
12954         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
12955         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
12956         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
12957         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
12958         return (long)ret_conv;
12959 }
12960
12961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12962         LDKDecodeError this_obj_conv;
12963         this_obj_conv.inner = (void*)(this_obj & (~1));
12964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12965         DecodeError_free(this_obj_conv);
12966 }
12967
12968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12969         LDKDecodeError orig_conv;
12970         orig_conv.inner = (void*)(orig & (~1));
12971         orig_conv.is_owned = false;
12972         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
12973         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12974         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12975         long ret_ref = (long)ret_var.inner;
12976         if (ret_var.is_owned) {
12977                 ret_ref |= 1;
12978         }
12979         return ret_ref;
12980 }
12981
12982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12983         LDKInit this_obj_conv;
12984         this_obj_conv.inner = (void*)(this_obj & (~1));
12985         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12986         Init_free(this_obj_conv);
12987 }
12988
12989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
12990         LDKInit this_ptr_conv;
12991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12992         this_ptr_conv.is_owned = false;
12993         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
12994         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12995         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12996         long ret_ref = (long)ret_var.inner;
12997         if (ret_var.is_owned) {
12998                 ret_ref |= 1;
12999         }
13000         return ret_ref;
13001 }
13002
13003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13004         LDKInit this_ptr_conv;
13005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13006         this_ptr_conv.is_owned = false;
13007         LDKInitFeatures val_conv;
13008         val_conv.inner = (void*)(val & (~1));
13009         val_conv.is_owned = (val & 1) || (val == 0);
13010         val_conv = InitFeatures_clone(&val_conv);
13011         Init_set_features(&this_ptr_conv, val_conv);
13012 }
13013
13014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
13015         LDKInitFeatures features_arg_conv;
13016         features_arg_conv.inner = (void*)(features_arg & (~1));
13017         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
13018         features_arg_conv = InitFeatures_clone(&features_arg_conv);
13019         LDKInit ret_var = Init_new(features_arg_conv);
13020         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13021         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13022         long ret_ref = (long)ret_var.inner;
13023         if (ret_var.is_owned) {
13024                 ret_ref |= 1;
13025         }
13026         return ret_ref;
13027 }
13028
13029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13030         LDKInit orig_conv;
13031         orig_conv.inner = (void*)(orig & (~1));
13032         orig_conv.is_owned = false;
13033         LDKInit ret_var = Init_clone(&orig_conv);
13034         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13035         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13036         long ret_ref = (long)ret_var.inner;
13037         if (ret_var.is_owned) {
13038                 ret_ref |= 1;
13039         }
13040         return ret_ref;
13041 }
13042
13043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13044         LDKErrorMessage this_obj_conv;
13045         this_obj_conv.inner = (void*)(this_obj & (~1));
13046         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13047         ErrorMessage_free(this_obj_conv);
13048 }
13049
13050 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13051         LDKErrorMessage this_ptr_conv;
13052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13053         this_ptr_conv.is_owned = false;
13054         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13055         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
13056         return ret_arr;
13057 }
13058
13059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13060         LDKErrorMessage this_ptr_conv;
13061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13062         this_ptr_conv.is_owned = false;
13063         LDKThirtyTwoBytes val_ref;
13064         CHECK((*env)->GetArrayLength(env, val) == 32);
13065         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13066         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
13067 }
13068
13069 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
13070         LDKErrorMessage this_ptr_conv;
13071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13072         this_ptr_conv.is_owned = false;
13073         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
13074         jstring _conv = str_ref_to_java(env, _str.chars, _str.len);
13075         return _conv;
13076 }
13077
13078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13079         LDKErrorMessage this_ptr_conv;
13080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13081         this_ptr_conv.is_owned = false;
13082         LDKCVec_u8Z val_ref;
13083         val_ref.datalen = (*env)->GetArrayLength(env, val);
13084         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
13085         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
13086         ErrorMessage_set_data(&this_ptr_conv, val_ref);
13087 }
13088
13089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray data_arg) {
13090         LDKThirtyTwoBytes channel_id_arg_ref;
13091         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13092         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13093         LDKCVec_u8Z data_arg_ref;
13094         data_arg_ref.datalen = (*env)->GetArrayLength(env, data_arg);
13095         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
13096         (*env)->GetByteArrayRegion(env, data_arg, 0, data_arg_ref.datalen, data_arg_ref.data);
13097         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
13098         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13099         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13100         long ret_ref = (long)ret_var.inner;
13101         if (ret_var.is_owned) {
13102                 ret_ref |= 1;
13103         }
13104         return ret_ref;
13105 }
13106
13107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13108         LDKErrorMessage orig_conv;
13109         orig_conv.inner = (void*)(orig & (~1));
13110         orig_conv.is_owned = false;
13111         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
13112         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13113         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13114         long ret_ref = (long)ret_var.inner;
13115         if (ret_var.is_owned) {
13116                 ret_ref |= 1;
13117         }
13118         return ret_ref;
13119 }
13120
13121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13122         LDKPing this_obj_conv;
13123         this_obj_conv.inner = (void*)(this_obj & (~1));
13124         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13125         Ping_free(this_obj_conv);
13126 }
13127
13128 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
13129         LDKPing this_ptr_conv;
13130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13131         this_ptr_conv.is_owned = false;
13132         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
13133         return ret_val;
13134 }
13135
13136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13137         LDKPing this_ptr_conv;
13138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13139         this_ptr_conv.is_owned = false;
13140         Ping_set_ponglen(&this_ptr_conv, val);
13141 }
13142
13143 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
13144         LDKPing this_ptr_conv;
13145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13146         this_ptr_conv.is_owned = false;
13147         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
13148         return ret_val;
13149 }
13150
13151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13152         LDKPing this_ptr_conv;
13153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13154         this_ptr_conv.is_owned = false;
13155         Ping_set_byteslen(&this_ptr_conv, val);
13156 }
13157
13158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
13159         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
13160         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13161         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13162         long ret_ref = (long)ret_var.inner;
13163         if (ret_var.is_owned) {
13164                 ret_ref |= 1;
13165         }
13166         return ret_ref;
13167 }
13168
13169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13170         LDKPing orig_conv;
13171         orig_conv.inner = (void*)(orig & (~1));
13172         orig_conv.is_owned = false;
13173         LDKPing ret_var = Ping_clone(&orig_conv);
13174         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13175         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13176         long ret_ref = (long)ret_var.inner;
13177         if (ret_var.is_owned) {
13178                 ret_ref |= 1;
13179         }
13180         return ret_ref;
13181 }
13182
13183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13184         LDKPong this_obj_conv;
13185         this_obj_conv.inner = (void*)(this_obj & (~1));
13186         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13187         Pong_free(this_obj_conv);
13188 }
13189
13190 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
13191         LDKPong this_ptr_conv;
13192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13193         this_ptr_conv.is_owned = false;
13194         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
13195         return ret_val;
13196 }
13197
13198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13199         LDKPong this_ptr_conv;
13200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13201         this_ptr_conv.is_owned = false;
13202         Pong_set_byteslen(&this_ptr_conv, val);
13203 }
13204
13205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
13206         LDKPong ret_var = Pong_new(byteslen_arg);
13207         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13208         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13209         long ret_ref = (long)ret_var.inner;
13210         if (ret_var.is_owned) {
13211                 ret_ref |= 1;
13212         }
13213         return ret_ref;
13214 }
13215
13216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13217         LDKPong orig_conv;
13218         orig_conv.inner = (void*)(orig & (~1));
13219         orig_conv.is_owned = false;
13220         LDKPong ret_var = Pong_clone(&orig_conv);
13221         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13222         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13223         long ret_ref = (long)ret_var.inner;
13224         if (ret_var.is_owned) {
13225                 ret_ref |= 1;
13226         }
13227         return ret_ref;
13228 }
13229
13230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13231         LDKOpenChannel this_obj_conv;
13232         this_obj_conv.inner = (void*)(this_obj & (~1));
13233         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13234         OpenChannel_free(this_obj_conv);
13235 }
13236
13237 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
13238         LDKOpenChannel this_ptr_conv;
13239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13240         this_ptr_conv.is_owned = false;
13241         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13242         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
13243         return ret_arr;
13244 }
13245
13246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13247         LDKOpenChannel this_ptr_conv;
13248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13249         this_ptr_conv.is_owned = false;
13250         LDKThirtyTwoBytes val_ref;
13251         CHECK((*env)->GetArrayLength(env, val) == 32);
13252         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13253         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
13254 }
13255
13256 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13257         LDKOpenChannel this_ptr_conv;
13258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13259         this_ptr_conv.is_owned = false;
13260         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13261         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
13262         return ret_arr;
13263 }
13264
13265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13266         LDKOpenChannel this_ptr_conv;
13267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13268         this_ptr_conv.is_owned = false;
13269         LDKThirtyTwoBytes val_ref;
13270         CHECK((*env)->GetArrayLength(env, val) == 32);
13271         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13272         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
13273 }
13274
13275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13276         LDKOpenChannel this_ptr_conv;
13277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13278         this_ptr_conv.is_owned = false;
13279         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
13280         return ret_val;
13281 }
13282
13283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13284         LDKOpenChannel this_ptr_conv;
13285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13286         this_ptr_conv.is_owned = false;
13287         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
13288 }
13289
13290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13291         LDKOpenChannel this_ptr_conv;
13292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13293         this_ptr_conv.is_owned = false;
13294         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
13295         return ret_val;
13296 }
13297
13298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13299         LDKOpenChannel this_ptr_conv;
13300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13301         this_ptr_conv.is_owned = false;
13302         OpenChannel_set_push_msat(&this_ptr_conv, val);
13303 }
13304
13305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13306         LDKOpenChannel this_ptr_conv;
13307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13308         this_ptr_conv.is_owned = false;
13309         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
13310         return ret_val;
13311 }
13312
13313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13314         LDKOpenChannel this_ptr_conv;
13315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13316         this_ptr_conv.is_owned = false;
13317         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
13318 }
13319
13320 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) {
13321         LDKOpenChannel this_ptr_conv;
13322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13323         this_ptr_conv.is_owned = false;
13324         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
13325         return ret_val;
13326 }
13327
13328 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) {
13329         LDKOpenChannel this_ptr_conv;
13330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13331         this_ptr_conv.is_owned = false;
13332         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13333 }
13334
13335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13336         LDKOpenChannel this_ptr_conv;
13337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13338         this_ptr_conv.is_owned = false;
13339         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
13340         return ret_val;
13341 }
13342
13343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13344         LDKOpenChannel this_ptr_conv;
13345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13346         this_ptr_conv.is_owned = false;
13347         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
13348 }
13349
13350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13351         LDKOpenChannel this_ptr_conv;
13352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13353         this_ptr_conv.is_owned = false;
13354         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
13355         return ret_val;
13356 }
13357
13358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13359         LDKOpenChannel this_ptr_conv;
13360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13361         this_ptr_conv.is_owned = false;
13362         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
13363 }
13364
13365 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
13366         LDKOpenChannel this_ptr_conv;
13367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13368         this_ptr_conv.is_owned = false;
13369         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
13370         return ret_val;
13371 }
13372
13373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13374         LDKOpenChannel this_ptr_conv;
13375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13376         this_ptr_conv.is_owned = false;
13377         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
13378 }
13379
13380 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13381         LDKOpenChannel this_ptr_conv;
13382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13383         this_ptr_conv.is_owned = false;
13384         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
13385         return ret_val;
13386 }
13387
13388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13389         LDKOpenChannel this_ptr_conv;
13390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13391         this_ptr_conv.is_owned = false;
13392         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
13393 }
13394
13395 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13396         LDKOpenChannel this_ptr_conv;
13397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13398         this_ptr_conv.is_owned = false;
13399         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
13400         return ret_val;
13401 }
13402
13403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13404         LDKOpenChannel this_ptr_conv;
13405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13406         this_ptr_conv.is_owned = false;
13407         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
13408 }
13409
13410 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13411         LDKOpenChannel this_ptr_conv;
13412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13413         this_ptr_conv.is_owned = false;
13414         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13415         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
13416         return ret_arr;
13417 }
13418
13419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13420         LDKOpenChannel this_ptr_conv;
13421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13422         this_ptr_conv.is_owned = false;
13423         LDKPublicKey val_ref;
13424         CHECK((*env)->GetArrayLength(env, val) == 33);
13425         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13426         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
13427 }
13428
13429 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13430         LDKOpenChannel 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, 33);
13434         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
13435         return ret_arr;
13436 }
13437
13438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13439         LDKOpenChannel this_ptr_conv;
13440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13441         this_ptr_conv.is_owned = false;
13442         LDKPublicKey val_ref;
13443         CHECK((*env)->GetArrayLength(env, val) == 33);
13444         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13445         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
13446 }
13447
13448 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13449         LDKOpenChannel this_ptr_conv;
13450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13451         this_ptr_conv.is_owned = false;
13452         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13453         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
13454         return ret_arr;
13455 }
13456
13457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13458         LDKOpenChannel this_ptr_conv;
13459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13460         this_ptr_conv.is_owned = false;
13461         LDKPublicKey val_ref;
13462         CHECK((*env)->GetArrayLength(env, val) == 33);
13463         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13464         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
13465 }
13466
13467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13468         LDKOpenChannel this_ptr_conv;
13469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13470         this_ptr_conv.is_owned = false;
13471         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13472         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
13473         return ret_arr;
13474 }
13475
13476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13477         LDKOpenChannel this_ptr_conv;
13478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13479         this_ptr_conv.is_owned = false;
13480         LDKPublicKey val_ref;
13481         CHECK((*env)->GetArrayLength(env, val) == 33);
13482         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13483         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
13484 }
13485
13486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13487         LDKOpenChannel this_ptr_conv;
13488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13489         this_ptr_conv.is_owned = false;
13490         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13491         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
13492         return ret_arr;
13493 }
13494
13495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13496         LDKOpenChannel this_ptr_conv;
13497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13498         this_ptr_conv.is_owned = false;
13499         LDKPublicKey val_ref;
13500         CHECK((*env)->GetArrayLength(env, val) == 33);
13501         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13502         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
13503 }
13504
13505 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13506         LDKOpenChannel this_ptr_conv;
13507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13508         this_ptr_conv.is_owned = false;
13509         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13510         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
13511         return ret_arr;
13512 }
13513
13514 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) {
13515         LDKOpenChannel this_ptr_conv;
13516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13517         this_ptr_conv.is_owned = false;
13518         LDKPublicKey val_ref;
13519         CHECK((*env)->GetArrayLength(env, val) == 33);
13520         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13521         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
13522 }
13523
13524 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
13525         LDKOpenChannel this_ptr_conv;
13526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13527         this_ptr_conv.is_owned = false;
13528         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
13529         return ret_val;
13530 }
13531
13532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
13533         LDKOpenChannel this_ptr_conv;
13534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13535         this_ptr_conv.is_owned = false;
13536         OpenChannel_set_channel_flags(&this_ptr_conv, val);
13537 }
13538
13539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13540         LDKOpenChannel orig_conv;
13541         orig_conv.inner = (void*)(orig & (~1));
13542         orig_conv.is_owned = false;
13543         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
13544         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13545         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13546         long ret_ref = (long)ret_var.inner;
13547         if (ret_var.is_owned) {
13548                 ret_ref |= 1;
13549         }
13550         return ret_ref;
13551 }
13552
13553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13554         LDKAcceptChannel this_obj_conv;
13555         this_obj_conv.inner = (void*)(this_obj & (~1));
13556         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13557         AcceptChannel_free(this_obj_conv);
13558 }
13559
13560 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13561         LDKAcceptChannel this_ptr_conv;
13562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13563         this_ptr_conv.is_owned = false;
13564         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13565         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
13566         return ret_arr;
13567 }
13568
13569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13570         LDKAcceptChannel this_ptr_conv;
13571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13572         this_ptr_conv.is_owned = false;
13573         LDKThirtyTwoBytes val_ref;
13574         CHECK((*env)->GetArrayLength(env, val) == 32);
13575         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13576         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
13577 }
13578
13579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13580         LDKAcceptChannel this_ptr_conv;
13581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13582         this_ptr_conv.is_owned = false;
13583         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
13584         return ret_val;
13585 }
13586
13587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13588         LDKAcceptChannel this_ptr_conv;
13589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13590         this_ptr_conv.is_owned = false;
13591         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
13592 }
13593
13594 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) {
13595         LDKAcceptChannel this_ptr_conv;
13596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13597         this_ptr_conv.is_owned = false;
13598         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
13599         return ret_val;
13600 }
13601
13602 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) {
13603         LDKAcceptChannel this_ptr_conv;
13604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13605         this_ptr_conv.is_owned = false;
13606         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13607 }
13608
13609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13610         LDKAcceptChannel this_ptr_conv;
13611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13612         this_ptr_conv.is_owned = false;
13613         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
13614         return ret_val;
13615 }
13616
13617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13618         LDKAcceptChannel this_ptr_conv;
13619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13620         this_ptr_conv.is_owned = false;
13621         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
13622 }
13623
13624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13625         LDKAcceptChannel this_ptr_conv;
13626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13627         this_ptr_conv.is_owned = false;
13628         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
13629         return ret_val;
13630 }
13631
13632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13633         LDKAcceptChannel this_ptr_conv;
13634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13635         this_ptr_conv.is_owned = false;
13636         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
13637 }
13638
13639 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13640         LDKAcceptChannel this_ptr_conv;
13641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13642         this_ptr_conv.is_owned = false;
13643         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
13644         return ret_val;
13645 }
13646
13647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13648         LDKAcceptChannel this_ptr_conv;
13649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13650         this_ptr_conv.is_owned = false;
13651         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
13652 }
13653
13654 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13655         LDKAcceptChannel this_ptr_conv;
13656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13657         this_ptr_conv.is_owned = false;
13658         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
13659         return ret_val;
13660 }
13661
13662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13663         LDKAcceptChannel this_ptr_conv;
13664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13665         this_ptr_conv.is_owned = false;
13666         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
13667 }
13668
13669 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13670         LDKAcceptChannel this_ptr_conv;
13671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13672         this_ptr_conv.is_owned = false;
13673         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
13674         return ret_val;
13675 }
13676
13677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13678         LDKAcceptChannel this_ptr_conv;
13679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13680         this_ptr_conv.is_owned = false;
13681         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
13682 }
13683
13684 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13685         LDKAcceptChannel this_ptr_conv;
13686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13687         this_ptr_conv.is_owned = false;
13688         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13689         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
13690         return ret_arr;
13691 }
13692
13693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13694         LDKAcceptChannel this_ptr_conv;
13695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13696         this_ptr_conv.is_owned = false;
13697         LDKPublicKey val_ref;
13698         CHECK((*env)->GetArrayLength(env, val) == 33);
13699         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13700         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
13701 }
13702
13703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13704         LDKAcceptChannel this_ptr_conv;
13705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13706         this_ptr_conv.is_owned = false;
13707         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13708         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
13709         return ret_arr;
13710 }
13711
13712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13713         LDKAcceptChannel this_ptr_conv;
13714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13715         this_ptr_conv.is_owned = false;
13716         LDKPublicKey val_ref;
13717         CHECK((*env)->GetArrayLength(env, val) == 33);
13718         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13719         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
13720 }
13721
13722 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13723         LDKAcceptChannel this_ptr_conv;
13724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13725         this_ptr_conv.is_owned = false;
13726         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13727         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
13728         return ret_arr;
13729 }
13730
13731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13732         LDKAcceptChannel this_ptr_conv;
13733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13734         this_ptr_conv.is_owned = false;
13735         LDKPublicKey val_ref;
13736         CHECK((*env)->GetArrayLength(env, val) == 33);
13737         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13738         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
13739 }
13740
13741 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13742         LDKAcceptChannel this_ptr_conv;
13743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13744         this_ptr_conv.is_owned = false;
13745         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13746         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
13747         return ret_arr;
13748 }
13749
13750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13751         LDKAcceptChannel this_ptr_conv;
13752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13753         this_ptr_conv.is_owned = false;
13754         LDKPublicKey val_ref;
13755         CHECK((*env)->GetArrayLength(env, val) == 33);
13756         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13757         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
13758 }
13759
13760 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13761         LDKAcceptChannel this_ptr_conv;
13762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13763         this_ptr_conv.is_owned = false;
13764         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13765         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
13766         return ret_arr;
13767 }
13768
13769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13770         LDKAcceptChannel this_ptr_conv;
13771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13772         this_ptr_conv.is_owned = false;
13773         LDKPublicKey val_ref;
13774         CHECK((*env)->GetArrayLength(env, val) == 33);
13775         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13776         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
13777 }
13778
13779 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13780         LDKAcceptChannel this_ptr_conv;
13781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13782         this_ptr_conv.is_owned = false;
13783         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13784         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
13785         return ret_arr;
13786 }
13787
13788 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) {
13789         LDKAcceptChannel this_ptr_conv;
13790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13791         this_ptr_conv.is_owned = false;
13792         LDKPublicKey val_ref;
13793         CHECK((*env)->GetArrayLength(env, val) == 33);
13794         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13795         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
13796 }
13797
13798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13799         LDKAcceptChannel orig_conv;
13800         orig_conv.inner = (void*)(orig & (~1));
13801         orig_conv.is_owned = false;
13802         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
13803         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13804         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13805         long ret_ref = (long)ret_var.inner;
13806         if (ret_var.is_owned) {
13807                 ret_ref |= 1;
13808         }
13809         return ret_ref;
13810 }
13811
13812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13813         LDKFundingCreated this_obj_conv;
13814         this_obj_conv.inner = (void*)(this_obj & (~1));
13815         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13816         FundingCreated_free(this_obj_conv);
13817 }
13818
13819 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13820         LDKFundingCreated this_ptr_conv;
13821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13822         this_ptr_conv.is_owned = false;
13823         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13824         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
13825         return ret_arr;
13826 }
13827
13828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13829         LDKFundingCreated this_ptr_conv;
13830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13831         this_ptr_conv.is_owned = false;
13832         LDKThirtyTwoBytes val_ref;
13833         CHECK((*env)->GetArrayLength(env, val) == 32);
13834         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13835         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
13836 }
13837
13838 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
13839         LDKFundingCreated this_ptr_conv;
13840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13841         this_ptr_conv.is_owned = false;
13842         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13843         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
13844         return ret_arr;
13845 }
13846
13847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13848         LDKFundingCreated this_ptr_conv;
13849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13850         this_ptr_conv.is_owned = false;
13851         LDKThirtyTwoBytes val_ref;
13852         CHECK((*env)->GetArrayLength(env, val) == 32);
13853         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13854         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
13855 }
13856
13857 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
13858         LDKFundingCreated this_ptr_conv;
13859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13860         this_ptr_conv.is_owned = false;
13861         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
13862         return ret_val;
13863 }
13864
13865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13866         LDKFundingCreated this_ptr_conv;
13867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13868         this_ptr_conv.is_owned = false;
13869         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
13870 }
13871
13872 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
13873         LDKFundingCreated this_ptr_conv;
13874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13875         this_ptr_conv.is_owned = false;
13876         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
13877         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
13878         return ret_arr;
13879 }
13880
13881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13882         LDKFundingCreated this_ptr_conv;
13883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13884         this_ptr_conv.is_owned = false;
13885         LDKSignature val_ref;
13886         CHECK((*env)->GetArrayLength(env, val) == 64);
13887         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
13888         FundingCreated_set_signature(&this_ptr_conv, val_ref);
13889 }
13890
13891 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) {
13892         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
13893         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
13894         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
13895         LDKThirtyTwoBytes funding_txid_arg_ref;
13896         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
13897         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
13898         LDKSignature signature_arg_ref;
13899         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
13900         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
13901         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
13902         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13903         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13904         long ret_ref = (long)ret_var.inner;
13905         if (ret_var.is_owned) {
13906                 ret_ref |= 1;
13907         }
13908         return ret_ref;
13909 }
13910
13911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13912         LDKFundingCreated orig_conv;
13913         orig_conv.inner = (void*)(orig & (~1));
13914         orig_conv.is_owned = false;
13915         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
13916         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13917         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13918         long ret_ref = (long)ret_var.inner;
13919         if (ret_var.is_owned) {
13920                 ret_ref |= 1;
13921         }
13922         return ret_ref;
13923 }
13924
13925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13926         LDKFundingSigned this_obj_conv;
13927         this_obj_conv.inner = (void*)(this_obj & (~1));
13928         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13929         FundingSigned_free(this_obj_conv);
13930 }
13931
13932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13933         LDKFundingSigned this_ptr_conv;
13934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13935         this_ptr_conv.is_owned = false;
13936         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13937         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
13938         return ret_arr;
13939 }
13940
13941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13942         LDKFundingSigned this_ptr_conv;
13943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13944         this_ptr_conv.is_owned = false;
13945         LDKThirtyTwoBytes val_ref;
13946         CHECK((*env)->GetArrayLength(env, val) == 32);
13947         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13948         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
13949 }
13950
13951 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
13952         LDKFundingSigned this_ptr_conv;
13953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13954         this_ptr_conv.is_owned = false;
13955         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
13956         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
13957         return ret_arr;
13958 }
13959
13960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13961         LDKFundingSigned this_ptr_conv;
13962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13963         this_ptr_conv.is_owned = false;
13964         LDKSignature val_ref;
13965         CHECK((*env)->GetArrayLength(env, val) == 64);
13966         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
13967         FundingSigned_set_signature(&this_ptr_conv, val_ref);
13968 }
13969
13970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
13971         LDKThirtyTwoBytes channel_id_arg_ref;
13972         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13973         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13974         LDKSignature signature_arg_ref;
13975         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
13976         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
13977         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
13978         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13979         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13980         long ret_ref = (long)ret_var.inner;
13981         if (ret_var.is_owned) {
13982                 ret_ref |= 1;
13983         }
13984         return ret_ref;
13985 }
13986
13987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13988         LDKFundingSigned orig_conv;
13989         orig_conv.inner = (void*)(orig & (~1));
13990         orig_conv.is_owned = false;
13991         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
13992         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13993         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13994         long ret_ref = (long)ret_var.inner;
13995         if (ret_var.is_owned) {
13996                 ret_ref |= 1;
13997         }
13998         return ret_ref;
13999 }
14000
14001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14002         LDKFundingLocked this_obj_conv;
14003         this_obj_conv.inner = (void*)(this_obj & (~1));
14004         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14005         FundingLocked_free(this_obj_conv);
14006 }
14007
14008 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14009         LDKFundingLocked this_ptr_conv;
14010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14011         this_ptr_conv.is_owned = false;
14012         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14013         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
14014         return ret_arr;
14015 }
14016
14017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14018         LDKFundingLocked this_ptr_conv;
14019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14020         this_ptr_conv.is_owned = false;
14021         LDKThirtyTwoBytes val_ref;
14022         CHECK((*env)->GetArrayLength(env, val) == 32);
14023         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14024         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
14025 }
14026
14027 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14028         LDKFundingLocked this_ptr_conv;
14029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14030         this_ptr_conv.is_owned = false;
14031         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14032         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
14033         return ret_arr;
14034 }
14035
14036 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) {
14037         LDKFundingLocked this_ptr_conv;
14038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14039         this_ptr_conv.is_owned = false;
14040         LDKPublicKey val_ref;
14041         CHECK((*env)->GetArrayLength(env, val) == 33);
14042         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14043         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
14044 }
14045
14046 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) {
14047         LDKThirtyTwoBytes channel_id_arg_ref;
14048         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14049         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14050         LDKPublicKey next_per_commitment_point_arg_ref;
14051         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
14052         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
14053         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
14054         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14055         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14056         long ret_ref = (long)ret_var.inner;
14057         if (ret_var.is_owned) {
14058                 ret_ref |= 1;
14059         }
14060         return ret_ref;
14061 }
14062
14063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14064         LDKFundingLocked orig_conv;
14065         orig_conv.inner = (void*)(orig & (~1));
14066         orig_conv.is_owned = false;
14067         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
14068         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14069         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14070         long ret_ref = (long)ret_var.inner;
14071         if (ret_var.is_owned) {
14072                 ret_ref |= 1;
14073         }
14074         return ret_ref;
14075 }
14076
14077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14078         LDKShutdown this_obj_conv;
14079         this_obj_conv.inner = (void*)(this_obj & (~1));
14080         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14081         Shutdown_free(this_obj_conv);
14082 }
14083
14084 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14085         LDKShutdown this_ptr_conv;
14086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14087         this_ptr_conv.is_owned = false;
14088         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14089         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
14090         return ret_arr;
14091 }
14092
14093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14094         LDKShutdown this_ptr_conv;
14095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14096         this_ptr_conv.is_owned = false;
14097         LDKThirtyTwoBytes val_ref;
14098         CHECK((*env)->GetArrayLength(env, val) == 32);
14099         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14100         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
14101 }
14102
14103 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14104         LDKShutdown this_ptr_conv;
14105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14106         this_ptr_conv.is_owned = false;
14107         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
14108         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14109         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14110         return ret_arr;
14111 }
14112
14113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14114         LDKShutdown this_ptr_conv;
14115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14116         this_ptr_conv.is_owned = false;
14117         LDKCVec_u8Z val_ref;
14118         val_ref.datalen = (*env)->GetArrayLength(env, val);
14119         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14120         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
14121         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
14122 }
14123
14124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
14125         LDKThirtyTwoBytes channel_id_arg_ref;
14126         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14127         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14128         LDKCVec_u8Z scriptpubkey_arg_ref;
14129         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
14130         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14131         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
14132         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
14133         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14134         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14135         long ret_ref = (long)ret_var.inner;
14136         if (ret_var.is_owned) {
14137                 ret_ref |= 1;
14138         }
14139         return ret_ref;
14140 }
14141
14142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14143         LDKShutdown orig_conv;
14144         orig_conv.inner = (void*)(orig & (~1));
14145         orig_conv.is_owned = false;
14146         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
14147         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14148         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14149         long ret_ref = (long)ret_var.inner;
14150         if (ret_var.is_owned) {
14151                 ret_ref |= 1;
14152         }
14153         return ret_ref;
14154 }
14155
14156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14157         LDKClosingSigned this_obj_conv;
14158         this_obj_conv.inner = (void*)(this_obj & (~1));
14159         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14160         ClosingSigned_free(this_obj_conv);
14161 }
14162
14163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14164         LDKClosingSigned this_ptr_conv;
14165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14166         this_ptr_conv.is_owned = false;
14167         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14168         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
14169         return ret_arr;
14170 }
14171
14172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14173         LDKClosingSigned this_ptr_conv;
14174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14175         this_ptr_conv.is_owned = false;
14176         LDKThirtyTwoBytes val_ref;
14177         CHECK((*env)->GetArrayLength(env, val) == 32);
14178         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14179         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
14180 }
14181
14182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14183         LDKClosingSigned this_ptr_conv;
14184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14185         this_ptr_conv.is_owned = false;
14186         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
14187         return ret_val;
14188 }
14189
14190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14191         LDKClosingSigned this_ptr_conv;
14192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14193         this_ptr_conv.is_owned = false;
14194         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
14195 }
14196
14197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14198         LDKClosingSigned this_ptr_conv;
14199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14200         this_ptr_conv.is_owned = false;
14201         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14202         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
14203         return ret_arr;
14204 }
14205
14206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14207         LDKClosingSigned this_ptr_conv;
14208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14209         this_ptr_conv.is_owned = false;
14210         LDKSignature val_ref;
14211         CHECK((*env)->GetArrayLength(env, val) == 64);
14212         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14213         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
14214 }
14215
14216 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) {
14217         LDKThirtyTwoBytes channel_id_arg_ref;
14218         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14219         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14220         LDKSignature signature_arg_ref;
14221         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
14222         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
14223         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
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 int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14234         LDKClosingSigned orig_conv;
14235         orig_conv.inner = (void*)(orig & (~1));
14236         orig_conv.is_owned = false;
14237         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
14238         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14239         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14240         long ret_ref = (long)ret_var.inner;
14241         if (ret_var.is_owned) {
14242                 ret_ref |= 1;
14243         }
14244         return ret_ref;
14245 }
14246
14247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14248         LDKUpdateAddHTLC this_obj_conv;
14249         this_obj_conv.inner = (void*)(this_obj & (~1));
14250         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14251         UpdateAddHTLC_free(this_obj_conv);
14252 }
14253
14254 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14255         LDKUpdateAddHTLC this_ptr_conv;
14256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14257         this_ptr_conv.is_owned = false;
14258         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14259         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
14260         return ret_arr;
14261 }
14262
14263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14264         LDKUpdateAddHTLC this_ptr_conv;
14265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14266         this_ptr_conv.is_owned = false;
14267         LDKThirtyTwoBytes val_ref;
14268         CHECK((*env)->GetArrayLength(env, val) == 32);
14269         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14270         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
14271 }
14272
14273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14274         LDKUpdateAddHTLC this_ptr_conv;
14275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14276         this_ptr_conv.is_owned = false;
14277         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
14278         return ret_val;
14279 }
14280
14281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14282         LDKUpdateAddHTLC this_ptr_conv;
14283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14284         this_ptr_conv.is_owned = false;
14285         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
14286 }
14287
14288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14289         LDKUpdateAddHTLC this_ptr_conv;
14290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14291         this_ptr_conv.is_owned = false;
14292         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
14293         return ret_val;
14294 }
14295
14296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14297         LDKUpdateAddHTLC this_ptr_conv;
14298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14299         this_ptr_conv.is_owned = false;
14300         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
14301 }
14302
14303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14304         LDKUpdateAddHTLC this_ptr_conv;
14305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14306         this_ptr_conv.is_owned = false;
14307         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14308         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
14309         return ret_arr;
14310 }
14311
14312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14313         LDKUpdateAddHTLC this_ptr_conv;
14314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14315         this_ptr_conv.is_owned = false;
14316         LDKThirtyTwoBytes val_ref;
14317         CHECK((*env)->GetArrayLength(env, val) == 32);
14318         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14319         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
14320 }
14321
14322 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
14323         LDKUpdateAddHTLC this_ptr_conv;
14324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14325         this_ptr_conv.is_owned = false;
14326         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
14327         return ret_val;
14328 }
14329
14330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14331         LDKUpdateAddHTLC this_ptr_conv;
14332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14333         this_ptr_conv.is_owned = false;
14334         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
14335 }
14336
14337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14338         LDKUpdateAddHTLC orig_conv;
14339         orig_conv.inner = (void*)(orig & (~1));
14340         orig_conv.is_owned = false;
14341         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
14342         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14343         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14344         long ret_ref = (long)ret_var.inner;
14345         if (ret_var.is_owned) {
14346                 ret_ref |= 1;
14347         }
14348         return ret_ref;
14349 }
14350
14351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14352         LDKUpdateFulfillHTLC this_obj_conv;
14353         this_obj_conv.inner = (void*)(this_obj & (~1));
14354         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14355         UpdateFulfillHTLC_free(this_obj_conv);
14356 }
14357
14358 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14359         LDKUpdateFulfillHTLC this_ptr_conv;
14360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14361         this_ptr_conv.is_owned = false;
14362         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14363         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
14364         return ret_arr;
14365 }
14366
14367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14368         LDKUpdateFulfillHTLC this_ptr_conv;
14369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14370         this_ptr_conv.is_owned = false;
14371         LDKThirtyTwoBytes val_ref;
14372         CHECK((*env)->GetArrayLength(env, val) == 32);
14373         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14374         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
14375 }
14376
14377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14378         LDKUpdateFulfillHTLC this_ptr_conv;
14379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14380         this_ptr_conv.is_owned = false;
14381         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
14382         return ret_val;
14383 }
14384
14385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14386         LDKUpdateFulfillHTLC this_ptr_conv;
14387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14388         this_ptr_conv.is_owned = false;
14389         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
14390 }
14391
14392 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
14393         LDKUpdateFulfillHTLC this_ptr_conv;
14394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14395         this_ptr_conv.is_owned = false;
14396         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14397         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
14398         return ret_arr;
14399 }
14400
14401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14402         LDKUpdateFulfillHTLC this_ptr_conv;
14403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14404         this_ptr_conv.is_owned = false;
14405         LDKThirtyTwoBytes val_ref;
14406         CHECK((*env)->GetArrayLength(env, val) == 32);
14407         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14408         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
14409 }
14410
14411 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) {
14412         LDKThirtyTwoBytes channel_id_arg_ref;
14413         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14414         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14415         LDKThirtyTwoBytes payment_preimage_arg_ref;
14416         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
14417         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
14418         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
14419         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14420         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14421         long ret_ref = (long)ret_var.inner;
14422         if (ret_var.is_owned) {
14423                 ret_ref |= 1;
14424         }
14425         return ret_ref;
14426 }
14427
14428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14429         LDKUpdateFulfillHTLC orig_conv;
14430         orig_conv.inner = (void*)(orig & (~1));
14431         orig_conv.is_owned = false;
14432         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
14433         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14434         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14435         long ret_ref = (long)ret_var.inner;
14436         if (ret_var.is_owned) {
14437                 ret_ref |= 1;
14438         }
14439         return ret_ref;
14440 }
14441
14442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14443         LDKUpdateFailHTLC this_obj_conv;
14444         this_obj_conv.inner = (void*)(this_obj & (~1));
14445         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14446         UpdateFailHTLC_free(this_obj_conv);
14447 }
14448
14449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14450         LDKUpdateFailHTLC this_ptr_conv;
14451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14452         this_ptr_conv.is_owned = false;
14453         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14454         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
14455         return ret_arr;
14456 }
14457
14458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14459         LDKUpdateFailHTLC this_ptr_conv;
14460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14461         this_ptr_conv.is_owned = false;
14462         LDKThirtyTwoBytes val_ref;
14463         CHECK((*env)->GetArrayLength(env, val) == 32);
14464         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14465         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
14466 }
14467
14468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14469         LDKUpdateFailHTLC this_ptr_conv;
14470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14471         this_ptr_conv.is_owned = false;
14472         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
14473         return ret_val;
14474 }
14475
14476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14477         LDKUpdateFailHTLC this_ptr_conv;
14478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14479         this_ptr_conv.is_owned = false;
14480         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
14481 }
14482
14483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14484         LDKUpdateFailHTLC orig_conv;
14485         orig_conv.inner = (void*)(orig & (~1));
14486         orig_conv.is_owned = false;
14487         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
14488         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14489         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14490         long ret_ref = (long)ret_var.inner;
14491         if (ret_var.is_owned) {
14492                 ret_ref |= 1;
14493         }
14494         return ret_ref;
14495 }
14496
14497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14498         LDKUpdateFailMalformedHTLC this_obj_conv;
14499         this_obj_conv.inner = (void*)(this_obj & (~1));
14500         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14501         UpdateFailMalformedHTLC_free(this_obj_conv);
14502 }
14503
14504 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14505         LDKUpdateFailMalformedHTLC this_ptr_conv;
14506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14507         this_ptr_conv.is_owned = false;
14508         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14509         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
14510         return ret_arr;
14511 }
14512
14513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14514         LDKUpdateFailMalformedHTLC this_ptr_conv;
14515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14516         this_ptr_conv.is_owned = false;
14517         LDKThirtyTwoBytes val_ref;
14518         CHECK((*env)->GetArrayLength(env, val) == 32);
14519         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14520         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
14521 }
14522
14523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14524         LDKUpdateFailMalformedHTLC this_ptr_conv;
14525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14526         this_ptr_conv.is_owned = false;
14527         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
14528         return ret_val;
14529 }
14530
14531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14532         LDKUpdateFailMalformedHTLC this_ptr_conv;
14533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14534         this_ptr_conv.is_owned = false;
14535         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
14536 }
14537
14538 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
14539         LDKUpdateFailMalformedHTLC this_ptr_conv;
14540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14541         this_ptr_conv.is_owned = false;
14542         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
14543         return ret_val;
14544 }
14545
14546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14547         LDKUpdateFailMalformedHTLC this_ptr_conv;
14548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14549         this_ptr_conv.is_owned = false;
14550         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
14551 }
14552
14553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14554         LDKUpdateFailMalformedHTLC orig_conv;
14555         orig_conv.inner = (void*)(orig & (~1));
14556         orig_conv.is_owned = false;
14557         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
14558         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14559         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14560         long ret_ref = (long)ret_var.inner;
14561         if (ret_var.is_owned) {
14562                 ret_ref |= 1;
14563         }
14564         return ret_ref;
14565 }
14566
14567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14568         LDKCommitmentSigned this_obj_conv;
14569         this_obj_conv.inner = (void*)(this_obj & (~1));
14570         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14571         CommitmentSigned_free(this_obj_conv);
14572 }
14573
14574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14575         LDKCommitmentSigned this_ptr_conv;
14576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14577         this_ptr_conv.is_owned = false;
14578         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14579         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
14580         return ret_arr;
14581 }
14582
14583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14584         LDKCommitmentSigned this_ptr_conv;
14585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14586         this_ptr_conv.is_owned = false;
14587         LDKThirtyTwoBytes val_ref;
14588         CHECK((*env)->GetArrayLength(env, val) == 32);
14589         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14590         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
14591 }
14592
14593 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14594         LDKCommitmentSigned this_ptr_conv;
14595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14596         this_ptr_conv.is_owned = false;
14597         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14598         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
14599         return ret_arr;
14600 }
14601
14602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14603         LDKCommitmentSigned this_ptr_conv;
14604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14605         this_ptr_conv.is_owned = false;
14606         LDKSignature val_ref;
14607         CHECK((*env)->GetArrayLength(env, val) == 64);
14608         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14609         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
14610 }
14611
14612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
14613         LDKCommitmentSigned this_ptr_conv;
14614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14615         this_ptr_conv.is_owned = false;
14616         LDKCVec_SignatureZ val_constr;
14617         val_constr.datalen = (*env)->GetArrayLength(env, val);
14618         if (val_constr.datalen > 0)
14619                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14620         else
14621                 val_constr.data = NULL;
14622         for (size_t i = 0; i < val_constr.datalen; i++) {
14623                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
14624                 LDKSignature val_conv_8_ref;
14625                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
14626                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
14627                 val_constr.data[i] = val_conv_8_ref;
14628         }
14629         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
14630 }
14631
14632 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) {
14633         LDKThirtyTwoBytes channel_id_arg_ref;
14634         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14635         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14636         LDKSignature signature_arg_ref;
14637         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
14638         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
14639         LDKCVec_SignatureZ htlc_signatures_arg_constr;
14640         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
14641         if (htlc_signatures_arg_constr.datalen > 0)
14642                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14643         else
14644                 htlc_signatures_arg_constr.data = NULL;
14645         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
14646                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
14647                 LDKSignature htlc_signatures_arg_conv_8_ref;
14648                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
14649                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
14650                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
14651         }
14652         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
14653         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14654         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14655         long ret_ref = (long)ret_var.inner;
14656         if (ret_var.is_owned) {
14657                 ret_ref |= 1;
14658         }
14659         return ret_ref;
14660 }
14661
14662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14663         LDKCommitmentSigned orig_conv;
14664         orig_conv.inner = (void*)(orig & (~1));
14665         orig_conv.is_owned = false;
14666         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
14667         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14668         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14669         long ret_ref = (long)ret_var.inner;
14670         if (ret_var.is_owned) {
14671                 ret_ref |= 1;
14672         }
14673         return ret_ref;
14674 }
14675
14676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14677         LDKRevokeAndACK this_obj_conv;
14678         this_obj_conv.inner = (void*)(this_obj & (~1));
14679         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14680         RevokeAndACK_free(this_obj_conv);
14681 }
14682
14683 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14684         LDKRevokeAndACK this_ptr_conv;
14685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14686         this_ptr_conv.is_owned = false;
14687         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14688         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
14689         return ret_arr;
14690 }
14691
14692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14693         LDKRevokeAndACK this_ptr_conv;
14694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14695         this_ptr_conv.is_owned = false;
14696         LDKThirtyTwoBytes val_ref;
14697         CHECK((*env)->GetArrayLength(env, val) == 32);
14698         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14699         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
14700 }
14701
14702 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
14703         LDKRevokeAndACK this_ptr_conv;
14704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14705         this_ptr_conv.is_owned = false;
14706         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14707         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
14708         return ret_arr;
14709 }
14710
14711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14712         LDKRevokeAndACK this_ptr_conv;
14713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14714         this_ptr_conv.is_owned = false;
14715         LDKThirtyTwoBytes val_ref;
14716         CHECK((*env)->GetArrayLength(env, val) == 32);
14717         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14718         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
14719 }
14720
14721 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14722         LDKRevokeAndACK this_ptr_conv;
14723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14724         this_ptr_conv.is_owned = false;
14725         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14726         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
14727         return ret_arr;
14728 }
14729
14730 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) {
14731         LDKRevokeAndACK this_ptr_conv;
14732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14733         this_ptr_conv.is_owned = false;
14734         LDKPublicKey val_ref;
14735         CHECK((*env)->GetArrayLength(env, val) == 33);
14736         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14737         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
14738 }
14739
14740 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) {
14741         LDKThirtyTwoBytes channel_id_arg_ref;
14742         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14743         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14744         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
14745         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
14746         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
14747         LDKPublicKey next_per_commitment_point_arg_ref;
14748         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
14749         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
14750         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
14751         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14752         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14753         long ret_ref = (long)ret_var.inner;
14754         if (ret_var.is_owned) {
14755                 ret_ref |= 1;
14756         }
14757         return ret_ref;
14758 }
14759
14760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14761         LDKRevokeAndACK orig_conv;
14762         orig_conv.inner = (void*)(orig & (~1));
14763         orig_conv.is_owned = false;
14764         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
14765         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14766         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14767         long ret_ref = (long)ret_var.inner;
14768         if (ret_var.is_owned) {
14769                 ret_ref |= 1;
14770         }
14771         return ret_ref;
14772 }
14773
14774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14775         LDKUpdateFee this_obj_conv;
14776         this_obj_conv.inner = (void*)(this_obj & (~1));
14777         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14778         UpdateFee_free(this_obj_conv);
14779 }
14780
14781 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14782         LDKUpdateFee this_ptr_conv;
14783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14784         this_ptr_conv.is_owned = false;
14785         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14786         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
14787         return ret_arr;
14788 }
14789
14790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14791         LDKUpdateFee this_ptr_conv;
14792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14793         this_ptr_conv.is_owned = false;
14794         LDKThirtyTwoBytes val_ref;
14795         CHECK((*env)->GetArrayLength(env, val) == 32);
14796         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14797         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
14798 }
14799
14800 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
14801         LDKUpdateFee this_ptr_conv;
14802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14803         this_ptr_conv.is_owned = false;
14804         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
14805         return ret_val;
14806 }
14807
14808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14809         LDKUpdateFee this_ptr_conv;
14810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14811         this_ptr_conv.is_owned = false;
14812         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
14813 }
14814
14815 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) {
14816         LDKThirtyTwoBytes channel_id_arg_ref;
14817         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14818         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14819         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
14820         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14821         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14822         long ret_ref = (long)ret_var.inner;
14823         if (ret_var.is_owned) {
14824                 ret_ref |= 1;
14825         }
14826         return ret_ref;
14827 }
14828
14829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14830         LDKUpdateFee orig_conv;
14831         orig_conv.inner = (void*)(orig & (~1));
14832         orig_conv.is_owned = false;
14833         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
14834         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14835         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14836         long ret_ref = (long)ret_var.inner;
14837         if (ret_var.is_owned) {
14838                 ret_ref |= 1;
14839         }
14840         return ret_ref;
14841 }
14842
14843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14844         LDKDataLossProtect this_obj_conv;
14845         this_obj_conv.inner = (void*)(this_obj & (~1));
14846         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14847         DataLossProtect_free(this_obj_conv);
14848 }
14849
14850 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
14851         LDKDataLossProtect this_ptr_conv;
14852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14853         this_ptr_conv.is_owned = false;
14854         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14855         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
14856         return ret_arr;
14857 }
14858
14859 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) {
14860         LDKDataLossProtect this_ptr_conv;
14861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14862         this_ptr_conv.is_owned = false;
14863         LDKThirtyTwoBytes val_ref;
14864         CHECK((*env)->GetArrayLength(env, val) == 32);
14865         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14866         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
14867 }
14868
14869 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14870         LDKDataLossProtect this_ptr_conv;
14871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14872         this_ptr_conv.is_owned = false;
14873         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14874         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
14875         return ret_arr;
14876 }
14877
14878 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) {
14879         LDKDataLossProtect this_ptr_conv;
14880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14881         this_ptr_conv.is_owned = false;
14882         LDKPublicKey val_ref;
14883         CHECK((*env)->GetArrayLength(env, val) == 33);
14884         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14885         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
14886 }
14887
14888 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) {
14889         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
14890         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
14891         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
14892         LDKPublicKey my_current_per_commitment_point_arg_ref;
14893         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
14894         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
14895         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
14896         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14897         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14898         long ret_ref = (long)ret_var.inner;
14899         if (ret_var.is_owned) {
14900                 ret_ref |= 1;
14901         }
14902         return ret_ref;
14903 }
14904
14905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14906         LDKDataLossProtect orig_conv;
14907         orig_conv.inner = (void*)(orig & (~1));
14908         orig_conv.is_owned = false;
14909         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
14910         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14911         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14912         long ret_ref = (long)ret_var.inner;
14913         if (ret_var.is_owned) {
14914                 ret_ref |= 1;
14915         }
14916         return ret_ref;
14917 }
14918
14919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14920         LDKChannelReestablish this_obj_conv;
14921         this_obj_conv.inner = (void*)(this_obj & (~1));
14922         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14923         ChannelReestablish_free(this_obj_conv);
14924 }
14925
14926 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14927         LDKChannelReestablish this_ptr_conv;
14928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14929         this_ptr_conv.is_owned = false;
14930         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14931         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
14932         return ret_arr;
14933 }
14934
14935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14936         LDKChannelReestablish this_ptr_conv;
14937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14938         this_ptr_conv.is_owned = false;
14939         LDKThirtyTwoBytes val_ref;
14940         CHECK((*env)->GetArrayLength(env, val) == 32);
14941         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14942         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
14943 }
14944
14945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
14946         LDKChannelReestablish this_ptr_conv;
14947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14948         this_ptr_conv.is_owned = false;
14949         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
14950         return ret_val;
14951 }
14952
14953 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) {
14954         LDKChannelReestablish this_ptr_conv;
14955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14956         this_ptr_conv.is_owned = false;
14957         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
14958 }
14959
14960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
14961         LDKChannelReestablish this_ptr_conv;
14962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14963         this_ptr_conv.is_owned = false;
14964         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
14965         return ret_val;
14966 }
14967
14968 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) {
14969         LDKChannelReestablish this_ptr_conv;
14970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14971         this_ptr_conv.is_owned = false;
14972         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
14973 }
14974
14975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14976         LDKChannelReestablish orig_conv;
14977         orig_conv.inner = (void*)(orig & (~1));
14978         orig_conv.is_owned = false;
14979         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
14980         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14981         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14982         long ret_ref = (long)ret_var.inner;
14983         if (ret_var.is_owned) {
14984                 ret_ref |= 1;
14985         }
14986         return ret_ref;
14987 }
14988
14989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14990         LDKAnnouncementSignatures this_obj_conv;
14991         this_obj_conv.inner = (void*)(this_obj & (~1));
14992         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14993         AnnouncementSignatures_free(this_obj_conv);
14994 }
14995
14996 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14997         LDKAnnouncementSignatures this_ptr_conv;
14998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14999         this_ptr_conv.is_owned = false;
15000         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15001         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
15002         return ret_arr;
15003 }
15004
15005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15006         LDKAnnouncementSignatures this_ptr_conv;
15007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15008         this_ptr_conv.is_owned = false;
15009         LDKThirtyTwoBytes val_ref;
15010         CHECK((*env)->GetArrayLength(env, val) == 32);
15011         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15012         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
15013 }
15014
15015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15016         LDKAnnouncementSignatures this_ptr_conv;
15017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15018         this_ptr_conv.is_owned = false;
15019         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
15020         return ret_val;
15021 }
15022
15023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15024         LDKAnnouncementSignatures this_ptr_conv;
15025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15026         this_ptr_conv.is_owned = false;
15027         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
15028 }
15029
15030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15031         LDKAnnouncementSignatures this_ptr_conv;
15032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15033         this_ptr_conv.is_owned = false;
15034         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15035         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
15036         return ret_arr;
15037 }
15038
15039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15040         LDKAnnouncementSignatures this_ptr_conv;
15041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15042         this_ptr_conv.is_owned = false;
15043         LDKSignature val_ref;
15044         CHECK((*env)->GetArrayLength(env, val) == 64);
15045         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15046         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
15047 }
15048
15049 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15050         LDKAnnouncementSignatures this_ptr_conv;
15051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15052         this_ptr_conv.is_owned = false;
15053         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15054         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
15055         return ret_arr;
15056 }
15057
15058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15059         LDKAnnouncementSignatures this_ptr_conv;
15060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15061         this_ptr_conv.is_owned = false;
15062         LDKSignature val_ref;
15063         CHECK((*env)->GetArrayLength(env, val) == 64);
15064         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15065         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
15066 }
15067
15068 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) {
15069         LDKThirtyTwoBytes channel_id_arg_ref;
15070         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
15071         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
15072         LDKSignature node_signature_arg_ref;
15073         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
15074         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
15075         LDKSignature bitcoin_signature_arg_ref;
15076         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
15077         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
15078         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
15079         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15080         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15081         long ret_ref = (long)ret_var.inner;
15082         if (ret_var.is_owned) {
15083                 ret_ref |= 1;
15084         }
15085         return ret_ref;
15086 }
15087
15088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15089         LDKAnnouncementSignatures orig_conv;
15090         orig_conv.inner = (void*)(orig & (~1));
15091         orig_conv.is_owned = false;
15092         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
15093         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15094         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15095         long ret_ref = (long)ret_var.inner;
15096         if (ret_var.is_owned) {
15097                 ret_ref |= 1;
15098         }
15099         return ret_ref;
15100 }
15101
15102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15103         if ((this_ptr & 1) != 0) return;
15104         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
15105         FREE((void*)this_ptr);
15106         NetAddress_free(this_ptr_conv);
15107 }
15108
15109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15110         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
15111         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
15112         *ret_copy = NetAddress_clone(orig_conv);
15113         long ret_ref = (long)ret_copy;
15114         return ret_ref;
15115 }
15116
15117 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
15118         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
15119         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
15120         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15121         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15122         CVec_u8Z_free(ret_var);
15123         return ret_arr;
15124 }
15125
15126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15127         LDKu8slice ser_ref;
15128         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15129         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15130         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
15131         *ret_conv = Result_read(ser_ref);
15132         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15133         return (long)ret_conv;
15134 }
15135
15136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15137         LDKUnsignedNodeAnnouncement this_obj_conv;
15138         this_obj_conv.inner = (void*)(this_obj & (~1));
15139         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15140         UnsignedNodeAnnouncement_free(this_obj_conv);
15141 }
15142
15143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
15144         LDKUnsignedNodeAnnouncement this_ptr_conv;
15145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15146         this_ptr_conv.is_owned = false;
15147         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
15148         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15149         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15150         long ret_ref = (long)ret_var.inner;
15151         if (ret_var.is_owned) {
15152                 ret_ref |= 1;
15153         }
15154         return ret_ref;
15155 }
15156
15157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15158         LDKUnsignedNodeAnnouncement this_ptr_conv;
15159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15160         this_ptr_conv.is_owned = false;
15161         LDKNodeFeatures val_conv;
15162         val_conv.inner = (void*)(val & (~1));
15163         val_conv.is_owned = (val & 1) || (val == 0);
15164         val_conv = NodeFeatures_clone(&val_conv);
15165         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
15166 }
15167
15168 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
15169         LDKUnsignedNodeAnnouncement this_ptr_conv;
15170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15171         this_ptr_conv.is_owned = false;
15172         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
15173         return ret_val;
15174 }
15175
15176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15177         LDKUnsignedNodeAnnouncement this_ptr_conv;
15178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15179         this_ptr_conv.is_owned = false;
15180         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
15181 }
15182
15183 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15184         LDKUnsignedNodeAnnouncement this_ptr_conv;
15185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15186         this_ptr_conv.is_owned = false;
15187         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15188         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
15189         return ret_arr;
15190 }
15191
15192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15193         LDKUnsignedNodeAnnouncement this_ptr_conv;
15194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15195         this_ptr_conv.is_owned = false;
15196         LDKPublicKey val_ref;
15197         CHECK((*env)->GetArrayLength(env, val) == 33);
15198         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15199         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
15200 }
15201
15202 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
15203         LDKUnsignedNodeAnnouncement this_ptr_conv;
15204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15205         this_ptr_conv.is_owned = false;
15206         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
15207         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
15208         return ret_arr;
15209 }
15210
15211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15212         LDKUnsignedNodeAnnouncement this_ptr_conv;
15213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15214         this_ptr_conv.is_owned = false;
15215         LDKThreeBytes val_ref;
15216         CHECK((*env)->GetArrayLength(env, val) == 3);
15217         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
15218         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
15219 }
15220
15221 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
15222         LDKUnsignedNodeAnnouncement this_ptr_conv;
15223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15224         this_ptr_conv.is_owned = false;
15225         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15226         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
15227         return ret_arr;
15228 }
15229
15230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15231         LDKUnsignedNodeAnnouncement this_ptr_conv;
15232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15233         this_ptr_conv.is_owned = false;
15234         LDKThirtyTwoBytes val_ref;
15235         CHECK((*env)->GetArrayLength(env, val) == 32);
15236         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15237         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
15238 }
15239
15240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
15241         LDKUnsignedNodeAnnouncement this_ptr_conv;
15242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15243         this_ptr_conv.is_owned = false;
15244         LDKCVec_NetAddressZ val_constr;
15245         val_constr.datalen = (*env)->GetArrayLength(env, val);
15246         if (val_constr.datalen > 0)
15247                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15248         else
15249                 val_constr.data = NULL;
15250         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
15251         for (size_t m = 0; m < val_constr.datalen; m++) {
15252                 int64_t val_conv_12 = val_vals[m];
15253                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
15254                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
15255                 val_constr.data[m] = val_conv_12_conv;
15256         }
15257         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
15258         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
15259 }
15260
15261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15262         LDKUnsignedNodeAnnouncement orig_conv;
15263         orig_conv.inner = (void*)(orig & (~1));
15264         orig_conv.is_owned = false;
15265         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
15266         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15267         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15268         long ret_ref = (long)ret_var.inner;
15269         if (ret_var.is_owned) {
15270                 ret_ref |= 1;
15271         }
15272         return ret_ref;
15273 }
15274
15275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15276         LDKNodeAnnouncement this_obj_conv;
15277         this_obj_conv.inner = (void*)(this_obj & (~1));
15278         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15279         NodeAnnouncement_free(this_obj_conv);
15280 }
15281
15282 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15283         LDKNodeAnnouncement this_ptr_conv;
15284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15285         this_ptr_conv.is_owned = false;
15286         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15287         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
15288         return ret_arr;
15289 }
15290
15291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15292         LDKNodeAnnouncement this_ptr_conv;
15293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15294         this_ptr_conv.is_owned = false;
15295         LDKSignature val_ref;
15296         CHECK((*env)->GetArrayLength(env, val) == 64);
15297         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15298         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
15299 }
15300
15301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
15302         LDKNodeAnnouncement this_ptr_conv;
15303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15304         this_ptr_conv.is_owned = false;
15305         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
15306         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15307         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15308         long ret_ref = (long)ret_var.inner;
15309         if (ret_var.is_owned) {
15310                 ret_ref |= 1;
15311         }
15312         return ret_ref;
15313 }
15314
15315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15316         LDKNodeAnnouncement this_ptr_conv;
15317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15318         this_ptr_conv.is_owned = false;
15319         LDKUnsignedNodeAnnouncement val_conv;
15320         val_conv.inner = (void*)(val & (~1));
15321         val_conv.is_owned = (val & 1) || (val == 0);
15322         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
15323         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
15324 }
15325
15326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
15327         LDKSignature signature_arg_ref;
15328         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
15329         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
15330         LDKUnsignedNodeAnnouncement contents_arg_conv;
15331         contents_arg_conv.inner = (void*)(contents_arg & (~1));
15332         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
15333         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
15334         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
15335         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15336         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15337         long ret_ref = (long)ret_var.inner;
15338         if (ret_var.is_owned) {
15339                 ret_ref |= 1;
15340         }
15341         return ret_ref;
15342 }
15343
15344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15345         LDKNodeAnnouncement orig_conv;
15346         orig_conv.inner = (void*)(orig & (~1));
15347         orig_conv.is_owned = false;
15348         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
15349         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15350         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15351         long ret_ref = (long)ret_var.inner;
15352         if (ret_var.is_owned) {
15353                 ret_ref |= 1;
15354         }
15355         return ret_ref;
15356 }
15357
15358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15359         LDKUnsignedChannelAnnouncement this_obj_conv;
15360         this_obj_conv.inner = (void*)(this_obj & (~1));
15361         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15362         UnsignedChannelAnnouncement_free(this_obj_conv);
15363 }
15364
15365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
15366         LDKUnsignedChannelAnnouncement this_ptr_conv;
15367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15368         this_ptr_conv.is_owned = false;
15369         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
15370         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15371         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15372         long ret_ref = (long)ret_var.inner;
15373         if (ret_var.is_owned) {
15374                 ret_ref |= 1;
15375         }
15376         return ret_ref;
15377 }
15378
15379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15380         LDKUnsignedChannelAnnouncement this_ptr_conv;
15381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15382         this_ptr_conv.is_owned = false;
15383         LDKChannelFeatures val_conv;
15384         val_conv.inner = (void*)(val & (~1));
15385         val_conv.is_owned = (val & 1) || (val == 0);
15386         val_conv = ChannelFeatures_clone(&val_conv);
15387         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
15388 }
15389
15390 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15391         LDKUnsignedChannelAnnouncement this_ptr_conv;
15392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15393         this_ptr_conv.is_owned = false;
15394         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15395         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
15396         return ret_arr;
15397 }
15398
15399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15400         LDKUnsignedChannelAnnouncement this_ptr_conv;
15401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15402         this_ptr_conv.is_owned = false;
15403         LDKThirtyTwoBytes val_ref;
15404         CHECK((*env)->GetArrayLength(env, val) == 32);
15405         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15406         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
15407 }
15408
15409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15410         LDKUnsignedChannelAnnouncement this_ptr_conv;
15411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15412         this_ptr_conv.is_owned = false;
15413         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
15414         return ret_val;
15415 }
15416
15417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15418         LDKUnsignedChannelAnnouncement this_ptr_conv;
15419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15420         this_ptr_conv.is_owned = false;
15421         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
15422 }
15423
15424 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
15425         LDKUnsignedChannelAnnouncement this_ptr_conv;
15426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15427         this_ptr_conv.is_owned = false;
15428         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15429         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
15430         return ret_arr;
15431 }
15432
15433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15434         LDKUnsignedChannelAnnouncement this_ptr_conv;
15435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15436         this_ptr_conv.is_owned = false;
15437         LDKPublicKey val_ref;
15438         CHECK((*env)->GetArrayLength(env, val) == 33);
15439         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15440         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
15441 }
15442
15443 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
15444         LDKUnsignedChannelAnnouncement this_ptr_conv;
15445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15446         this_ptr_conv.is_owned = false;
15447         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15448         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
15449         return ret_arr;
15450 }
15451
15452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15453         LDKUnsignedChannelAnnouncement this_ptr_conv;
15454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15455         this_ptr_conv.is_owned = false;
15456         LDKPublicKey val_ref;
15457         CHECK((*env)->GetArrayLength(env, val) == 33);
15458         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15459         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
15460 }
15461
15462 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
15463         LDKUnsignedChannelAnnouncement this_ptr_conv;
15464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15465         this_ptr_conv.is_owned = false;
15466         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15467         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
15468         return ret_arr;
15469 }
15470
15471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15472         LDKUnsignedChannelAnnouncement this_ptr_conv;
15473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15474         this_ptr_conv.is_owned = false;
15475         LDKPublicKey val_ref;
15476         CHECK((*env)->GetArrayLength(env, val) == 33);
15477         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15478         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
15479 }
15480
15481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
15482         LDKUnsignedChannelAnnouncement this_ptr_conv;
15483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15484         this_ptr_conv.is_owned = false;
15485         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15486         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
15487         return ret_arr;
15488 }
15489
15490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15491         LDKUnsignedChannelAnnouncement this_ptr_conv;
15492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15493         this_ptr_conv.is_owned = false;
15494         LDKPublicKey val_ref;
15495         CHECK((*env)->GetArrayLength(env, val) == 33);
15496         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15497         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
15498 }
15499
15500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15501         LDKUnsignedChannelAnnouncement orig_conv;
15502         orig_conv.inner = (void*)(orig & (~1));
15503         orig_conv.is_owned = false;
15504         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
15505         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15506         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15507         long ret_ref = (long)ret_var.inner;
15508         if (ret_var.is_owned) {
15509                 ret_ref |= 1;
15510         }
15511         return ret_ref;
15512 }
15513
15514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15515         LDKChannelAnnouncement this_obj_conv;
15516         this_obj_conv.inner = (void*)(this_obj & (~1));
15517         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15518         ChannelAnnouncement_free(this_obj_conv);
15519 }
15520
15521 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
15522         LDKChannelAnnouncement this_ptr_conv;
15523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15524         this_ptr_conv.is_owned = false;
15525         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15526         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
15527         return ret_arr;
15528 }
15529
15530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15531         LDKChannelAnnouncement this_ptr_conv;
15532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15533         this_ptr_conv.is_owned = false;
15534         LDKSignature val_ref;
15535         CHECK((*env)->GetArrayLength(env, val) == 64);
15536         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15537         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
15538 }
15539
15540 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
15541         LDKChannelAnnouncement this_ptr_conv;
15542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15543         this_ptr_conv.is_owned = false;
15544         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15545         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
15546         return ret_arr;
15547 }
15548
15549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15550         LDKChannelAnnouncement this_ptr_conv;
15551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15552         this_ptr_conv.is_owned = false;
15553         LDKSignature val_ref;
15554         CHECK((*env)->GetArrayLength(env, val) == 64);
15555         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15556         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
15557 }
15558
15559 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
15560         LDKChannelAnnouncement this_ptr_conv;
15561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15562         this_ptr_conv.is_owned = false;
15563         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15564         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
15565         return ret_arr;
15566 }
15567
15568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15569         LDKChannelAnnouncement this_ptr_conv;
15570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15571         this_ptr_conv.is_owned = false;
15572         LDKSignature val_ref;
15573         CHECK((*env)->GetArrayLength(env, val) == 64);
15574         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15575         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
15576 }
15577
15578 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
15579         LDKChannelAnnouncement this_ptr_conv;
15580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15581         this_ptr_conv.is_owned = false;
15582         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15583         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
15584         return ret_arr;
15585 }
15586
15587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15588         LDKChannelAnnouncement this_ptr_conv;
15589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15590         this_ptr_conv.is_owned = false;
15591         LDKSignature val_ref;
15592         CHECK((*env)->GetArrayLength(env, val) == 64);
15593         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15594         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
15595 }
15596
15597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
15598         LDKChannelAnnouncement this_ptr_conv;
15599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15600         this_ptr_conv.is_owned = false;
15601         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
15602         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15603         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15604         long ret_ref = (long)ret_var.inner;
15605         if (ret_var.is_owned) {
15606                 ret_ref |= 1;
15607         }
15608         return ret_ref;
15609 }
15610
15611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15612         LDKChannelAnnouncement this_ptr_conv;
15613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15614         this_ptr_conv.is_owned = false;
15615         LDKUnsignedChannelAnnouncement val_conv;
15616         val_conv.inner = (void*)(val & (~1));
15617         val_conv.is_owned = (val & 1) || (val == 0);
15618         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
15619         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
15620 }
15621
15622 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) {
15623         LDKSignature node_signature_1_arg_ref;
15624         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
15625         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
15626         LDKSignature node_signature_2_arg_ref;
15627         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
15628         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
15629         LDKSignature bitcoin_signature_1_arg_ref;
15630         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
15631         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
15632         LDKSignature bitcoin_signature_2_arg_ref;
15633         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
15634         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
15635         LDKUnsignedChannelAnnouncement contents_arg_conv;
15636         contents_arg_conv.inner = (void*)(contents_arg & (~1));
15637         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
15638         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
15639         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);
15640         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15641         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15642         long ret_ref = (long)ret_var.inner;
15643         if (ret_var.is_owned) {
15644                 ret_ref |= 1;
15645         }
15646         return ret_ref;
15647 }
15648
15649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15650         LDKChannelAnnouncement orig_conv;
15651         orig_conv.inner = (void*)(orig & (~1));
15652         orig_conv.is_owned = false;
15653         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
15654         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15655         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15656         long ret_ref = (long)ret_var.inner;
15657         if (ret_var.is_owned) {
15658                 ret_ref |= 1;
15659         }
15660         return ret_ref;
15661 }
15662
15663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15664         LDKUnsignedChannelUpdate this_obj_conv;
15665         this_obj_conv.inner = (void*)(this_obj & (~1));
15666         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15667         UnsignedChannelUpdate_free(this_obj_conv);
15668 }
15669
15670 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15671         LDKUnsignedChannelUpdate this_ptr_conv;
15672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15673         this_ptr_conv.is_owned = false;
15674         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15675         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
15676         return ret_arr;
15677 }
15678
15679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15680         LDKUnsignedChannelUpdate this_ptr_conv;
15681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15682         this_ptr_conv.is_owned = false;
15683         LDKThirtyTwoBytes val_ref;
15684         CHECK((*env)->GetArrayLength(env, val) == 32);
15685         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15686         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
15687 }
15688
15689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15690         LDKUnsignedChannelUpdate this_ptr_conv;
15691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15692         this_ptr_conv.is_owned = false;
15693         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
15694         return ret_val;
15695 }
15696
15697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15698         LDKUnsignedChannelUpdate this_ptr_conv;
15699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15700         this_ptr_conv.is_owned = false;
15701         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
15702 }
15703
15704 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
15705         LDKUnsignedChannelUpdate this_ptr_conv;
15706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15707         this_ptr_conv.is_owned = false;
15708         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
15709         return ret_val;
15710 }
15711
15712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15713         LDKUnsignedChannelUpdate this_ptr_conv;
15714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15715         this_ptr_conv.is_owned = false;
15716         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
15717 }
15718
15719 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
15720         LDKUnsignedChannelUpdate this_ptr_conv;
15721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15722         this_ptr_conv.is_owned = false;
15723         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
15724         return ret_val;
15725 }
15726
15727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
15728         LDKUnsignedChannelUpdate this_ptr_conv;
15729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15730         this_ptr_conv.is_owned = false;
15731         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
15732 }
15733
15734 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
15735         LDKUnsignedChannelUpdate this_ptr_conv;
15736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15737         this_ptr_conv.is_owned = false;
15738         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
15739         return ret_val;
15740 }
15741
15742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15743         LDKUnsignedChannelUpdate this_ptr_conv;
15744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15745         this_ptr_conv.is_owned = false;
15746         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
15747 }
15748
15749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15750         LDKUnsignedChannelUpdate this_ptr_conv;
15751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15752         this_ptr_conv.is_owned = false;
15753         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
15754         return ret_val;
15755 }
15756
15757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15758         LDKUnsignedChannelUpdate this_ptr_conv;
15759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15760         this_ptr_conv.is_owned = false;
15761         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
15762 }
15763
15764 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15765         LDKUnsignedChannelUpdate this_ptr_conv;
15766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15767         this_ptr_conv.is_owned = false;
15768         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
15769         return ret_val;
15770 }
15771
15772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15773         LDKUnsignedChannelUpdate this_ptr_conv;
15774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15775         this_ptr_conv.is_owned = false;
15776         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
15777 }
15778
15779 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
15780         LDKUnsignedChannelUpdate this_ptr_conv;
15781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15782         this_ptr_conv.is_owned = false;
15783         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
15784         return ret_val;
15785 }
15786
15787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15788         LDKUnsignedChannelUpdate this_ptr_conv;
15789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15790         this_ptr_conv.is_owned = false;
15791         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
15792 }
15793
15794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15795         LDKUnsignedChannelUpdate orig_conv;
15796         orig_conv.inner = (void*)(orig & (~1));
15797         orig_conv.is_owned = false;
15798         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
15799         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15800         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15801         long ret_ref = (long)ret_var.inner;
15802         if (ret_var.is_owned) {
15803                 ret_ref |= 1;
15804         }
15805         return ret_ref;
15806 }
15807
15808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15809         LDKChannelUpdate this_obj_conv;
15810         this_obj_conv.inner = (void*)(this_obj & (~1));
15811         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15812         ChannelUpdate_free(this_obj_conv);
15813 }
15814
15815 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15816         LDKChannelUpdate this_ptr_conv;
15817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15818         this_ptr_conv.is_owned = false;
15819         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15820         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
15821         return ret_arr;
15822 }
15823
15824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15825         LDKChannelUpdate this_ptr_conv;
15826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15827         this_ptr_conv.is_owned = false;
15828         LDKSignature val_ref;
15829         CHECK((*env)->GetArrayLength(env, val) == 64);
15830         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15831         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
15832 }
15833
15834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
15835         LDKChannelUpdate this_ptr_conv;
15836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15837         this_ptr_conv.is_owned = false;
15838         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
15839         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15840         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15841         long ret_ref = (long)ret_var.inner;
15842         if (ret_var.is_owned) {
15843                 ret_ref |= 1;
15844         }
15845         return ret_ref;
15846 }
15847
15848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15849         LDKChannelUpdate this_ptr_conv;
15850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15851         this_ptr_conv.is_owned = false;
15852         LDKUnsignedChannelUpdate val_conv;
15853         val_conv.inner = (void*)(val & (~1));
15854         val_conv.is_owned = (val & 1) || (val == 0);
15855         val_conv = UnsignedChannelUpdate_clone(&val_conv);
15856         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
15857 }
15858
15859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
15860         LDKSignature signature_arg_ref;
15861         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
15862         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
15863         LDKUnsignedChannelUpdate contents_arg_conv;
15864         contents_arg_conv.inner = (void*)(contents_arg & (~1));
15865         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
15866         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
15867         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
15868         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15869         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15870         long ret_ref = (long)ret_var.inner;
15871         if (ret_var.is_owned) {
15872                 ret_ref |= 1;
15873         }
15874         return ret_ref;
15875 }
15876
15877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15878         LDKChannelUpdate orig_conv;
15879         orig_conv.inner = (void*)(orig & (~1));
15880         orig_conv.is_owned = false;
15881         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
15882         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15883         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15884         long ret_ref = (long)ret_var.inner;
15885         if (ret_var.is_owned) {
15886                 ret_ref |= 1;
15887         }
15888         return ret_ref;
15889 }
15890
15891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15892         LDKQueryChannelRange this_obj_conv;
15893         this_obj_conv.inner = (void*)(this_obj & (~1));
15894         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15895         QueryChannelRange_free(this_obj_conv);
15896 }
15897
15898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15899         LDKQueryChannelRange this_ptr_conv;
15900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15901         this_ptr_conv.is_owned = false;
15902         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15903         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
15904         return ret_arr;
15905 }
15906
15907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15908         LDKQueryChannelRange this_ptr_conv;
15909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15910         this_ptr_conv.is_owned = false;
15911         LDKThirtyTwoBytes val_ref;
15912         CHECK((*env)->GetArrayLength(env, val) == 32);
15913         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15914         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
15915 }
15916
15917 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
15918         LDKQueryChannelRange this_ptr_conv;
15919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15920         this_ptr_conv.is_owned = false;
15921         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
15922         return ret_val;
15923 }
15924
15925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15926         LDKQueryChannelRange this_ptr_conv;
15927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15928         this_ptr_conv.is_owned = false;
15929         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
15930 }
15931
15932 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
15933         LDKQueryChannelRange this_ptr_conv;
15934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15935         this_ptr_conv.is_owned = false;
15936         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
15937         return ret_val;
15938 }
15939
15940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15941         LDKQueryChannelRange this_ptr_conv;
15942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15943         this_ptr_conv.is_owned = false;
15944         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
15945 }
15946
15947 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) {
15948         LDKThirtyTwoBytes chain_hash_arg_ref;
15949         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
15950         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
15951         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
15952         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15953         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15954         long ret_ref = (long)ret_var.inner;
15955         if (ret_var.is_owned) {
15956                 ret_ref |= 1;
15957         }
15958         return ret_ref;
15959 }
15960
15961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15962         LDKQueryChannelRange orig_conv;
15963         orig_conv.inner = (void*)(orig & (~1));
15964         orig_conv.is_owned = false;
15965         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
15966         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15967         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15968         long ret_ref = (long)ret_var.inner;
15969         if (ret_var.is_owned) {
15970                 ret_ref |= 1;
15971         }
15972         return ret_ref;
15973 }
15974
15975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15976         LDKReplyChannelRange this_obj_conv;
15977         this_obj_conv.inner = (void*)(this_obj & (~1));
15978         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15979         ReplyChannelRange_free(this_obj_conv);
15980 }
15981
15982 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15983         LDKReplyChannelRange this_ptr_conv;
15984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15985         this_ptr_conv.is_owned = false;
15986         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15987         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
15988         return ret_arr;
15989 }
15990
15991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15992         LDKReplyChannelRange this_ptr_conv;
15993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15994         this_ptr_conv.is_owned = false;
15995         LDKThirtyTwoBytes val_ref;
15996         CHECK((*env)->GetArrayLength(env, val) == 32);
15997         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15998         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
15999 }
16000
16001 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
16002         LDKReplyChannelRange this_ptr_conv;
16003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16004         this_ptr_conv.is_owned = false;
16005         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
16006         return ret_val;
16007 }
16008
16009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16010         LDKReplyChannelRange this_ptr_conv;
16011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16012         this_ptr_conv.is_owned = false;
16013         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
16014 }
16015
16016 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
16017         LDKReplyChannelRange this_ptr_conv;
16018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16019         this_ptr_conv.is_owned = false;
16020         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
16021         return ret_val;
16022 }
16023
16024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16025         LDKReplyChannelRange this_ptr_conv;
16026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16027         this_ptr_conv.is_owned = false;
16028         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
16029 }
16030
16031 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
16032         LDKReplyChannelRange this_ptr_conv;
16033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16034         this_ptr_conv.is_owned = false;
16035         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
16036         return ret_val;
16037 }
16038
16039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16040         LDKReplyChannelRange this_ptr_conv;
16041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16042         this_ptr_conv.is_owned = false;
16043         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
16044 }
16045
16046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16047         LDKReplyChannelRange this_ptr_conv;
16048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16049         this_ptr_conv.is_owned = false;
16050         LDKCVec_u64Z val_constr;
16051         val_constr.datalen = (*env)->GetArrayLength(env, val);
16052         if (val_constr.datalen > 0)
16053                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16054         else
16055                 val_constr.data = NULL;
16056         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16057         for (size_t g = 0; g < val_constr.datalen; g++) {
16058                 int64_t val_conv_6 = val_vals[g];
16059                 val_constr.data[g] = val_conv_6;
16060         }
16061         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16062         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
16063 }
16064
16065 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) {
16066         LDKThirtyTwoBytes chain_hash_arg_ref;
16067         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16068         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16069         LDKCVec_u64Z short_channel_ids_arg_constr;
16070         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
16071         if (short_channel_ids_arg_constr.datalen > 0)
16072                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16073         else
16074                 short_channel_ids_arg_constr.data = NULL;
16075         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
16076         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
16077                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
16078                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
16079         }
16080         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
16081         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
16082         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16083         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16084         long ret_ref = (long)ret_var.inner;
16085         if (ret_var.is_owned) {
16086                 ret_ref |= 1;
16087         }
16088         return ret_ref;
16089 }
16090
16091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16092         LDKReplyChannelRange orig_conv;
16093         orig_conv.inner = (void*)(orig & (~1));
16094         orig_conv.is_owned = false;
16095         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_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_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16106         LDKQueryShortChannelIds this_obj_conv;
16107         this_obj_conv.inner = (void*)(this_obj & (~1));
16108         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16109         QueryShortChannelIds_free(this_obj_conv);
16110 }
16111
16112 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16113         LDKQueryShortChannelIds this_ptr_conv;
16114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16115         this_ptr_conv.is_owned = false;
16116         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16117         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
16118         return ret_arr;
16119 }
16120
16121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16122         LDKQueryShortChannelIds this_ptr_conv;
16123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16124         this_ptr_conv.is_owned = false;
16125         LDKThirtyTwoBytes val_ref;
16126         CHECK((*env)->GetArrayLength(env, val) == 32);
16127         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16128         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
16129 }
16130
16131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16132         LDKQueryShortChannelIds this_ptr_conv;
16133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16134         this_ptr_conv.is_owned = false;
16135         LDKCVec_u64Z val_constr;
16136         val_constr.datalen = (*env)->GetArrayLength(env, val);
16137         if (val_constr.datalen > 0)
16138                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16139         else
16140                 val_constr.data = NULL;
16141         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16142         for (size_t g = 0; g < val_constr.datalen; g++) {
16143                 int64_t val_conv_6 = val_vals[g];
16144                 val_constr.data[g] = val_conv_6;
16145         }
16146         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16147         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
16148 }
16149
16150 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) {
16151         LDKThirtyTwoBytes chain_hash_arg_ref;
16152         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16153         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16154         LDKCVec_u64Z short_channel_ids_arg_constr;
16155         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
16156         if (short_channel_ids_arg_constr.datalen > 0)
16157                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16158         else
16159                 short_channel_ids_arg_constr.data = NULL;
16160         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
16161         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
16162                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
16163                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
16164         }
16165         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
16166         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
16167         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16168         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16169         long ret_ref = (long)ret_var.inner;
16170         if (ret_var.is_owned) {
16171                 ret_ref |= 1;
16172         }
16173         return ret_ref;
16174 }
16175
16176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16177         LDKQueryShortChannelIds orig_conv;
16178         orig_conv.inner = (void*)(orig & (~1));
16179         orig_conv.is_owned = false;
16180         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
16181         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16182         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16183         long ret_ref = (long)ret_var.inner;
16184         if (ret_var.is_owned) {
16185                 ret_ref |= 1;
16186         }
16187         return ret_ref;
16188 }
16189
16190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16191         LDKReplyShortChannelIdsEnd this_obj_conv;
16192         this_obj_conv.inner = (void*)(this_obj & (~1));
16193         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16194         ReplyShortChannelIdsEnd_free(this_obj_conv);
16195 }
16196
16197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16198         LDKReplyShortChannelIdsEnd this_ptr_conv;
16199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16200         this_ptr_conv.is_owned = false;
16201         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16202         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
16203         return ret_arr;
16204 }
16205
16206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16207         LDKReplyShortChannelIdsEnd this_ptr_conv;
16208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16209         this_ptr_conv.is_owned = false;
16210         LDKThirtyTwoBytes val_ref;
16211         CHECK((*env)->GetArrayLength(env, val) == 32);
16212         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16213         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
16214 }
16215
16216 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
16217         LDKReplyShortChannelIdsEnd this_ptr_conv;
16218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16219         this_ptr_conv.is_owned = false;
16220         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
16221         return ret_val;
16222 }
16223
16224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16225         LDKReplyShortChannelIdsEnd this_ptr_conv;
16226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16227         this_ptr_conv.is_owned = false;
16228         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
16229 }
16230
16231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
16232         LDKThirtyTwoBytes chain_hash_arg_ref;
16233         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16234         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16235         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
16236         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16237         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16238         long ret_ref = (long)ret_var.inner;
16239         if (ret_var.is_owned) {
16240                 ret_ref |= 1;
16241         }
16242         return ret_ref;
16243 }
16244
16245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16246         LDKReplyShortChannelIdsEnd orig_conv;
16247         orig_conv.inner = (void*)(orig & (~1));
16248         orig_conv.is_owned = false;
16249         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
16250         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16251         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16252         long ret_ref = (long)ret_var.inner;
16253         if (ret_var.is_owned) {
16254                 ret_ref |= 1;
16255         }
16256         return ret_ref;
16257 }
16258
16259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16260         LDKGossipTimestampFilter this_obj_conv;
16261         this_obj_conv.inner = (void*)(this_obj & (~1));
16262         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16263         GossipTimestampFilter_free(this_obj_conv);
16264 }
16265
16266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16267         LDKGossipTimestampFilter this_ptr_conv;
16268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16269         this_ptr_conv.is_owned = false;
16270         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16271         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
16272         return ret_arr;
16273 }
16274
16275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16276         LDKGossipTimestampFilter this_ptr_conv;
16277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16278         this_ptr_conv.is_owned = false;
16279         LDKThirtyTwoBytes val_ref;
16280         CHECK((*env)->GetArrayLength(env, val) == 32);
16281         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16282         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
16283 }
16284
16285 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
16286         LDKGossipTimestampFilter this_ptr_conv;
16287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16288         this_ptr_conv.is_owned = false;
16289         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
16290         return ret_val;
16291 }
16292
16293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16294         LDKGossipTimestampFilter this_ptr_conv;
16295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16296         this_ptr_conv.is_owned = false;
16297         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
16298 }
16299
16300 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
16301         LDKGossipTimestampFilter this_ptr_conv;
16302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16303         this_ptr_conv.is_owned = false;
16304         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
16305         return ret_val;
16306 }
16307
16308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16309         LDKGossipTimestampFilter this_ptr_conv;
16310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16311         this_ptr_conv.is_owned = false;
16312         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
16313 }
16314
16315 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) {
16316         LDKThirtyTwoBytes chain_hash_arg_ref;
16317         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16318         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16319         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
16320         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16321         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16322         long ret_ref = (long)ret_var.inner;
16323         if (ret_var.is_owned) {
16324                 ret_ref |= 1;
16325         }
16326         return ret_ref;
16327 }
16328
16329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16330         LDKGossipTimestampFilter orig_conv;
16331         orig_conv.inner = (void*)(orig & (~1));
16332         orig_conv.is_owned = false;
16333         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
16334         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16335         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16336         long ret_ref = (long)ret_var.inner;
16337         if (ret_var.is_owned) {
16338                 ret_ref |= 1;
16339         }
16340         return ret_ref;
16341 }
16342
16343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16344         if ((this_ptr & 1) != 0) return;
16345         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
16346         FREE((void*)this_ptr);
16347         ErrorAction_free(this_ptr_conv);
16348 }
16349
16350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16351         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
16352         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
16353         *ret_copy = ErrorAction_clone(orig_conv);
16354         long ret_ref = (long)ret_copy;
16355         return ret_ref;
16356 }
16357
16358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16359         LDKLightningError this_obj_conv;
16360         this_obj_conv.inner = (void*)(this_obj & (~1));
16361         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16362         LightningError_free(this_obj_conv);
16363 }
16364
16365 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
16366         LDKLightningError this_ptr_conv;
16367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16368         this_ptr_conv.is_owned = false;
16369         LDKStr _str = LightningError_get_err(&this_ptr_conv);
16370         jstring _conv = str_ref_to_java(env, _str.chars, _str.len);
16371         return _conv;
16372 }
16373
16374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16375         LDKLightningError this_ptr_conv;
16376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16377         this_ptr_conv.is_owned = false;
16378         LDKCVec_u8Z val_ref;
16379         val_ref.datalen = (*env)->GetArrayLength(env, val);
16380         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
16381         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
16382         LightningError_set_err(&this_ptr_conv, val_ref);
16383 }
16384
16385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
16386         LDKLightningError this_ptr_conv;
16387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16388         this_ptr_conv.is_owned = false;
16389         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
16390         *ret_copy = LightningError_get_action(&this_ptr_conv);
16391         long ret_ref = (long)ret_copy;
16392         return ret_ref;
16393 }
16394
16395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16396         LDKLightningError this_ptr_conv;
16397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16398         this_ptr_conv.is_owned = false;
16399         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
16400         FREE((void*)val);
16401         LightningError_set_action(&this_ptr_conv, val_conv);
16402 }
16403
16404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, int8_tArray err_arg, int64_t action_arg) {
16405         LDKCVec_u8Z err_arg_ref;
16406         err_arg_ref.datalen = (*env)->GetArrayLength(env, err_arg);
16407         err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
16408         (*env)->GetByteArrayRegion(env, err_arg, 0, err_arg_ref.datalen, err_arg_ref.data);
16409         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
16410         FREE((void*)action_arg);
16411         LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
16412         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16413         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16414         long ret_ref = (long)ret_var.inner;
16415         if (ret_var.is_owned) {
16416                 ret_ref |= 1;
16417         }
16418         return ret_ref;
16419 }
16420
16421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16422         LDKLightningError orig_conv;
16423         orig_conv.inner = (void*)(orig & (~1));
16424         orig_conv.is_owned = false;
16425         LDKLightningError ret_var = LightningError_clone(&orig_conv);
16426         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16427         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16428         long ret_ref = (long)ret_var.inner;
16429         if (ret_var.is_owned) {
16430                 ret_ref |= 1;
16431         }
16432         return ret_ref;
16433 }
16434
16435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16436         LDKCommitmentUpdate this_obj_conv;
16437         this_obj_conv.inner = (void*)(this_obj & (~1));
16438         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16439         CommitmentUpdate_free(this_obj_conv);
16440 }
16441
16442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16443         LDKCommitmentUpdate this_ptr_conv;
16444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16445         this_ptr_conv.is_owned = false;
16446         LDKCVec_UpdateAddHTLCZ val_constr;
16447         val_constr.datalen = (*env)->GetArrayLength(env, val);
16448         if (val_constr.datalen > 0)
16449                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
16450         else
16451                 val_constr.data = NULL;
16452         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16453         for (size_t p = 0; p < val_constr.datalen; p++) {
16454                 int64_t val_conv_15 = val_vals[p];
16455                 LDKUpdateAddHTLC val_conv_15_conv;
16456                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
16457                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
16458                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
16459                 val_constr.data[p] = val_conv_15_conv;
16460         }
16461         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16462         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
16463 }
16464
16465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16466         LDKCommitmentUpdate this_ptr_conv;
16467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16468         this_ptr_conv.is_owned = false;
16469         LDKCVec_UpdateFulfillHTLCZ val_constr;
16470         val_constr.datalen = (*env)->GetArrayLength(env, val);
16471         if (val_constr.datalen > 0)
16472                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
16473         else
16474                 val_constr.data = NULL;
16475         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16476         for (size_t t = 0; t < val_constr.datalen; t++) {
16477                 int64_t val_conv_19 = val_vals[t];
16478                 LDKUpdateFulfillHTLC val_conv_19_conv;
16479                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
16480                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
16481                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
16482                 val_constr.data[t] = val_conv_19_conv;
16483         }
16484         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16485         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
16486 }
16487
16488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16489         LDKCommitmentUpdate this_ptr_conv;
16490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16491         this_ptr_conv.is_owned = false;
16492         LDKCVec_UpdateFailHTLCZ val_constr;
16493         val_constr.datalen = (*env)->GetArrayLength(env, val);
16494         if (val_constr.datalen > 0)
16495                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
16496         else
16497                 val_constr.data = NULL;
16498         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16499         for (size_t q = 0; q < val_constr.datalen; q++) {
16500                 int64_t val_conv_16 = val_vals[q];
16501                 LDKUpdateFailHTLC val_conv_16_conv;
16502                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
16503                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
16504                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
16505                 val_constr.data[q] = val_conv_16_conv;
16506         }
16507         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16508         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
16509 }
16510
16511 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) {
16512         LDKCommitmentUpdate this_ptr_conv;
16513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16514         this_ptr_conv.is_owned = false;
16515         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
16516         val_constr.datalen = (*env)->GetArrayLength(env, val);
16517         if (val_constr.datalen > 0)
16518                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
16519         else
16520                 val_constr.data = NULL;
16521         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16522         for (size_t z = 0; z < val_constr.datalen; z++) {
16523                 int64_t val_conv_25 = val_vals[z];
16524                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
16525                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
16526                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
16527                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
16528                 val_constr.data[z] = val_conv_25_conv;
16529         }
16530         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16531         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
16532 }
16533
16534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
16535         LDKCommitmentUpdate this_ptr_conv;
16536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16537         this_ptr_conv.is_owned = false;
16538         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
16539         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16540         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16541         long ret_ref = (long)ret_var.inner;
16542         if (ret_var.is_owned) {
16543                 ret_ref |= 1;
16544         }
16545         return ret_ref;
16546 }
16547
16548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16549         LDKCommitmentUpdate this_ptr_conv;
16550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16551         this_ptr_conv.is_owned = false;
16552         LDKUpdateFee val_conv;
16553         val_conv.inner = (void*)(val & (~1));
16554         val_conv.is_owned = (val & 1) || (val == 0);
16555         val_conv = UpdateFee_clone(&val_conv);
16556         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
16557 }
16558
16559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
16560         LDKCommitmentUpdate this_ptr_conv;
16561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16562         this_ptr_conv.is_owned = false;
16563         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
16564         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16565         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16566         long ret_ref = (long)ret_var.inner;
16567         if (ret_var.is_owned) {
16568                 ret_ref |= 1;
16569         }
16570         return ret_ref;
16571 }
16572
16573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16574         LDKCommitmentUpdate this_ptr_conv;
16575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16576         this_ptr_conv.is_owned = false;
16577         LDKCommitmentSigned val_conv;
16578         val_conv.inner = (void*)(val & (~1));
16579         val_conv.is_owned = (val & 1) || (val == 0);
16580         val_conv = CommitmentSigned_clone(&val_conv);
16581         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
16582 }
16583
16584 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) {
16585         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
16586         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
16587         if (update_add_htlcs_arg_constr.datalen > 0)
16588                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
16589         else
16590                 update_add_htlcs_arg_constr.data = NULL;
16591         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
16592         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
16593                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
16594                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
16595                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
16596                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
16597                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
16598                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
16599         }
16600         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
16601         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
16602         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
16603         if (update_fulfill_htlcs_arg_constr.datalen > 0)
16604                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
16605         else
16606                 update_fulfill_htlcs_arg_constr.data = NULL;
16607         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
16608         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
16609                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
16610                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
16611                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
16612                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
16613                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
16614                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
16615         }
16616         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
16617         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
16618         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
16619         if (update_fail_htlcs_arg_constr.datalen > 0)
16620                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
16621         else
16622                 update_fail_htlcs_arg_constr.data = NULL;
16623         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
16624         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
16625                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
16626                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
16627                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
16628                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
16629                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
16630                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
16631         }
16632         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
16633         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
16634         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
16635         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
16636                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
16637         else
16638                 update_fail_malformed_htlcs_arg_constr.data = NULL;
16639         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
16640         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
16641                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
16642                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
16643                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
16644                 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);
16645                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
16646                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
16647         }
16648         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
16649         LDKUpdateFee update_fee_arg_conv;
16650         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
16651         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
16652         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
16653         LDKCommitmentSigned commitment_signed_arg_conv;
16654         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
16655         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
16656         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
16657         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);
16658         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16659         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16660         long ret_ref = (long)ret_var.inner;
16661         if (ret_var.is_owned) {
16662                 ret_ref |= 1;
16663         }
16664         return ret_ref;
16665 }
16666
16667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16668         LDKCommitmentUpdate orig_conv;
16669         orig_conv.inner = (void*)(orig & (~1));
16670         orig_conv.is_owned = false;
16671         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
16672         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16673         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16674         long ret_ref = (long)ret_var.inner;
16675         if (ret_var.is_owned) {
16676                 ret_ref |= 1;
16677         }
16678         return ret_ref;
16679 }
16680
16681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16682         if ((this_ptr & 1) != 0) return;
16683         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
16684         FREE((void*)this_ptr);
16685         HTLCFailChannelUpdate_free(this_ptr_conv);
16686 }
16687
16688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16689         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
16690         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
16691         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
16692         long ret_ref = (long)ret_copy;
16693         return ret_ref;
16694 }
16695
16696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16697         if ((this_ptr & 1) != 0) return;
16698         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
16699         FREE((void*)this_ptr);
16700         ChannelMessageHandler_free(this_ptr_conv);
16701 }
16702
16703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16704         if ((this_ptr & 1) != 0) return;
16705         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
16706         FREE((void*)this_ptr);
16707         RoutingMessageHandler_free(this_ptr_conv);
16708 }
16709
16710 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
16711         LDKAcceptChannel obj_conv;
16712         obj_conv.inner = (void*)(obj & (~1));
16713         obj_conv.is_owned = false;
16714         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
16715         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16716         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16717         CVec_u8Z_free(ret_var);
16718         return ret_arr;
16719 }
16720
16721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16722         LDKu8slice ser_ref;
16723         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16724         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16725         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
16726         *ret_conv = AcceptChannel_read(ser_ref);
16727         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16728         return (long)ret_conv;
16729 }
16730
16731 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
16732         LDKAnnouncementSignatures obj_conv;
16733         obj_conv.inner = (void*)(obj & (~1));
16734         obj_conv.is_owned = false;
16735         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
16736         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16737         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16738         CVec_u8Z_free(ret_var);
16739         return ret_arr;
16740 }
16741
16742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16743         LDKu8slice ser_ref;
16744         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16745         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16746         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
16747         *ret_conv = AnnouncementSignatures_read(ser_ref);
16748         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16749         return (long)ret_conv;
16750 }
16751
16752 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
16753         LDKChannelReestablish obj_conv;
16754         obj_conv.inner = (void*)(obj & (~1));
16755         obj_conv.is_owned = false;
16756         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
16757         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16758         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16759         CVec_u8Z_free(ret_var);
16760         return ret_arr;
16761 }
16762
16763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16764         LDKu8slice ser_ref;
16765         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16766         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16767         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
16768         *ret_conv = ChannelReestablish_read(ser_ref);
16769         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16770         return (long)ret_conv;
16771 }
16772
16773 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
16774         LDKClosingSigned obj_conv;
16775         obj_conv.inner = (void*)(obj & (~1));
16776         obj_conv.is_owned = false;
16777         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
16778         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16779         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16780         CVec_u8Z_free(ret_var);
16781         return ret_arr;
16782 }
16783
16784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16785         LDKu8slice ser_ref;
16786         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16787         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16788         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
16789         *ret_conv = ClosingSigned_read(ser_ref);
16790         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16791         return (long)ret_conv;
16792 }
16793
16794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
16795         LDKCommitmentSigned obj_conv;
16796         obj_conv.inner = (void*)(obj & (~1));
16797         obj_conv.is_owned = false;
16798         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
16799         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16800         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16801         CVec_u8Z_free(ret_var);
16802         return ret_arr;
16803 }
16804
16805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16806         LDKu8slice ser_ref;
16807         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16808         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16809         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
16810         *ret_conv = CommitmentSigned_read(ser_ref);
16811         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16812         return (long)ret_conv;
16813 }
16814
16815 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
16816         LDKFundingCreated obj_conv;
16817         obj_conv.inner = (void*)(obj & (~1));
16818         obj_conv.is_owned = false;
16819         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
16820         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16821         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16822         CVec_u8Z_free(ret_var);
16823         return ret_arr;
16824 }
16825
16826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16827         LDKu8slice ser_ref;
16828         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16829         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16830         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
16831         *ret_conv = FundingCreated_read(ser_ref);
16832         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16833         return (long)ret_conv;
16834 }
16835
16836 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
16837         LDKFundingSigned obj_conv;
16838         obj_conv.inner = (void*)(obj & (~1));
16839         obj_conv.is_owned = false;
16840         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
16841         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16842         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16843         CVec_u8Z_free(ret_var);
16844         return ret_arr;
16845 }
16846
16847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16848         LDKu8slice ser_ref;
16849         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16850         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16851         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
16852         *ret_conv = FundingSigned_read(ser_ref);
16853         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16854         return (long)ret_conv;
16855 }
16856
16857 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
16858         LDKFundingLocked obj_conv;
16859         obj_conv.inner = (void*)(obj & (~1));
16860         obj_conv.is_owned = false;
16861         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
16862         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16863         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16864         CVec_u8Z_free(ret_var);
16865         return ret_arr;
16866 }
16867
16868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16869         LDKu8slice ser_ref;
16870         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16871         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16872         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
16873         *ret_conv = FundingLocked_read(ser_ref);
16874         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16875         return (long)ret_conv;
16876 }
16877
16878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
16879         LDKInit obj_conv;
16880         obj_conv.inner = (void*)(obj & (~1));
16881         obj_conv.is_owned = false;
16882         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
16883         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16884         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16885         CVec_u8Z_free(ret_var);
16886         return ret_arr;
16887 }
16888
16889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16890         LDKu8slice ser_ref;
16891         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16892         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16893         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
16894         *ret_conv = Init_read(ser_ref);
16895         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16896         return (long)ret_conv;
16897 }
16898
16899 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
16900         LDKOpenChannel obj_conv;
16901         obj_conv.inner = (void*)(obj & (~1));
16902         obj_conv.is_owned = false;
16903         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
16904         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16905         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16906         CVec_u8Z_free(ret_var);
16907         return ret_arr;
16908 }
16909
16910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16911         LDKu8slice ser_ref;
16912         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16913         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16914         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
16915         *ret_conv = OpenChannel_read(ser_ref);
16916         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16917         return (long)ret_conv;
16918 }
16919
16920 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
16921         LDKRevokeAndACK obj_conv;
16922         obj_conv.inner = (void*)(obj & (~1));
16923         obj_conv.is_owned = false;
16924         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
16925         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16926         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16927         CVec_u8Z_free(ret_var);
16928         return ret_arr;
16929 }
16930
16931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16932         LDKu8slice ser_ref;
16933         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16934         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16935         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
16936         *ret_conv = RevokeAndACK_read(ser_ref);
16937         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16938         return (long)ret_conv;
16939 }
16940
16941 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
16942         LDKShutdown obj_conv;
16943         obj_conv.inner = (void*)(obj & (~1));
16944         obj_conv.is_owned = false;
16945         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
16946         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16947         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16948         CVec_u8Z_free(ret_var);
16949         return ret_arr;
16950 }
16951
16952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16953         LDKu8slice ser_ref;
16954         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16955         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16956         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
16957         *ret_conv = Shutdown_read(ser_ref);
16958         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16959         return (long)ret_conv;
16960 }
16961
16962 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
16963         LDKUpdateFailHTLC obj_conv;
16964         obj_conv.inner = (void*)(obj & (~1));
16965         obj_conv.is_owned = false;
16966         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
16967         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16968         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16969         CVec_u8Z_free(ret_var);
16970         return ret_arr;
16971 }
16972
16973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16974         LDKu8slice ser_ref;
16975         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16976         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16977         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
16978         *ret_conv = UpdateFailHTLC_read(ser_ref);
16979         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16980         return (long)ret_conv;
16981 }
16982
16983 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
16984         LDKUpdateFailMalformedHTLC obj_conv;
16985         obj_conv.inner = (void*)(obj & (~1));
16986         obj_conv.is_owned = false;
16987         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
16988         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16989         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16990         CVec_u8Z_free(ret_var);
16991         return ret_arr;
16992 }
16993
16994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16995         LDKu8slice ser_ref;
16996         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16997         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16998         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
16999         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
17000         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17001         return (long)ret_conv;
17002 }
17003
17004 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
17005         LDKUpdateFee obj_conv;
17006         obj_conv.inner = (void*)(obj & (~1));
17007         obj_conv.is_owned = false;
17008         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
17009         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17010         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17011         CVec_u8Z_free(ret_var);
17012         return ret_arr;
17013 }
17014
17015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17016         LDKu8slice ser_ref;
17017         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17018         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17019         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
17020         *ret_conv = UpdateFee_read(ser_ref);
17021         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17022         return (long)ret_conv;
17023 }
17024
17025 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
17026         LDKUpdateFulfillHTLC obj_conv;
17027         obj_conv.inner = (void*)(obj & (~1));
17028         obj_conv.is_owned = false;
17029         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
17030         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17031         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17032         CVec_u8Z_free(ret_var);
17033         return ret_arr;
17034 }
17035
17036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17037         LDKu8slice ser_ref;
17038         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17039         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17040         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
17041         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
17042         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17043         return (long)ret_conv;
17044 }
17045
17046 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
17047         LDKUpdateAddHTLC obj_conv;
17048         obj_conv.inner = (void*)(obj & (~1));
17049         obj_conv.is_owned = false;
17050         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
17051         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17052         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17053         CVec_u8Z_free(ret_var);
17054         return ret_arr;
17055 }
17056
17057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17058         LDKu8slice ser_ref;
17059         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17060         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17061         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
17062         *ret_conv = UpdateAddHTLC_read(ser_ref);
17063         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17064         return (long)ret_conv;
17065 }
17066
17067 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
17068         LDKPing obj_conv;
17069         obj_conv.inner = (void*)(obj & (~1));
17070         obj_conv.is_owned = false;
17071         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
17072         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17073         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17074         CVec_u8Z_free(ret_var);
17075         return ret_arr;
17076 }
17077
17078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17079         LDKu8slice ser_ref;
17080         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17081         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17082         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
17083         *ret_conv = Ping_read(ser_ref);
17084         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17085         return (long)ret_conv;
17086 }
17087
17088 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
17089         LDKPong obj_conv;
17090         obj_conv.inner = (void*)(obj & (~1));
17091         obj_conv.is_owned = false;
17092         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
17093         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17094         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17095         CVec_u8Z_free(ret_var);
17096         return ret_arr;
17097 }
17098
17099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17100         LDKu8slice ser_ref;
17101         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17102         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17103         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
17104         *ret_conv = Pong_read(ser_ref);
17105         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17106         return (long)ret_conv;
17107 }
17108
17109 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17110         LDKUnsignedChannelAnnouncement obj_conv;
17111         obj_conv.inner = (void*)(obj & (~1));
17112         obj_conv.is_owned = false;
17113         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
17114         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17115         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17116         CVec_u8Z_free(ret_var);
17117         return ret_arr;
17118 }
17119
17120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17121         LDKu8slice ser_ref;
17122         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17123         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17124         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
17125         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
17126         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17127         return (long)ret_conv;
17128 }
17129
17130 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17131         LDKChannelAnnouncement obj_conv;
17132         obj_conv.inner = (void*)(obj & (~1));
17133         obj_conv.is_owned = false;
17134         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
17135         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17136         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17137         CVec_u8Z_free(ret_var);
17138         return ret_arr;
17139 }
17140
17141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17142         LDKu8slice ser_ref;
17143         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17144         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17145         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
17146         *ret_conv = ChannelAnnouncement_read(ser_ref);
17147         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17148         return (long)ret_conv;
17149 }
17150
17151 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
17152         LDKUnsignedChannelUpdate obj_conv;
17153         obj_conv.inner = (void*)(obj & (~1));
17154         obj_conv.is_owned = false;
17155         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
17156         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17157         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17158         CVec_u8Z_free(ret_var);
17159         return ret_arr;
17160 }
17161
17162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17163         LDKu8slice ser_ref;
17164         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17165         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17166         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
17167         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
17168         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17169         return (long)ret_conv;
17170 }
17171
17172 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
17173         LDKChannelUpdate obj_conv;
17174         obj_conv.inner = (void*)(obj & (~1));
17175         obj_conv.is_owned = false;
17176         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
17177         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17178         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17179         CVec_u8Z_free(ret_var);
17180         return ret_arr;
17181 }
17182
17183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17184         LDKu8slice ser_ref;
17185         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17186         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17187         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
17188         *ret_conv = ChannelUpdate_read(ser_ref);
17189         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17190         return (long)ret_conv;
17191 }
17192
17193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
17194         LDKErrorMessage obj_conv;
17195         obj_conv.inner = (void*)(obj & (~1));
17196         obj_conv.is_owned = false;
17197         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
17198         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17199         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17200         CVec_u8Z_free(ret_var);
17201         return ret_arr;
17202 }
17203
17204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17205         LDKu8slice ser_ref;
17206         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17207         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17208         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
17209         *ret_conv = ErrorMessage_read(ser_ref);
17210         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17211         return (long)ret_conv;
17212 }
17213
17214 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17215         LDKUnsignedNodeAnnouncement obj_conv;
17216         obj_conv.inner = (void*)(obj & (~1));
17217         obj_conv.is_owned = false;
17218         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
17219         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17220         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17221         CVec_u8Z_free(ret_var);
17222         return ret_arr;
17223 }
17224
17225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17226         LDKu8slice ser_ref;
17227         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17228         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17229         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
17230         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
17231         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17232         return (long)ret_conv;
17233 }
17234
17235 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17236         LDKNodeAnnouncement obj_conv;
17237         obj_conv.inner = (void*)(obj & (~1));
17238         obj_conv.is_owned = false;
17239         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
17240         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17241         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17242         CVec_u8Z_free(ret_var);
17243         return ret_arr;
17244 }
17245
17246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17247         LDKu8slice ser_ref;
17248         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17249         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17250         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
17251         *ret_conv = NodeAnnouncement_read(ser_ref);
17252         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17253         return (long)ret_conv;
17254 }
17255
17256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17257         LDKu8slice ser_ref;
17258         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17259         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17260         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
17261         *ret_conv = QueryShortChannelIds_read(ser_ref);
17262         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17263         return (long)ret_conv;
17264 }
17265
17266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
17267         LDKQueryShortChannelIds obj_conv;
17268         obj_conv.inner = (void*)(obj & (~1));
17269         obj_conv.is_owned = false;
17270         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
17271         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17272         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17273         CVec_u8Z_free(ret_var);
17274         return ret_arr;
17275 }
17276
17277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17278         LDKu8slice ser_ref;
17279         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17280         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17281         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
17282         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
17283         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17284         return (long)ret_conv;
17285 }
17286
17287 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
17288         LDKReplyShortChannelIdsEnd obj_conv;
17289         obj_conv.inner = (void*)(obj & (~1));
17290         obj_conv.is_owned = false;
17291         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
17292         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17293         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17294         CVec_u8Z_free(ret_var);
17295         return ret_arr;
17296 }
17297
17298 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
17299         LDKQueryChannelRange this_arg_conv;
17300         this_arg_conv.inner = (void*)(this_arg & (~1));
17301         this_arg_conv.is_owned = false;
17302         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
17303         return ret_val;
17304 }
17305
17306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17307         LDKu8slice ser_ref;
17308         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17309         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17310         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
17311         *ret_conv = QueryChannelRange_read(ser_ref);
17312         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17313         return (long)ret_conv;
17314 }
17315
17316 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
17317         LDKQueryChannelRange obj_conv;
17318         obj_conv.inner = (void*)(obj & (~1));
17319         obj_conv.is_owned = false;
17320         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
17321         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17322         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17323         CVec_u8Z_free(ret_var);
17324         return ret_arr;
17325 }
17326
17327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17328         LDKu8slice ser_ref;
17329         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17330         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17331         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
17332         *ret_conv = ReplyChannelRange_read(ser_ref);
17333         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17334         return (long)ret_conv;
17335 }
17336
17337 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
17338         LDKReplyChannelRange obj_conv;
17339         obj_conv.inner = (void*)(obj & (~1));
17340         obj_conv.is_owned = false;
17341         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
17342         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17343         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17344         CVec_u8Z_free(ret_var);
17345         return ret_arr;
17346 }
17347
17348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17349         LDKu8slice ser_ref;
17350         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17351         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17352         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
17353         *ret_conv = GossipTimestampFilter_read(ser_ref);
17354         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17355         return (long)ret_conv;
17356 }
17357
17358 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
17359         LDKGossipTimestampFilter obj_conv;
17360         obj_conv.inner = (void*)(obj & (~1));
17361         obj_conv.is_owned = false;
17362         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
17363         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17364         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17365         CVec_u8Z_free(ret_var);
17366         return ret_arr;
17367 }
17368
17369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17370         LDKIgnoringMessageHandler this_obj_conv;
17371         this_obj_conv.inner = (void*)(this_obj & (~1));
17372         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17373         IgnoringMessageHandler_free(this_obj_conv);
17374 }
17375
17376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
17377         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
17378         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17379         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17380         long ret_ref = (long)ret_var.inner;
17381         if (ret_var.is_owned) {
17382                 ret_ref |= 1;
17383         }
17384         return ret_ref;
17385 }
17386
17387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17388         LDKIgnoringMessageHandler this_arg_conv;
17389         this_arg_conv.inner = (void*)(this_arg & (~1));
17390         this_arg_conv.is_owned = false;
17391         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
17392         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
17393         return (long)ret;
17394 }
17395
17396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
17397         LDKIgnoringMessageHandler this_arg_conv;
17398         this_arg_conv.inner = (void*)(this_arg & (~1));
17399         this_arg_conv.is_owned = false;
17400         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
17401         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
17402         return (long)ret;
17403 }
17404
17405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17406         LDKErroringMessageHandler this_obj_conv;
17407         this_obj_conv.inner = (void*)(this_obj & (~1));
17408         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17409         ErroringMessageHandler_free(this_obj_conv);
17410 }
17411
17412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
17413         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
17414         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17415         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17416         long ret_ref = (long)ret_var.inner;
17417         if (ret_var.is_owned) {
17418                 ret_ref |= 1;
17419         }
17420         return ret_ref;
17421 }
17422
17423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17424         LDKErroringMessageHandler this_arg_conv;
17425         this_arg_conv.inner = (void*)(this_arg & (~1));
17426         this_arg_conv.is_owned = false;
17427         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
17428         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
17429         return (long)ret;
17430 }
17431
17432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
17433         LDKErroringMessageHandler this_arg_conv;
17434         this_arg_conv.inner = (void*)(this_arg & (~1));
17435         this_arg_conv.is_owned = false;
17436         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
17437         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
17438         return (long)ret;
17439 }
17440
17441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17442         LDKMessageHandler this_obj_conv;
17443         this_obj_conv.inner = (void*)(this_obj & (~1));
17444         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17445         MessageHandler_free(this_obj_conv);
17446 }
17447
17448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
17449         LDKMessageHandler this_ptr_conv;
17450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17451         this_ptr_conv.is_owned = false;
17452         long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
17453         return ret_ret;
17454 }
17455
17456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17457         LDKMessageHandler this_ptr_conv;
17458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17459         this_ptr_conv.is_owned = false;
17460         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
17461         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
17462                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17463                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
17464         }
17465         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
17466 }
17467
17468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
17469         LDKMessageHandler this_ptr_conv;
17470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17471         this_ptr_conv.is_owned = false;
17472         long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
17473         return ret_ret;
17474 }
17475
17476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17477         LDKMessageHandler this_ptr_conv;
17478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17479         this_ptr_conv.is_owned = false;
17480         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
17481         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
17482                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17483                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
17484         }
17485         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
17486 }
17487
17488 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) {
17489         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
17490         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
17491                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17492                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
17493         }
17494         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
17495         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
17496                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17497                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
17498         }
17499         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
17500         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17501         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17502         long ret_ref = (long)ret_var.inner;
17503         if (ret_var.is_owned) {
17504                 ret_ref |= 1;
17505         }
17506         return ret_ref;
17507 }
17508
17509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17510         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
17511         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
17512         *ret = SocketDescriptor_clone(orig_conv);
17513         return (long)ret;
17514 }
17515
17516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17517         if ((this_ptr & 1) != 0) return;
17518         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
17519         FREE((void*)this_ptr);
17520         SocketDescriptor_free(this_ptr_conv);
17521 }
17522
17523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17524         LDKPeerHandleError this_obj_conv;
17525         this_obj_conv.inner = (void*)(this_obj & (~1));
17526         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17527         PeerHandleError_free(this_obj_conv);
17528 }
17529
17530 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
17531         LDKPeerHandleError this_ptr_conv;
17532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17533         this_ptr_conv.is_owned = false;
17534         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
17535         return ret_val;
17536 }
17537
17538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
17539         LDKPeerHandleError this_ptr_conv;
17540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17541         this_ptr_conv.is_owned = false;
17542         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
17543 }
17544
17545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
17546         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
17547         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17548         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17549         long ret_ref = (long)ret_var.inner;
17550         if (ret_var.is_owned) {
17551                 ret_ref |= 1;
17552         }
17553         return ret_ref;
17554 }
17555
17556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17557         LDKPeerHandleError orig_conv;
17558         orig_conv.inner = (void*)(orig & (~1));
17559         orig_conv.is_owned = false;
17560         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
17561         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17562         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17563         long ret_ref = (long)ret_var.inner;
17564         if (ret_var.is_owned) {
17565                 ret_ref |= 1;
17566         }
17567         return ret_ref;
17568 }
17569
17570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17571         LDKPeerManager this_obj_conv;
17572         this_obj_conv.inner = (void*)(this_obj & (~1));
17573         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17574         PeerManager_free(this_obj_conv);
17575 }
17576
17577 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) {
17578         LDKMessageHandler message_handler_conv;
17579         message_handler_conv.inner = (void*)(message_handler & (~1));
17580         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
17581         // Warning: we need a move here but no clone is available for LDKMessageHandler
17582         LDKSecretKey our_node_secret_ref;
17583         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
17584         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
17585         unsigned char ephemeral_random_data_arr[32];
17586         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
17587         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
17588         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
17589         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17590         if (logger_conv.free == LDKLogger_JCalls_free) {
17591                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17592                 LDKLogger_JCalls_clone(logger_conv.this_arg);
17593         }
17594         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
17595         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17596         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17597         long ret_ref = (long)ret_var.inner;
17598         if (ret_var.is_owned) {
17599                 ret_ref |= 1;
17600         }
17601         return ret_ref;
17602 }
17603
17604 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
17605         LDKPeerManager this_arg_conv;
17606         this_arg_conv.inner = (void*)(this_arg & (~1));
17607         this_arg_conv.is_owned = false;
17608         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
17609         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
17610         ;
17611         for (size_t i = 0; i < ret_var.datalen; i++) {
17612                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
17613                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
17614                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
17615         }
17616         FREE(ret_var.data);
17617         return ret_arr;
17618 }
17619
17620 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) {
17621         LDKPeerManager this_arg_conv;
17622         this_arg_conv.inner = (void*)(this_arg & (~1));
17623         this_arg_conv.is_owned = false;
17624         LDKPublicKey their_node_id_ref;
17625         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
17626         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
17627         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
17628         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
17629                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17630                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
17631         }
17632         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
17633         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
17634         return (long)ret_conv;
17635 }
17636
17637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
17638         LDKPeerManager this_arg_conv;
17639         this_arg_conv.inner = (void*)(this_arg & (~1));
17640         this_arg_conv.is_owned = false;
17641         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
17642         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
17643                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17644                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
17645         }
17646         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
17647         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
17648         return (long)ret_conv;
17649 }
17650
17651 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) {
17652         LDKPeerManager this_arg_conv;
17653         this_arg_conv.inner = (void*)(this_arg & (~1));
17654         this_arg_conv.is_owned = false;
17655         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
17656         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
17657         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
17658         return (long)ret_conv;
17659 }
17660
17661 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) {
17662         LDKPeerManager this_arg_conv;
17663         this_arg_conv.inner = (void*)(this_arg & (~1));
17664         this_arg_conv.is_owned = false;
17665         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
17666         LDKu8slice data_ref;
17667         data_ref.datalen = (*env)->GetArrayLength(env, data);
17668         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
17669         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
17670         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
17671         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
17672         return (long)ret_conv;
17673 }
17674
17675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
17676         LDKPeerManager this_arg_conv;
17677         this_arg_conv.inner = (void*)(this_arg & (~1));
17678         this_arg_conv.is_owned = false;
17679         PeerManager_process_events(&this_arg_conv);
17680 }
17681
17682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
17683         LDKPeerManager this_arg_conv;
17684         this_arg_conv.inner = (void*)(this_arg & (~1));
17685         this_arg_conv.is_owned = false;
17686         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
17687         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
17688 }
17689
17690 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) {
17691         LDKPeerManager this_arg_conv;
17692         this_arg_conv.inner = (void*)(this_arg & (~1));
17693         this_arg_conv.is_owned = false;
17694         LDKPublicKey node_id_ref;
17695         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17696         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17697         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
17698 }
17699
17700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
17701         LDKPeerManager this_arg_conv;
17702         this_arg_conv.inner = (void*)(this_arg & (~1));
17703         this_arg_conv.is_owned = false;
17704         PeerManager_timer_tick_occurred(&this_arg_conv);
17705 }
17706
17707 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
17708         unsigned char commitment_seed_arr[32];
17709         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
17710         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
17711         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
17712         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17713         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
17714         return ret_arr;
17715 }
17716
17717 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) {
17718         LDKPublicKey per_commitment_point_ref;
17719         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
17720         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17721         unsigned char base_secret_arr[32];
17722         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
17723         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
17724         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
17725         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
17726         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
17727         return (long)ret_conv;
17728 }
17729
17730 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) {
17731         LDKPublicKey per_commitment_point_ref;
17732         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
17733         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17734         LDKPublicKey base_point_ref;
17735         CHECK((*env)->GetArrayLength(env, base_point) == 33);
17736         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
17737         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
17738         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
17739         return (long)ret_conv;
17740 }
17741
17742 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) {
17743         unsigned char per_commitment_secret_arr[32];
17744         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
17745         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
17746         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
17747         unsigned char countersignatory_revocation_base_secret_arr[32];
17748         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
17749         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
17750         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
17751         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
17752         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
17753         return (long)ret_conv;
17754 }
17755
17756 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) {
17757         LDKPublicKey per_commitment_point_ref;
17758         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
17759         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17760         LDKPublicKey countersignatory_revocation_base_point_ref;
17761         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
17762         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
17763         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
17764         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
17765         return (long)ret_conv;
17766 }
17767
17768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17769         LDKTxCreationKeys this_obj_conv;
17770         this_obj_conv.inner = (void*)(this_obj & (~1));
17771         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17772         TxCreationKeys_free(this_obj_conv);
17773 }
17774
17775 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17776         LDKTxCreationKeys this_ptr_conv;
17777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17778         this_ptr_conv.is_owned = false;
17779         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17780         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
17781         return ret_arr;
17782 }
17783
17784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17785         LDKTxCreationKeys this_ptr_conv;
17786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17787         this_ptr_conv.is_owned = false;
17788         LDKPublicKey val_ref;
17789         CHECK((*env)->GetArrayLength(env, val) == 33);
17790         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17791         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
17792 }
17793
17794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17795         LDKTxCreationKeys this_ptr_conv;
17796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17797         this_ptr_conv.is_owned = false;
17798         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17799         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
17800         return ret_arr;
17801 }
17802
17803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17804         LDKTxCreationKeys this_ptr_conv;
17805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17806         this_ptr_conv.is_owned = false;
17807         LDKPublicKey val_ref;
17808         CHECK((*env)->GetArrayLength(env, val) == 33);
17809         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17810         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
17811 }
17812
17813 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17814         LDKTxCreationKeys this_ptr_conv;
17815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17816         this_ptr_conv.is_owned = false;
17817         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17818         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
17819         return ret_arr;
17820 }
17821
17822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17823         LDKTxCreationKeys this_ptr_conv;
17824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17825         this_ptr_conv.is_owned = false;
17826         LDKPublicKey val_ref;
17827         CHECK((*env)->GetArrayLength(env, val) == 33);
17828         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17829         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
17830 }
17831
17832 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17833         LDKTxCreationKeys this_ptr_conv;
17834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17835         this_ptr_conv.is_owned = false;
17836         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17837         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
17838         return ret_arr;
17839 }
17840
17841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17842         LDKTxCreationKeys this_ptr_conv;
17843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17844         this_ptr_conv.is_owned = false;
17845         LDKPublicKey val_ref;
17846         CHECK((*env)->GetArrayLength(env, val) == 33);
17847         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17848         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
17849 }
17850
17851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17852         LDKTxCreationKeys this_ptr_conv;
17853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17854         this_ptr_conv.is_owned = false;
17855         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17856         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
17857         return ret_arr;
17858 }
17859
17860 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) {
17861         LDKTxCreationKeys this_ptr_conv;
17862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17863         this_ptr_conv.is_owned = false;
17864         LDKPublicKey val_ref;
17865         CHECK((*env)->GetArrayLength(env, val) == 33);
17866         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17867         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
17868 }
17869
17870 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) {
17871         LDKPublicKey per_commitment_point_arg_ref;
17872         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
17873         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
17874         LDKPublicKey revocation_key_arg_ref;
17875         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
17876         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
17877         LDKPublicKey broadcaster_htlc_key_arg_ref;
17878         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
17879         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
17880         LDKPublicKey countersignatory_htlc_key_arg_ref;
17881         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
17882         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
17883         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
17884         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
17885         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
17886         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);
17887         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17888         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17889         long ret_ref = (long)ret_var.inner;
17890         if (ret_var.is_owned) {
17891                 ret_ref |= 1;
17892         }
17893         return ret_ref;
17894 }
17895
17896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17897         LDKTxCreationKeys orig_conv;
17898         orig_conv.inner = (void*)(orig & (~1));
17899         orig_conv.is_owned = false;
17900         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
17901         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17902         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17903         long ret_ref = (long)ret_var.inner;
17904         if (ret_var.is_owned) {
17905                 ret_ref |= 1;
17906         }
17907         return ret_ref;
17908 }
17909
17910 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
17911         LDKTxCreationKeys obj_conv;
17912         obj_conv.inner = (void*)(obj & (~1));
17913         obj_conv.is_owned = false;
17914         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
17915         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17916         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17917         CVec_u8Z_free(ret_var);
17918         return ret_arr;
17919 }
17920
17921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17922         LDKu8slice ser_ref;
17923         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17924         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17925         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
17926         *ret_conv = TxCreationKeys_read(ser_ref);
17927         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17928         return (long)ret_conv;
17929 }
17930
17931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17932         LDKChannelPublicKeys this_obj_conv;
17933         this_obj_conv.inner = (void*)(this_obj & (~1));
17934         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17935         ChannelPublicKeys_free(this_obj_conv);
17936 }
17937
17938 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17939         LDKChannelPublicKeys this_ptr_conv;
17940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17941         this_ptr_conv.is_owned = false;
17942         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17943         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
17944         return ret_arr;
17945 }
17946
17947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17948         LDKChannelPublicKeys this_ptr_conv;
17949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17950         this_ptr_conv.is_owned = false;
17951         LDKPublicKey val_ref;
17952         CHECK((*env)->GetArrayLength(env, val) == 33);
17953         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17954         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
17955 }
17956
17957 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17958         LDKChannelPublicKeys this_ptr_conv;
17959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17960         this_ptr_conv.is_owned = false;
17961         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17962         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
17963         return ret_arr;
17964 }
17965
17966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17967         LDKChannelPublicKeys this_ptr_conv;
17968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17969         this_ptr_conv.is_owned = false;
17970         LDKPublicKey val_ref;
17971         CHECK((*env)->GetArrayLength(env, val) == 33);
17972         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17973         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
17974 }
17975
17976 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17977         LDKChannelPublicKeys this_ptr_conv;
17978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17979         this_ptr_conv.is_owned = false;
17980         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17981         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
17982         return ret_arr;
17983 }
17984
17985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17986         LDKChannelPublicKeys this_ptr_conv;
17987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17988         this_ptr_conv.is_owned = false;
17989         LDKPublicKey val_ref;
17990         CHECK((*env)->GetArrayLength(env, val) == 33);
17991         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17992         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
17993 }
17994
17995 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17996         LDKChannelPublicKeys this_ptr_conv;
17997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17998         this_ptr_conv.is_owned = false;
17999         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18000         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
18001         return ret_arr;
18002 }
18003
18004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18005         LDKChannelPublicKeys this_ptr_conv;
18006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18007         this_ptr_conv.is_owned = false;
18008         LDKPublicKey val_ref;
18009         CHECK((*env)->GetArrayLength(env, val) == 33);
18010         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18011         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
18012 }
18013
18014 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18015         LDKChannelPublicKeys this_ptr_conv;
18016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18017         this_ptr_conv.is_owned = false;
18018         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18019         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
18020         return ret_arr;
18021 }
18022
18023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18024         LDKChannelPublicKeys this_ptr_conv;
18025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18026         this_ptr_conv.is_owned = false;
18027         LDKPublicKey val_ref;
18028         CHECK((*env)->GetArrayLength(env, val) == 33);
18029         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18030         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
18031 }
18032
18033 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) {
18034         LDKPublicKey funding_pubkey_arg_ref;
18035         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
18036         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
18037         LDKPublicKey revocation_basepoint_arg_ref;
18038         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
18039         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
18040         LDKPublicKey payment_point_arg_ref;
18041         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
18042         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
18043         LDKPublicKey delayed_payment_basepoint_arg_ref;
18044         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
18045         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
18046         LDKPublicKey htlc_basepoint_arg_ref;
18047         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
18048         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
18049         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);
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_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18060         LDKChannelPublicKeys orig_conv;
18061         orig_conv.inner = (void*)(orig & (~1));
18062         orig_conv.is_owned = false;
18063         LDKChannelPublicKeys ret_var = ChannelPublicKeys_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 int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
18074         LDKChannelPublicKeys obj_conv;
18075         obj_conv.inner = (void*)(obj & (~1));
18076         obj_conv.is_owned = false;
18077         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
18078         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18079         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18080         CVec_u8Z_free(ret_var);
18081         return ret_arr;
18082 }
18083
18084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18085         LDKu8slice ser_ref;
18086         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18087         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18088         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
18089         *ret_conv = ChannelPublicKeys_read(ser_ref);
18090         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18091         return (long)ret_conv;
18092 }
18093
18094 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) {
18095         LDKPublicKey per_commitment_point_ref;
18096         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
18097         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
18098         LDKPublicKey broadcaster_delayed_payment_base_ref;
18099         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
18100         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
18101         LDKPublicKey broadcaster_htlc_base_ref;
18102         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
18103         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
18104         LDKPublicKey countersignatory_revocation_base_ref;
18105         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
18106         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
18107         LDKPublicKey countersignatory_htlc_base_ref;
18108         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
18109         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
18110         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
18111         *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);
18112         return (long)ret_conv;
18113 }
18114
18115 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) {
18116         LDKPublicKey per_commitment_point_ref;
18117         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
18118         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
18119         LDKChannelPublicKeys broadcaster_keys_conv;
18120         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
18121         broadcaster_keys_conv.is_owned = false;
18122         LDKChannelPublicKeys countersignatory_keys_conv;
18123         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
18124         countersignatory_keys_conv.is_owned = false;
18125         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
18126         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
18127         return (long)ret_conv;
18128 }
18129
18130 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) {
18131         LDKPublicKey revocation_key_ref;
18132         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
18133         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
18134         LDKPublicKey broadcaster_delayed_payment_key_ref;
18135         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
18136         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
18137         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
18138         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18139         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18140         CVec_u8Z_free(ret_var);
18141         return ret_arr;
18142 }
18143
18144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18145         LDKHTLCOutputInCommitment this_obj_conv;
18146         this_obj_conv.inner = (void*)(this_obj & (~1));
18147         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18148         HTLCOutputInCommitment_free(this_obj_conv);
18149 }
18150
18151 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
18152         LDKHTLCOutputInCommitment this_ptr_conv;
18153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18154         this_ptr_conv.is_owned = false;
18155         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
18156         return ret_val;
18157 }
18158
18159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18160         LDKHTLCOutputInCommitment this_ptr_conv;
18161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18162         this_ptr_conv.is_owned = false;
18163         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
18164 }
18165
18166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18167         LDKHTLCOutputInCommitment this_ptr_conv;
18168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18169         this_ptr_conv.is_owned = false;
18170         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
18171         return ret_val;
18172 }
18173
18174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18175         LDKHTLCOutputInCommitment this_ptr_conv;
18176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18177         this_ptr_conv.is_owned = false;
18178         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
18179 }
18180
18181 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
18182         LDKHTLCOutputInCommitment this_ptr_conv;
18183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18184         this_ptr_conv.is_owned = false;
18185         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
18186         return ret_val;
18187 }
18188
18189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18190         LDKHTLCOutputInCommitment this_ptr_conv;
18191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18192         this_ptr_conv.is_owned = false;
18193         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
18194 }
18195
18196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18197         LDKHTLCOutputInCommitment this_ptr_conv;
18198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18199         this_ptr_conv.is_owned = false;
18200         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18201         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
18202         return ret_arr;
18203 }
18204
18205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18206         LDKHTLCOutputInCommitment this_ptr_conv;
18207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18208         this_ptr_conv.is_owned = false;
18209         LDKThirtyTwoBytes val_ref;
18210         CHECK((*env)->GetArrayLength(env, val) == 32);
18211         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18212         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
18213 }
18214
18215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
18216         LDKHTLCOutputInCommitment this_ptr_conv;
18217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18218         this_ptr_conv.is_owned = false;
18219         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
18220         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
18221         long ret_ref = (long)ret_copy;
18222         return ret_ref;
18223 }
18224
18225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18226         LDKHTLCOutputInCommitment this_ptr_conv;
18227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18228         this_ptr_conv.is_owned = false;
18229         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
18230         FREE((void*)val);
18231         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
18232 }
18233
18234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1new(JNIEnv *env, jclass clz, jboolean offered_arg, int64_t amount_msat_arg, int32_t cltv_expiry_arg, int8_tArray payment_hash_arg, int64_t transaction_output_index_arg) {
18235         LDKThirtyTwoBytes payment_hash_arg_ref;
18236         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
18237         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
18238         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
18239         FREE((void*)transaction_output_index_arg);
18240         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
18241         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18242         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18243         long ret_ref = (long)ret_var.inner;
18244         if (ret_var.is_owned) {
18245                 ret_ref |= 1;
18246         }
18247         return ret_ref;
18248 }
18249
18250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18251         LDKHTLCOutputInCommitment orig_conv;
18252         orig_conv.inner = (void*)(orig & (~1));
18253         orig_conv.is_owned = false;
18254         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
18255         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18256         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18257         long ret_ref = (long)ret_var.inner;
18258         if (ret_var.is_owned) {
18259                 ret_ref |= 1;
18260         }
18261         return ret_ref;
18262 }
18263
18264 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
18265         LDKHTLCOutputInCommitment obj_conv;
18266         obj_conv.inner = (void*)(obj & (~1));
18267         obj_conv.is_owned = false;
18268         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
18269         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18270         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18271         CVec_u8Z_free(ret_var);
18272         return ret_arr;
18273 }
18274
18275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18276         LDKu8slice ser_ref;
18277         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18278         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18279         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
18280         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
18281         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18282         return (long)ret_conv;
18283 }
18284
18285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
18286         LDKHTLCOutputInCommitment htlc_conv;
18287         htlc_conv.inner = (void*)(htlc & (~1));
18288         htlc_conv.is_owned = false;
18289         LDKTxCreationKeys keys_conv;
18290         keys_conv.inner = (void*)(keys & (~1));
18291         keys_conv.is_owned = false;
18292         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
18293         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18294         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18295         CVec_u8Z_free(ret_var);
18296         return ret_arr;
18297 }
18298
18299 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
18300         LDKPublicKey broadcaster_ref;
18301         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
18302         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
18303         LDKPublicKey countersignatory_ref;
18304         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
18305         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
18306         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
18307         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18308         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18309         CVec_u8Z_free(ret_var);
18310         return ret_arr;
18311 }
18312
18313 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) {
18314         unsigned char prev_hash_arr[32];
18315         CHECK((*env)->GetArrayLength(env, prev_hash) == 32);
18316         (*env)->GetByteArrayRegion(env, prev_hash, 0, 32, prev_hash_arr);
18317         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
18318         LDKHTLCOutputInCommitment htlc_conv;
18319         htlc_conv.inner = (void*)(htlc & (~1));
18320         htlc_conv.is_owned = false;
18321         LDKPublicKey broadcaster_delayed_payment_key_ref;
18322         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
18323         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
18324         LDKPublicKey revocation_key_ref;
18325         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
18326         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
18327         LDKTransaction ret_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
18328         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18329         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18330         Transaction_free(ret_var);
18331         return ret_arr;
18332 }
18333
18334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18335         LDKChannelTransactionParameters 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         ChannelTransactionParameters_free(this_obj_conv);
18339 }
18340
18341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
18342         LDKChannelTransactionParameters this_ptr_conv;
18343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18344         this_ptr_conv.is_owned = false;
18345         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
18346         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18347         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18348         long ret_ref = (long)ret_var.inner;
18349         if (ret_var.is_owned) {
18350                 ret_ref |= 1;
18351         }
18352         return ret_ref;
18353 }
18354
18355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18356         LDKChannelTransactionParameters this_ptr_conv;
18357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18358         this_ptr_conv.is_owned = false;
18359         LDKChannelPublicKeys val_conv;
18360         val_conv.inner = (void*)(val & (~1));
18361         val_conv.is_owned = (val & 1) || (val == 0);
18362         val_conv = ChannelPublicKeys_clone(&val_conv);
18363         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
18364 }
18365
18366 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
18367         LDKChannelTransactionParameters this_ptr_conv;
18368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18369         this_ptr_conv.is_owned = false;
18370         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
18371         return ret_val;
18372 }
18373
18374 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) {
18375         LDKChannelTransactionParameters this_ptr_conv;
18376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18377         this_ptr_conv.is_owned = false;
18378         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
18379 }
18380
18381 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
18382         LDKChannelTransactionParameters this_ptr_conv;
18383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18384         this_ptr_conv.is_owned = false;
18385         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
18386         return ret_val;
18387 }
18388
18389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18390         LDKChannelTransactionParameters this_ptr_conv;
18391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18392         this_ptr_conv.is_owned = false;
18393         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
18394 }
18395
18396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
18397         LDKChannelTransactionParameters this_ptr_conv;
18398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18399         this_ptr_conv.is_owned = false;
18400         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
18401         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18402         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18403         long ret_ref = (long)ret_var.inner;
18404         if (ret_var.is_owned) {
18405                 ret_ref |= 1;
18406         }
18407         return ret_ref;
18408 }
18409
18410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18411         LDKChannelTransactionParameters this_ptr_conv;
18412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18413         this_ptr_conv.is_owned = false;
18414         LDKCounterpartyChannelTransactionParameters val_conv;
18415         val_conv.inner = (void*)(val & (~1));
18416         val_conv.is_owned = (val & 1) || (val == 0);
18417         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
18418         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
18419 }
18420
18421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18422         LDKChannelTransactionParameters this_ptr_conv;
18423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18424         this_ptr_conv.is_owned = false;
18425         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
18426         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18427         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18428         long ret_ref = (long)ret_var.inner;
18429         if (ret_var.is_owned) {
18430                 ret_ref |= 1;
18431         }
18432         return ret_ref;
18433 }
18434
18435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18436         LDKChannelTransactionParameters this_ptr_conv;
18437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18438         this_ptr_conv.is_owned = false;
18439         LDKOutPoint val_conv;
18440         val_conv.inner = (void*)(val & (~1));
18441         val_conv.is_owned = (val & 1) || (val == 0);
18442         val_conv = OutPoint_clone(&val_conv);
18443         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
18444 }
18445
18446 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) {
18447         LDKChannelPublicKeys holder_pubkeys_arg_conv;
18448         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
18449         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
18450         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
18451         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
18452         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
18453         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
18454         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
18455         LDKOutPoint funding_outpoint_arg_conv;
18456         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
18457         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
18458         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
18459         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);
18460         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18461         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18462         long ret_ref = (long)ret_var.inner;
18463         if (ret_var.is_owned) {
18464                 ret_ref |= 1;
18465         }
18466         return ret_ref;
18467 }
18468
18469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18470         LDKChannelTransactionParameters orig_conv;
18471         orig_conv.inner = (void*)(orig & (~1));
18472         orig_conv.is_owned = false;
18473         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
18474         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18475         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18476         long ret_ref = (long)ret_var.inner;
18477         if (ret_var.is_owned) {
18478                 ret_ref |= 1;
18479         }
18480         return ret_ref;
18481 }
18482
18483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18484         LDKCounterpartyChannelTransactionParameters this_obj_conv;
18485         this_obj_conv.inner = (void*)(this_obj & (~1));
18486         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18487         CounterpartyChannelTransactionParameters_free(this_obj_conv);
18488 }
18489
18490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
18491         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
18492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18493         this_ptr_conv.is_owned = false;
18494         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
18495         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18496         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18497         long ret_ref = (long)ret_var.inner;
18498         if (ret_var.is_owned) {
18499                 ret_ref |= 1;
18500         }
18501         return ret_ref;
18502 }
18503
18504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18505         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
18506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18507         this_ptr_conv.is_owned = false;
18508         LDKChannelPublicKeys val_conv;
18509         val_conv.inner = (void*)(val & (~1));
18510         val_conv.is_owned = (val & 1) || (val == 0);
18511         val_conv = ChannelPublicKeys_clone(&val_conv);
18512         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
18513 }
18514
18515 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
18516         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
18517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18518         this_ptr_conv.is_owned = false;
18519         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
18520         return ret_val;
18521 }
18522
18523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18524         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
18525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18526         this_ptr_conv.is_owned = false;
18527         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
18528 }
18529
18530 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) {
18531         LDKChannelPublicKeys pubkeys_arg_conv;
18532         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
18533         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
18534         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
18535         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
18536         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18537         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18538         long ret_ref = (long)ret_var.inner;
18539         if (ret_var.is_owned) {
18540                 ret_ref |= 1;
18541         }
18542         return ret_ref;
18543 }
18544
18545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18546         LDKCounterpartyChannelTransactionParameters orig_conv;
18547         orig_conv.inner = (void*)(orig & (~1));
18548         orig_conv.is_owned = false;
18549         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
18550         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18551         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18552         long ret_ref = (long)ret_var.inner;
18553         if (ret_var.is_owned) {
18554                 ret_ref |= 1;
18555         }
18556         return ret_ref;
18557 }
18558
18559 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
18560         LDKChannelTransactionParameters this_arg_conv;
18561         this_arg_conv.inner = (void*)(this_arg & (~1));
18562         this_arg_conv.is_owned = false;
18563         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
18564         return ret_val;
18565 }
18566
18567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
18568         LDKChannelTransactionParameters this_arg_conv;
18569         this_arg_conv.inner = (void*)(this_arg & (~1));
18570         this_arg_conv.is_owned = false;
18571         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
18572         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18573         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18574         long ret_ref = (long)ret_var.inner;
18575         if (ret_var.is_owned) {
18576                 ret_ref |= 1;
18577         }
18578         return ret_ref;
18579 }
18580
18581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
18582         LDKChannelTransactionParameters this_arg_conv;
18583         this_arg_conv.inner = (void*)(this_arg & (~1));
18584         this_arg_conv.is_owned = false;
18585         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
18586         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18587         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18588         long ret_ref = (long)ret_var.inner;
18589         if (ret_var.is_owned) {
18590                 ret_ref |= 1;
18591         }
18592         return ret_ref;
18593 }
18594
18595 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
18596         LDKCounterpartyChannelTransactionParameters obj_conv;
18597         obj_conv.inner = (void*)(obj & (~1));
18598         obj_conv.is_owned = false;
18599         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
18600         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18601         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18602         CVec_u8Z_free(ret_var);
18603         return ret_arr;
18604 }
18605
18606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18607         LDKu8slice ser_ref;
18608         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18609         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18610         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
18611         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
18612         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18613         return (long)ret_conv;
18614 }
18615
18616 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
18617         LDKChannelTransactionParameters obj_conv;
18618         obj_conv.inner = (void*)(obj & (~1));
18619         obj_conv.is_owned = false;
18620         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
18621         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18622         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18623         CVec_u8Z_free(ret_var);
18624         return ret_arr;
18625 }
18626
18627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18628         LDKu8slice ser_ref;
18629         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18630         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18631         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
18632         *ret_conv = ChannelTransactionParameters_read(ser_ref);
18633         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18634         return (long)ret_conv;
18635 }
18636
18637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18638         LDKDirectedChannelTransactionParameters this_obj_conv;
18639         this_obj_conv.inner = (void*)(this_obj & (~1));
18640         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18641         DirectedChannelTransactionParameters_free(this_obj_conv);
18642 }
18643
18644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
18645         LDKDirectedChannelTransactionParameters this_arg_conv;
18646         this_arg_conv.inner = (void*)(this_arg & (~1));
18647         this_arg_conv.is_owned = false;
18648         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_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_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
18659         LDKDirectedChannelTransactionParameters this_arg_conv;
18660         this_arg_conv.inner = (void*)(this_arg & (~1));
18661         this_arg_conv.is_owned = false;
18662         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_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 int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
18673         LDKDirectedChannelTransactionParameters this_arg_conv;
18674         this_arg_conv.inner = (void*)(this_arg & (~1));
18675         this_arg_conv.is_owned = false;
18676         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
18677         return ret_val;
18678 }
18679
18680 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
18681         LDKDirectedChannelTransactionParameters this_arg_conv;
18682         this_arg_conv.inner = (void*)(this_arg & (~1));
18683         this_arg_conv.is_owned = false;
18684         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
18685         return ret_val;
18686 }
18687
18688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
18689         LDKDirectedChannelTransactionParameters this_arg_conv;
18690         this_arg_conv.inner = (void*)(this_arg & (~1));
18691         this_arg_conv.is_owned = false;
18692         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
18693         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18694         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18695         long ret_ref = (long)ret_var.inner;
18696         if (ret_var.is_owned) {
18697                 ret_ref |= 1;
18698         }
18699         return ret_ref;
18700 }
18701
18702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18703         LDKHolderCommitmentTransaction this_obj_conv;
18704         this_obj_conv.inner = (void*)(this_obj & (~1));
18705         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18706         HolderCommitmentTransaction_free(this_obj_conv);
18707 }
18708
18709 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
18710         LDKHolderCommitmentTransaction this_ptr_conv;
18711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18712         this_ptr_conv.is_owned = false;
18713         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18714         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
18715         return ret_arr;
18716 }
18717
18718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18719         LDKHolderCommitmentTransaction this_ptr_conv;
18720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18721         this_ptr_conv.is_owned = false;
18722         LDKSignature val_ref;
18723         CHECK((*env)->GetArrayLength(env, val) == 64);
18724         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18725         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
18726 }
18727
18728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
18729         LDKHolderCommitmentTransaction this_ptr_conv;
18730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18731         this_ptr_conv.is_owned = false;
18732         LDKCVec_SignatureZ val_constr;
18733         val_constr.datalen = (*env)->GetArrayLength(env, val);
18734         if (val_constr.datalen > 0)
18735                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18736         else
18737                 val_constr.data = NULL;
18738         for (size_t i = 0; i < val_constr.datalen; i++) {
18739                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
18740                 LDKSignature val_conv_8_ref;
18741                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
18742                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
18743                 val_constr.data[i] = val_conv_8_ref;
18744         }
18745         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
18746 }
18747
18748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18749         LDKHolderCommitmentTransaction orig_conv;
18750         orig_conv.inner = (void*)(orig & (~1));
18751         orig_conv.is_owned = false;
18752         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
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 int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
18763         LDKHolderCommitmentTransaction obj_conv;
18764         obj_conv.inner = (void*)(obj & (~1));
18765         obj_conv.is_owned = false;
18766         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
18767         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18768         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18769         CVec_u8Z_free(ret_var);
18770         return ret_arr;
18771 }
18772
18773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18774         LDKu8slice ser_ref;
18775         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18776         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18777         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
18778         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
18779         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18780         return (long)ret_conv;
18781 }
18782
18783 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) {
18784         LDKCommitmentTransaction commitment_tx_conv;
18785         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
18786         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
18787         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
18788         LDKSignature counterparty_sig_ref;
18789         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
18790         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
18791         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
18792         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
18793         if (counterparty_htlc_sigs_constr.datalen > 0)
18794                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18795         else
18796                 counterparty_htlc_sigs_constr.data = NULL;
18797         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
18798                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
18799                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
18800                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
18801                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
18802                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
18803         }
18804         LDKPublicKey holder_funding_key_ref;
18805         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
18806         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
18807         LDKPublicKey counterparty_funding_key_ref;
18808         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
18809         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
18810         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
18811         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18812         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18813         long ret_ref = (long)ret_var.inner;
18814         if (ret_var.is_owned) {
18815                 ret_ref |= 1;
18816         }
18817         return ret_ref;
18818 }
18819
18820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18821         LDKBuiltCommitmentTransaction this_obj_conv;
18822         this_obj_conv.inner = (void*)(this_obj & (~1));
18823         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18824         BuiltCommitmentTransaction_free(this_obj_conv);
18825 }
18826
18827 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
18828         LDKBuiltCommitmentTransaction this_ptr_conv;
18829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18830         this_ptr_conv.is_owned = false;
18831         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
18832         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18833         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18834         Transaction_free(ret_var);
18835         return ret_arr;
18836 }
18837
18838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18839         LDKBuiltCommitmentTransaction this_ptr_conv;
18840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18841         this_ptr_conv.is_owned = false;
18842         LDKTransaction val_ref;
18843         val_ref.datalen = (*env)->GetArrayLength(env, val);
18844         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
18845         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
18846         val_ref.data_is_owned = true;
18847         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
18848 }
18849
18850 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
18851         LDKBuiltCommitmentTransaction this_ptr_conv;
18852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18853         this_ptr_conv.is_owned = false;
18854         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18855         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
18856         return ret_arr;
18857 }
18858
18859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18860         LDKBuiltCommitmentTransaction this_ptr_conv;
18861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18862         this_ptr_conv.is_owned = false;
18863         LDKThirtyTwoBytes val_ref;
18864         CHECK((*env)->GetArrayLength(env, val) == 32);
18865         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18866         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
18867 }
18868
18869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
18870         LDKTransaction transaction_arg_ref;
18871         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
18872         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
18873         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
18874         transaction_arg_ref.data_is_owned = true;
18875         LDKThirtyTwoBytes txid_arg_ref;
18876         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
18877         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
18878         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
18879         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18880         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18881         long ret_ref = (long)ret_var.inner;
18882         if (ret_var.is_owned) {
18883                 ret_ref |= 1;
18884         }
18885         return ret_ref;
18886 }
18887
18888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18889         LDKBuiltCommitmentTransaction orig_conv;
18890         orig_conv.inner = (void*)(orig & (~1));
18891         orig_conv.is_owned = false;
18892         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
18893         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18894         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18895         long ret_ref = (long)ret_var.inner;
18896         if (ret_var.is_owned) {
18897                 ret_ref |= 1;
18898         }
18899         return ret_ref;
18900 }
18901
18902 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
18903         LDKBuiltCommitmentTransaction obj_conv;
18904         obj_conv.inner = (void*)(obj & (~1));
18905         obj_conv.is_owned = false;
18906         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
18907         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18908         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18909         CVec_u8Z_free(ret_var);
18910         return ret_arr;
18911 }
18912
18913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18914         LDKu8slice ser_ref;
18915         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18916         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18917         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
18918         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
18919         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18920         return (long)ret_conv;
18921 }
18922
18923 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) {
18924         LDKBuiltCommitmentTransaction this_arg_conv;
18925         this_arg_conv.inner = (void*)(this_arg & (~1));
18926         this_arg_conv.is_owned = false;
18927         LDKu8slice funding_redeemscript_ref;
18928         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
18929         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
18930         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18931         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
18932         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
18933         return ret_arr;
18934 }
18935
18936 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) {
18937         LDKBuiltCommitmentTransaction this_arg_conv;
18938         this_arg_conv.inner = (void*)(this_arg & (~1));
18939         this_arg_conv.is_owned = false;
18940         unsigned char funding_key_arr[32];
18941         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
18942         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
18943         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
18944         LDKu8slice funding_redeemscript_ref;
18945         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
18946         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
18947         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18948         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
18949         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
18950         return ret_arr;
18951 }
18952
18953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18954         LDKCommitmentTransaction this_obj_conv;
18955         this_obj_conv.inner = (void*)(this_obj & (~1));
18956         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18957         CommitmentTransaction_free(this_obj_conv);
18958 }
18959
18960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18961         LDKCommitmentTransaction orig_conv;
18962         orig_conv.inner = (void*)(orig & (~1));
18963         orig_conv.is_owned = false;
18964         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
18965         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18966         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18967         long ret_ref = (long)ret_var.inner;
18968         if (ret_var.is_owned) {
18969                 ret_ref |= 1;
18970         }
18971         return ret_ref;
18972 }
18973
18974 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
18975         LDKCommitmentTransaction obj_conv;
18976         obj_conv.inner = (void*)(obj & (~1));
18977         obj_conv.is_owned = false;
18978         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
18979         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18980         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18981         CVec_u8Z_free(ret_var);
18982         return ret_arr;
18983 }
18984
18985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18986         LDKu8slice ser_ref;
18987         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18988         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18989         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
18990         *ret_conv = CommitmentTransaction_read(ser_ref);
18991         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18992         return (long)ret_conv;
18993 }
18994
18995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
18996         LDKCommitmentTransaction this_arg_conv;
18997         this_arg_conv.inner = (void*)(this_arg & (~1));
18998         this_arg_conv.is_owned = false;
18999         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
19000         return ret_val;
19001 }
19002
19003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
19004         LDKCommitmentTransaction this_arg_conv;
19005         this_arg_conv.inner = (void*)(this_arg & (~1));
19006         this_arg_conv.is_owned = false;
19007         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
19008         return ret_val;
19009 }
19010
19011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
19012         LDKCommitmentTransaction this_arg_conv;
19013         this_arg_conv.inner = (void*)(this_arg & (~1));
19014         this_arg_conv.is_owned = false;
19015         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
19016         return ret_val;
19017 }
19018
19019 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
19020         LDKCommitmentTransaction this_arg_conv;
19021         this_arg_conv.inner = (void*)(this_arg & (~1));
19022         this_arg_conv.is_owned = false;
19023         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
19024         return ret_val;
19025 }
19026
19027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
19028         LDKCommitmentTransaction this_arg_conv;
19029         this_arg_conv.inner = (void*)(this_arg & (~1));
19030         this_arg_conv.is_owned = false;
19031         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
19032         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19033         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19034         long ret_ref = (long)ret_var.inner;
19035         if (ret_var.is_owned) {
19036                 ret_ref |= 1;
19037         }
19038         return ret_ref;
19039 }
19040
19041 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) {
19042         LDKCommitmentTransaction this_arg_conv;
19043         this_arg_conv.inner = (void*)(this_arg & (~1));
19044         this_arg_conv.is_owned = false;
19045         LDKDirectedChannelTransactionParameters channel_parameters_conv;
19046         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
19047         channel_parameters_conv.is_owned = false;
19048         LDKChannelPublicKeys broadcaster_keys_conv;
19049         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
19050         broadcaster_keys_conv.is_owned = false;
19051         LDKChannelPublicKeys countersignatory_keys_conv;
19052         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
19053         countersignatory_keys_conv.is_owned = false;
19054         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
19055         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
19056         return (long)ret_conv;
19057 }
19058
19059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19060         LDKTrustedCommitmentTransaction this_obj_conv;
19061         this_obj_conv.inner = (void*)(this_obj & (~1));
19062         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19063         TrustedCommitmentTransaction_free(this_obj_conv);
19064 }
19065
19066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
19067         LDKTrustedCommitmentTransaction this_arg_conv;
19068         this_arg_conv.inner = (void*)(this_arg & (~1));
19069         this_arg_conv.is_owned = false;
19070         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19071         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
19072         return ret_arr;
19073 }
19074
19075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
19076         LDKTrustedCommitmentTransaction this_arg_conv;
19077         this_arg_conv.inner = (void*)(this_arg & (~1));
19078         this_arg_conv.is_owned = false;
19079         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
19080         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19081         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19082         long ret_ref = (long)ret_var.inner;
19083         if (ret_var.is_owned) {
19084                 ret_ref |= 1;
19085         }
19086         return ret_ref;
19087 }
19088
19089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
19090         LDKTrustedCommitmentTransaction this_arg_conv;
19091         this_arg_conv.inner = (void*)(this_arg & (~1));
19092         this_arg_conv.is_owned = false;
19093         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
19094         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19095         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19096         long ret_ref = (long)ret_var.inner;
19097         if (ret_var.is_owned) {
19098                 ret_ref |= 1;
19099         }
19100         return ret_ref;
19101 }
19102
19103 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) {
19104         LDKTrustedCommitmentTransaction this_arg_conv;
19105         this_arg_conv.inner = (void*)(this_arg & (~1));
19106         this_arg_conv.is_owned = false;
19107         unsigned char htlc_base_key_arr[32];
19108         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
19109         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
19110         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
19111         LDKDirectedChannelTransactionParameters channel_parameters_conv;
19112         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
19113         channel_parameters_conv.is_owned = false;
19114         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
19115         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
19116         return (long)ret_conv;
19117 }
19118
19119 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) {
19120         LDKPublicKey broadcaster_payment_basepoint_ref;
19121         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
19122         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
19123         LDKPublicKey countersignatory_payment_basepoint_ref;
19124         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
19125         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
19126         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
19127         return ret_val;
19128 }
19129
19130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19131         LDKInitFeatures orig_conv;
19132         orig_conv.inner = (void*)(orig & (~1));
19133         orig_conv.is_owned = false;
19134         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
19135         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19136         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19137         long ret_ref = (long)ret_var.inner;
19138         if (ret_var.is_owned) {
19139                 ret_ref |= 1;
19140         }
19141         return ret_ref;
19142 }
19143
19144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19145         LDKNodeFeatures orig_conv;
19146         orig_conv.inner = (void*)(orig & (~1));
19147         orig_conv.is_owned = false;
19148         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
19149         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19150         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19151         long ret_ref = (long)ret_var.inner;
19152         if (ret_var.is_owned) {
19153                 ret_ref |= 1;
19154         }
19155         return ret_ref;
19156 }
19157
19158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19159         LDKChannelFeatures orig_conv;
19160         orig_conv.inner = (void*)(orig & (~1));
19161         orig_conv.is_owned = false;
19162         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
19163         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19164         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19165         long ret_ref = (long)ret_var.inner;
19166         if (ret_var.is_owned) {
19167                 ret_ref |= 1;
19168         }
19169         return ret_ref;
19170 }
19171
19172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19173         LDKInvoiceFeatures orig_conv;
19174         orig_conv.inner = (void*)(orig & (~1));
19175         orig_conv.is_owned = false;
19176         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
19177         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19178         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19179         long ret_ref = (long)ret_var.inner;
19180         if (ret_var.is_owned) {
19181                 ret_ref |= 1;
19182         }
19183         return ret_ref;
19184 }
19185
19186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19187         LDKInitFeatures this_obj_conv;
19188         this_obj_conv.inner = (void*)(this_obj & (~1));
19189         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19190         InitFeatures_free(this_obj_conv);
19191 }
19192
19193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19194         LDKNodeFeatures this_obj_conv;
19195         this_obj_conv.inner = (void*)(this_obj & (~1));
19196         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19197         NodeFeatures_free(this_obj_conv);
19198 }
19199
19200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19201         LDKChannelFeatures this_obj_conv;
19202         this_obj_conv.inner = (void*)(this_obj & (~1));
19203         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19204         ChannelFeatures_free(this_obj_conv);
19205 }
19206
19207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19208         LDKInvoiceFeatures this_obj_conv;
19209         this_obj_conv.inner = (void*)(this_obj & (~1));
19210         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19211         InvoiceFeatures_free(this_obj_conv);
19212 }
19213
19214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
19215         LDKInitFeatures ret_var = InitFeatures_empty();
19216         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19217         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19218         long ret_ref = (long)ret_var.inner;
19219         if (ret_var.is_owned) {
19220                 ret_ref |= 1;
19221         }
19222         return ret_ref;
19223 }
19224
19225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
19226         LDKInitFeatures ret_var = InitFeatures_known();
19227         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19228         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19229         long ret_ref = (long)ret_var.inner;
19230         if (ret_var.is_owned) {
19231                 ret_ref |= 1;
19232         }
19233         return ret_ref;
19234 }
19235
19236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
19237         LDKNodeFeatures ret_var = NodeFeatures_empty();
19238         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19239         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19240         long ret_ref = (long)ret_var.inner;
19241         if (ret_var.is_owned) {
19242                 ret_ref |= 1;
19243         }
19244         return ret_ref;
19245 }
19246
19247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
19248         LDKNodeFeatures ret_var = NodeFeatures_known();
19249         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19250         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19251         long ret_ref = (long)ret_var.inner;
19252         if (ret_var.is_owned) {
19253                 ret_ref |= 1;
19254         }
19255         return ret_ref;
19256 }
19257
19258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
19259         LDKChannelFeatures ret_var = ChannelFeatures_empty();
19260         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19261         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19262         long ret_ref = (long)ret_var.inner;
19263         if (ret_var.is_owned) {
19264                 ret_ref |= 1;
19265         }
19266         return ret_ref;
19267 }
19268
19269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
19270         LDKChannelFeatures ret_var = ChannelFeatures_known();
19271         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19272         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19273         long ret_ref = (long)ret_var.inner;
19274         if (ret_var.is_owned) {
19275                 ret_ref |= 1;
19276         }
19277         return ret_ref;
19278 }
19279
19280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
19281         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
19282         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19283         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19284         long ret_ref = (long)ret_var.inner;
19285         if (ret_var.is_owned) {
19286                 ret_ref |= 1;
19287         }
19288         return ret_ref;
19289 }
19290
19291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
19292         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
19293         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19294         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19295         long ret_ref = (long)ret_var.inner;
19296         if (ret_var.is_owned) {
19297                 ret_ref |= 1;
19298         }
19299         return ret_ref;
19300 }
19301
19302 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19303         LDKInitFeatures obj_conv;
19304         obj_conv.inner = (void*)(obj & (~1));
19305         obj_conv.is_owned = false;
19306         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
19307         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19308         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19309         CVec_u8Z_free(ret_var);
19310         return ret_arr;
19311 }
19312
19313 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19314         LDKNodeFeatures obj_conv;
19315         obj_conv.inner = (void*)(obj & (~1));
19316         obj_conv.is_owned = false;
19317         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
19318         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19319         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19320         CVec_u8Z_free(ret_var);
19321         return ret_arr;
19322 }
19323
19324 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19325         LDKChannelFeatures obj_conv;
19326         obj_conv.inner = (void*)(obj & (~1));
19327         obj_conv.is_owned = false;
19328         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
19329         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19330         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19331         CVec_u8Z_free(ret_var);
19332         return ret_arr;
19333 }
19334
19335 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19336         LDKInvoiceFeatures obj_conv;
19337         obj_conv.inner = (void*)(obj & (~1));
19338         obj_conv.is_owned = false;
19339         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
19340         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19341         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19342         CVec_u8Z_free(ret_var);
19343         return ret_arr;
19344 }
19345
19346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19347         LDKu8slice ser_ref;
19348         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19349         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19350         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
19351         *ret_conv = InitFeatures_read(ser_ref);
19352         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19353         return (long)ret_conv;
19354 }
19355
19356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19357         LDKu8slice ser_ref;
19358         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19359         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19360         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
19361         *ret_conv = NodeFeatures_read(ser_ref);
19362         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19363         return (long)ret_conv;
19364 }
19365
19366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19367         LDKu8slice ser_ref;
19368         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19369         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19370         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
19371         *ret_conv = ChannelFeatures_read(ser_ref);
19372         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19373         return (long)ret_conv;
19374 }
19375
19376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19377         LDKu8slice ser_ref;
19378         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19379         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19380         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
19381         *ret_conv = InvoiceFeatures_read(ser_ref);
19382         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19383         return (long)ret_conv;
19384 }
19385
19386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19387         LDKRouteHop this_obj_conv;
19388         this_obj_conv.inner = (void*)(this_obj & (~1));
19389         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19390         RouteHop_free(this_obj_conv);
19391 }
19392
19393 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
19394         LDKRouteHop this_ptr_conv;
19395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19396         this_ptr_conv.is_owned = false;
19397         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19398         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
19399         return ret_arr;
19400 }
19401
19402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19403         LDKRouteHop this_ptr_conv;
19404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19405         this_ptr_conv.is_owned = false;
19406         LDKPublicKey val_ref;
19407         CHECK((*env)->GetArrayLength(env, val) == 33);
19408         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19409         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
19410 }
19411
19412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19413         LDKRouteHop this_ptr_conv;
19414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19415         this_ptr_conv.is_owned = false;
19416         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
19417         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19418         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19419         long ret_ref = (long)ret_var.inner;
19420         if (ret_var.is_owned) {
19421                 ret_ref |= 1;
19422         }
19423         return ret_ref;
19424 }
19425
19426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19427         LDKRouteHop this_ptr_conv;
19428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19429         this_ptr_conv.is_owned = false;
19430         LDKNodeFeatures val_conv;
19431         val_conv.inner = (void*)(val & (~1));
19432         val_conv.is_owned = (val & 1) || (val == 0);
19433         val_conv = NodeFeatures_clone(&val_conv);
19434         RouteHop_set_node_features(&this_ptr_conv, val_conv);
19435 }
19436
19437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19438         LDKRouteHop this_ptr_conv;
19439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19440         this_ptr_conv.is_owned = false;
19441         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
19442         return ret_val;
19443 }
19444
19445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19446         LDKRouteHop this_ptr_conv;
19447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19448         this_ptr_conv.is_owned = false;
19449         RouteHop_set_short_channel_id(&this_ptr_conv, val);
19450 }
19451
19452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19453         LDKRouteHop this_ptr_conv;
19454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19455         this_ptr_conv.is_owned = false;
19456         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
19457         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19458         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19459         long ret_ref = (long)ret_var.inner;
19460         if (ret_var.is_owned) {
19461                 ret_ref |= 1;
19462         }
19463         return ret_ref;
19464 }
19465
19466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19467         LDKRouteHop this_ptr_conv;
19468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19469         this_ptr_conv.is_owned = false;
19470         LDKChannelFeatures val_conv;
19471         val_conv.inner = (void*)(val & (~1));
19472         val_conv.is_owned = (val & 1) || (val == 0);
19473         val_conv = ChannelFeatures_clone(&val_conv);
19474         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
19475 }
19476
19477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19478         LDKRouteHop this_ptr_conv;
19479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19480         this_ptr_conv.is_owned = false;
19481         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
19482         return ret_val;
19483 }
19484
19485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19486         LDKRouteHop this_ptr_conv;
19487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19488         this_ptr_conv.is_owned = false;
19489         RouteHop_set_fee_msat(&this_ptr_conv, val);
19490 }
19491
19492 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
19493         LDKRouteHop this_ptr_conv;
19494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19495         this_ptr_conv.is_owned = false;
19496         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
19497         return ret_val;
19498 }
19499
19500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19501         LDKRouteHop this_ptr_conv;
19502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19503         this_ptr_conv.is_owned = false;
19504         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
19505 }
19506
19507 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) {
19508         LDKPublicKey pubkey_arg_ref;
19509         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
19510         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
19511         LDKNodeFeatures node_features_arg_conv;
19512         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
19513         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
19514         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
19515         LDKChannelFeatures channel_features_arg_conv;
19516         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
19517         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
19518         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
19519         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);
19520         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19521         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19522         long ret_ref = (long)ret_var.inner;
19523         if (ret_var.is_owned) {
19524                 ret_ref |= 1;
19525         }
19526         return ret_ref;
19527 }
19528
19529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19530         LDKRouteHop orig_conv;
19531         orig_conv.inner = (void*)(orig & (~1));
19532         orig_conv.is_owned = false;
19533         LDKRouteHop ret_var = RouteHop_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 void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19544         LDKRoute this_obj_conv;
19545         this_obj_conv.inner = (void*)(this_obj & (~1));
19546         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19547         Route_free(this_obj_conv);
19548 }
19549
19550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
19551         LDKRoute this_ptr_conv;
19552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19553         this_ptr_conv.is_owned = false;
19554         LDKCVec_CVec_RouteHopZZ val_constr;
19555         val_constr.datalen = (*env)->GetArrayLength(env, val);
19556         if (val_constr.datalen > 0)
19557                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
19558         else
19559                 val_constr.data = NULL;
19560         for (size_t m = 0; m < val_constr.datalen; m++) {
19561                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
19562                 LDKCVec_RouteHopZ val_conv_12_constr;
19563                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
19564                 if (val_conv_12_constr.datalen > 0)
19565                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19566                 else
19567                         val_conv_12_constr.data = NULL;
19568                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
19569                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
19570                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
19571                         LDKRouteHop val_conv_12_conv_10_conv;
19572                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
19573                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
19574                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
19575                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
19576                 }
19577                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
19578                 val_constr.data[m] = val_conv_12_constr;
19579         }
19580         Route_set_paths(&this_ptr_conv, val_constr);
19581 }
19582
19583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
19584         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
19585         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
19586         if (paths_arg_constr.datalen > 0)
19587                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
19588         else
19589                 paths_arg_constr.data = NULL;
19590         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
19591                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
19592                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
19593                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
19594                 if (paths_arg_conv_12_constr.datalen > 0)
19595                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19596                 else
19597                         paths_arg_conv_12_constr.data = NULL;
19598                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
19599                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
19600                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
19601                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
19602                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
19603                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
19604                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
19605                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
19606                 }
19607                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
19608                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
19609         }
19610         LDKRoute ret_var = Route_new(paths_arg_constr);
19611         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19612         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19613         long ret_ref = (long)ret_var.inner;
19614         if (ret_var.is_owned) {
19615                 ret_ref |= 1;
19616         }
19617         return ret_ref;
19618 }
19619
19620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19621         LDKRoute orig_conv;
19622         orig_conv.inner = (void*)(orig & (~1));
19623         orig_conv.is_owned = false;
19624         LDKRoute ret_var = Route_clone(&orig_conv);
19625         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19626         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19627         long ret_ref = (long)ret_var.inner;
19628         if (ret_var.is_owned) {
19629                 ret_ref |= 1;
19630         }
19631         return ret_ref;
19632 }
19633
19634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
19635         LDKRoute obj_conv;
19636         obj_conv.inner = (void*)(obj & (~1));
19637         obj_conv.is_owned = false;
19638         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
19639         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19640         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19641         CVec_u8Z_free(ret_var);
19642         return ret_arr;
19643 }
19644
19645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19646         LDKu8slice ser_ref;
19647         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19648         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19649         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
19650         *ret_conv = Route_read(ser_ref);
19651         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19652         return (long)ret_conv;
19653 }
19654
19655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19656         LDKRouteHint this_obj_conv;
19657         this_obj_conv.inner = (void*)(this_obj & (~1));
19658         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19659         RouteHint_free(this_obj_conv);
19660 }
19661
19662 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19663         LDKRouteHint this_ptr_conv;
19664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19665         this_ptr_conv.is_owned = false;
19666         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19667         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHint_get_src_node_id(&this_ptr_conv).compressed_form);
19668         return ret_arr;
19669 }
19670
19671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19672         LDKRouteHint this_ptr_conv;
19673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19674         this_ptr_conv.is_owned = false;
19675         LDKPublicKey val_ref;
19676         CHECK((*env)->GetArrayLength(env, val) == 33);
19677         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19678         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
19679 }
19680
19681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19682         LDKRouteHint this_ptr_conv;
19683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19684         this_ptr_conv.is_owned = false;
19685         int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
19686         return ret_val;
19687 }
19688
19689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19690         LDKRouteHint this_ptr_conv;
19691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19692         this_ptr_conv.is_owned = false;
19693         RouteHint_set_short_channel_id(&this_ptr_conv, val);
19694 }
19695
19696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
19697         LDKRouteHint this_ptr_conv;
19698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19699         this_ptr_conv.is_owned = false;
19700         LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
19701         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19702         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19703         long ret_ref = (long)ret_var.inner;
19704         if (ret_var.is_owned) {
19705                 ret_ref |= 1;
19706         }
19707         return ret_ref;
19708 }
19709
19710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19711         LDKRouteHint this_ptr_conv;
19712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19713         this_ptr_conv.is_owned = false;
19714         LDKRoutingFees val_conv;
19715         val_conv.inner = (void*)(val & (~1));
19716         val_conv.is_owned = (val & 1) || (val == 0);
19717         val_conv = RoutingFees_clone(&val_conv);
19718         RouteHint_set_fees(&this_ptr_conv, val_conv);
19719 }
19720
19721 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
19722         LDKRouteHint this_ptr_conv;
19723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19724         this_ptr_conv.is_owned = false;
19725         int16_t ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
19726         return ret_val;
19727 }
19728
19729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19730         LDKRouteHint this_ptr_conv;
19731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19732         this_ptr_conv.is_owned = false;
19733         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
19734 }
19735
19736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19737         LDKRouteHint this_ptr_conv;
19738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19739         this_ptr_conv.is_owned = false;
19740         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
19741         *ret_copy = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
19742         long ret_ref = (long)ret_copy;
19743         return ret_ref;
19744 }
19745
19746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19747         LDKRouteHint this_ptr_conv;
19748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19749         this_ptr_conv.is_owned = false;
19750         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
19751         FREE((void*)val);
19752         RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
19753 }
19754
19755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19756         LDKRouteHint this_ptr_conv;
19757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19758         this_ptr_conv.is_owned = false;
19759         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
19760         *ret_copy = RouteHint_get_htlc_maximum_msat(&this_ptr_conv);
19761         long ret_ref = (long)ret_copy;
19762         return ret_ref;
19763 }
19764
19765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19766         LDKRouteHint this_ptr_conv;
19767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19768         this_ptr_conv.is_owned = false;
19769         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
19770         FREE((void*)val);
19771         RouteHint_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
19772 }
19773
19774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int8_tArray src_node_id_arg, int64_t short_channel_id_arg, int64_t fees_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg) {
19775         LDKPublicKey src_node_id_arg_ref;
19776         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
19777         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
19778         LDKRoutingFees fees_arg_conv;
19779         fees_arg_conv.inner = (void*)(fees_arg & (~1));
19780         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
19781         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
19782         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
19783         FREE((void*)htlc_minimum_msat_arg);
19784         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
19785         FREE((void*)htlc_maximum_msat_arg);
19786         LDKRouteHint ret_var = RouteHint_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg_conv, htlc_maximum_msat_arg_conv);
19787         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19788         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19789         long ret_ref = (long)ret_var.inner;
19790         if (ret_var.is_owned) {
19791                 ret_ref |= 1;
19792         }
19793         return ret_ref;
19794 }
19795
19796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19797         LDKRouteHint orig_conv;
19798         orig_conv.inner = (void*)(orig & (~1));
19799         orig_conv.is_owned = false;
19800         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
19801         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19802         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19803         long ret_ref = (long)ret_var.inner;
19804         if (ret_var.is_owned) {
19805                 ret_ref |= 1;
19806         }
19807         return ret_ref;
19808 }
19809
19810 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_t payee_features, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) {
19811         LDKPublicKey our_node_id_ref;
19812         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
19813         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
19814         LDKNetworkGraph network_conv;
19815         network_conv.inner = (void*)(network & (~1));
19816         network_conv.is_owned = false;
19817         LDKPublicKey payee_ref;
19818         CHECK((*env)->GetArrayLength(env, payee) == 33);
19819         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
19820         LDKInvoiceFeatures payee_features_conv;
19821         payee_features_conv.inner = (void*)(payee_features & (~1));
19822         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
19823         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
19824         LDKCVec_ChannelDetailsZ first_hops_constr;
19825         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
19826         if (first_hops_constr.datalen > 0)
19827                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
19828         else
19829                 first_hops_constr.data = NULL;
19830         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
19831         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
19832                 int64_t first_hops_conv_16 = first_hops_vals[q];
19833                 LDKChannelDetails first_hops_conv_16_conv;
19834                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
19835                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
19836                 first_hops_constr.data[q] = first_hops_conv_16_conv;
19837         }
19838         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
19839         LDKCVec_RouteHintZ last_hops_constr;
19840         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
19841         if (last_hops_constr.datalen > 0)
19842                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
19843         else
19844                 last_hops_constr.data = NULL;
19845         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
19846         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
19847                 int64_t last_hops_conv_11 = last_hops_vals[l];
19848                 LDKRouteHint last_hops_conv_11_conv;
19849                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
19850                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
19851                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
19852                 last_hops_constr.data[l] = last_hops_conv_11_conv;
19853         }
19854         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
19855         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19856         if (logger_conv.free == LDKLogger_JCalls_free) {
19857                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19858                 LDKLogger_JCalls_clone(logger_conv.this_arg);
19859         }
19860         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
19861         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
19862         FREE(first_hops_constr.data);
19863         return (long)ret_conv;
19864 }
19865
19866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19867         LDKNetworkGraph this_obj_conv;
19868         this_obj_conv.inner = (void*)(this_obj & (~1));
19869         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19870         NetworkGraph_free(this_obj_conv);
19871 }
19872
19873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19874         LDKNetworkGraph orig_conv;
19875         orig_conv.inner = (void*)(orig & (~1));
19876         orig_conv.is_owned = false;
19877         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
19878         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19879         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19880         long ret_ref = (long)ret_var.inner;
19881         if (ret_var.is_owned) {
19882                 ret_ref |= 1;
19883         }
19884         return ret_ref;
19885 }
19886
19887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19888         LDKLockedNetworkGraph this_obj_conv;
19889         this_obj_conv.inner = (void*)(this_obj & (~1));
19890         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19891         LockedNetworkGraph_free(this_obj_conv);
19892 }
19893
19894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19895         LDKNetGraphMsgHandler this_obj_conv;
19896         this_obj_conv.inner = (void*)(this_obj & (~1));
19897         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19898         NetGraphMsgHandler_free(this_obj_conv);
19899 }
19900
19901 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) {
19902         LDKThirtyTwoBytes genesis_hash_ref;
19903         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
19904         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
19905         LDKAccess *chain_access_conv_ptr = NULL;
19906         if (chain_access != 0) {
19907                 LDKAccess chain_access_conv;
19908                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19909                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
19910                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19911                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
19912                 }
19913                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19914                 *chain_access_conv_ptr = chain_access_conv;
19915         }
19916         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19917         if (logger_conv.free == LDKLogger_JCalls_free) {
19918                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19919                 LDKLogger_JCalls_clone(logger_conv.this_arg);
19920         }
19921         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
19922         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19923         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19924         long ret_ref = (long)ret_var.inner;
19925         if (ret_var.is_owned) {
19926                 ret_ref |= 1;
19927         }
19928         return ret_ref;
19929 }
19930
19931 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) {
19932         LDKAccess *chain_access_conv_ptr = NULL;
19933         if (chain_access != 0) {
19934                 LDKAccess chain_access_conv;
19935                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19936                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
19937                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19938                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
19939                 }
19940                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19941                 *chain_access_conv_ptr = chain_access_conv;
19942         }
19943         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19944         if (logger_conv.free == LDKLogger_JCalls_free) {
19945                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19946                 LDKLogger_JCalls_clone(logger_conv.this_arg);
19947         }
19948         LDKNetworkGraph network_graph_conv;
19949         network_graph_conv.inner = (void*)(network_graph & (~1));
19950         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
19951         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
19952         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
19953         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19954         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19955         long ret_ref = (long)ret_var.inner;
19956         if (ret_var.is_owned) {
19957                 ret_ref |= 1;
19958         }
19959         return ret_ref;
19960 }
19961
19962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
19963         LDKNetGraphMsgHandler this_arg_conv;
19964         this_arg_conv.inner = (void*)(this_arg & (~1));
19965         this_arg_conv.is_owned = false;
19966         LDKAccess *chain_access_conv_ptr = NULL;
19967         if (chain_access != 0) {
19968                 LDKAccess chain_access_conv;
19969                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19970                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
19971                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19972                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
19973                 }
19974                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19975                 *chain_access_conv_ptr = chain_access_conv;
19976         }
19977         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
19978 }
19979
19980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
19981         LDKNetGraphMsgHandler this_arg_conv;
19982         this_arg_conv.inner = (void*)(this_arg & (~1));
19983         this_arg_conv.is_owned = false;
19984         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
19985         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19986         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19987         long ret_ref = (long)ret_var.inner;
19988         if (ret_var.is_owned) {
19989                 ret_ref |= 1;
19990         }
19991         return ret_ref;
19992 }
19993
19994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
19995         LDKLockedNetworkGraph this_arg_conv;
19996         this_arg_conv.inner = (void*)(this_arg & (~1));
19997         this_arg_conv.is_owned = false;
19998         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
19999         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20000         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20001         long ret_ref = (long)ret_var.inner;
20002         if (ret_var.is_owned) {
20003                 ret_ref |= 1;
20004         }
20005         return ret_ref;
20006 }
20007
20008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
20009         LDKNetGraphMsgHandler this_arg_conv;
20010         this_arg_conv.inner = (void*)(this_arg & (~1));
20011         this_arg_conv.is_owned = false;
20012         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
20013         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
20014         return (long)ret;
20015 }
20016
20017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
20018         LDKNetGraphMsgHandler this_arg_conv;
20019         this_arg_conv.inner = (void*)(this_arg & (~1));
20020         this_arg_conv.is_owned = false;
20021         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20022         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
20023         return (long)ret;
20024 }
20025
20026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20027         LDKDirectionalChannelInfo this_obj_conv;
20028         this_obj_conv.inner = (void*)(this_obj & (~1));
20029         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20030         DirectionalChannelInfo_free(this_obj_conv);
20031 }
20032
20033 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
20034         LDKDirectionalChannelInfo this_ptr_conv;
20035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20036         this_ptr_conv.is_owned = false;
20037         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
20038         return ret_val;
20039 }
20040
20041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20042         LDKDirectionalChannelInfo this_ptr_conv;
20043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20044         this_ptr_conv.is_owned = false;
20045         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
20046 }
20047
20048 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
20049         LDKDirectionalChannelInfo this_ptr_conv;
20050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20051         this_ptr_conv.is_owned = false;
20052         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
20053         return ret_val;
20054 }
20055
20056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20057         LDKDirectionalChannelInfo this_ptr_conv;
20058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20059         this_ptr_conv.is_owned = false;
20060         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
20061 }
20062
20063 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
20064         LDKDirectionalChannelInfo this_ptr_conv;
20065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20066         this_ptr_conv.is_owned = false;
20067         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
20068         return ret_val;
20069 }
20070
20071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20072         LDKDirectionalChannelInfo this_ptr_conv;
20073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20074         this_ptr_conv.is_owned = false;
20075         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
20076 }
20077
20078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20079         LDKDirectionalChannelInfo this_ptr_conv;
20080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20081         this_ptr_conv.is_owned = false;
20082         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
20083         return ret_val;
20084 }
20085
20086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20087         LDKDirectionalChannelInfo this_ptr_conv;
20088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20089         this_ptr_conv.is_owned = false;
20090         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
20091 }
20092
20093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20094         LDKDirectionalChannelInfo this_ptr_conv;
20095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20096         this_ptr_conv.is_owned = false;
20097         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20098         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
20099         long ret_ref = (long)ret_copy;
20100         return ret_ref;
20101 }
20102
20103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20104         LDKDirectionalChannelInfo this_ptr_conv;
20105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20106         this_ptr_conv.is_owned = false;
20107         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20108         FREE((void*)val);
20109         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
20110 }
20111
20112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
20113         LDKDirectionalChannelInfo this_ptr_conv;
20114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20115         this_ptr_conv.is_owned = false;
20116         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
20117         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20118         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20119         long ret_ref = (long)ret_var.inner;
20120         if (ret_var.is_owned) {
20121                 ret_ref |= 1;
20122         }
20123         return ret_ref;
20124 }
20125
20126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20127         LDKDirectionalChannelInfo this_ptr_conv;
20128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20129         this_ptr_conv.is_owned = false;
20130         LDKRoutingFees val_conv;
20131         val_conv.inner = (void*)(val & (~1));
20132         val_conv.is_owned = (val & 1) || (val == 0);
20133         val_conv = RoutingFees_clone(&val_conv);
20134         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
20135 }
20136
20137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
20138         LDKDirectionalChannelInfo this_ptr_conv;
20139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20140         this_ptr_conv.is_owned = false;
20141         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
20142         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20143         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20144         long ret_ref = (long)ret_var.inner;
20145         if (ret_var.is_owned) {
20146                 ret_ref |= 1;
20147         }
20148         return ret_ref;
20149 }
20150
20151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20152         LDKDirectionalChannelInfo this_ptr_conv;
20153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20154         this_ptr_conv.is_owned = false;
20155         LDKChannelUpdate val_conv;
20156         val_conv.inner = (void*)(val & (~1));
20157         val_conv.is_owned = (val & 1) || (val == 0);
20158         val_conv = ChannelUpdate_clone(&val_conv);
20159         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
20160 }
20161
20162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1new(JNIEnv *env, jclass clz, int32_t last_update_arg, jboolean enabled_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int64_t fees_arg, int64_t last_update_message_arg) {
20163         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
20164         FREE((void*)htlc_maximum_msat_arg);
20165         LDKRoutingFees fees_arg_conv;
20166         fees_arg_conv.inner = (void*)(fees_arg & (~1));
20167         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
20168         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
20169         LDKChannelUpdate last_update_message_arg_conv;
20170         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
20171         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
20172         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
20173         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
20174         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20175         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20176         long ret_ref = (long)ret_var.inner;
20177         if (ret_var.is_owned) {
20178                 ret_ref |= 1;
20179         }
20180         return ret_ref;
20181 }
20182
20183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20184         LDKDirectionalChannelInfo orig_conv;
20185         orig_conv.inner = (void*)(orig & (~1));
20186         orig_conv.is_owned = false;
20187         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
20188         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20189         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20190         long ret_ref = (long)ret_var.inner;
20191         if (ret_var.is_owned) {
20192                 ret_ref |= 1;
20193         }
20194         return ret_ref;
20195 }
20196
20197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
20198         LDKDirectionalChannelInfo obj_conv;
20199         obj_conv.inner = (void*)(obj & (~1));
20200         obj_conv.is_owned = false;
20201         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
20202         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20203         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20204         CVec_u8Z_free(ret_var);
20205         return ret_arr;
20206 }
20207
20208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20209         LDKu8slice ser_ref;
20210         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20211         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20212         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
20213         *ret_conv = DirectionalChannelInfo_read(ser_ref);
20214         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20215         return (long)ret_conv;
20216 }
20217
20218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20219         LDKChannelInfo this_obj_conv;
20220         this_obj_conv.inner = (void*)(this_obj & (~1));
20221         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20222         ChannelInfo_free(this_obj_conv);
20223 }
20224
20225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20226         LDKChannelInfo this_ptr_conv;
20227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20228         this_ptr_conv.is_owned = false;
20229         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
20230         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20231         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20232         long ret_ref = (long)ret_var.inner;
20233         if (ret_var.is_owned) {
20234                 ret_ref |= 1;
20235         }
20236         return ret_ref;
20237 }
20238
20239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20240         LDKChannelInfo this_ptr_conv;
20241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20242         this_ptr_conv.is_owned = false;
20243         LDKChannelFeatures val_conv;
20244         val_conv.inner = (void*)(val & (~1));
20245         val_conv.is_owned = (val & 1) || (val == 0);
20246         val_conv = ChannelFeatures_clone(&val_conv);
20247         ChannelInfo_set_features(&this_ptr_conv, val_conv);
20248 }
20249
20250 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
20251         LDKChannelInfo this_ptr_conv;
20252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20253         this_ptr_conv.is_owned = false;
20254         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20255         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
20256         return ret_arr;
20257 }
20258
20259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20260         LDKChannelInfo this_ptr_conv;
20261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20262         this_ptr_conv.is_owned = false;
20263         LDKPublicKey val_ref;
20264         CHECK((*env)->GetArrayLength(env, val) == 33);
20265         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20266         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
20267 }
20268
20269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
20270         LDKChannelInfo this_ptr_conv;
20271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20272         this_ptr_conv.is_owned = false;
20273         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
20274         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20275         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20276         long ret_ref = (long)ret_var.inner;
20277         if (ret_var.is_owned) {
20278                 ret_ref |= 1;
20279         }
20280         return ret_ref;
20281 }
20282
20283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20284         LDKChannelInfo this_ptr_conv;
20285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20286         this_ptr_conv.is_owned = false;
20287         LDKDirectionalChannelInfo val_conv;
20288         val_conv.inner = (void*)(val & (~1));
20289         val_conv.is_owned = (val & 1) || (val == 0);
20290         val_conv = DirectionalChannelInfo_clone(&val_conv);
20291         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
20292 }
20293
20294 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
20295         LDKChannelInfo this_ptr_conv;
20296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20297         this_ptr_conv.is_owned = false;
20298         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20299         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
20300         return ret_arr;
20301 }
20302
20303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20304         LDKChannelInfo this_ptr_conv;
20305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20306         this_ptr_conv.is_owned = false;
20307         LDKPublicKey val_ref;
20308         CHECK((*env)->GetArrayLength(env, val) == 33);
20309         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20310         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
20311 }
20312
20313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
20314         LDKChannelInfo this_ptr_conv;
20315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20316         this_ptr_conv.is_owned = false;
20317         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
20318         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20319         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20320         long ret_ref = (long)ret_var.inner;
20321         if (ret_var.is_owned) {
20322                 ret_ref |= 1;
20323         }
20324         return ret_ref;
20325 }
20326
20327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20328         LDKChannelInfo this_ptr_conv;
20329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20330         this_ptr_conv.is_owned = false;
20331         LDKDirectionalChannelInfo val_conv;
20332         val_conv.inner = (void*)(val & (~1));
20333         val_conv.is_owned = (val & 1) || (val == 0);
20334         val_conv = DirectionalChannelInfo_clone(&val_conv);
20335         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
20336 }
20337
20338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
20339         LDKChannelInfo this_ptr_conv;
20340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20341         this_ptr_conv.is_owned = false;
20342         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20343         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
20344         long ret_ref = (long)ret_copy;
20345         return ret_ref;
20346 }
20347
20348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20349         LDKChannelInfo this_ptr_conv;
20350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20351         this_ptr_conv.is_owned = false;
20352         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20353         FREE((void*)val);
20354         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
20355 }
20356
20357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
20358         LDKChannelInfo this_ptr_conv;
20359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20360         this_ptr_conv.is_owned = false;
20361         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
20362         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20363         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20364         long ret_ref = (long)ret_var.inner;
20365         if (ret_var.is_owned) {
20366                 ret_ref |= 1;
20367         }
20368         return ret_ref;
20369 }
20370
20371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20372         LDKChannelInfo this_ptr_conv;
20373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20374         this_ptr_conv.is_owned = false;
20375         LDKChannelAnnouncement val_conv;
20376         val_conv.inner = (void*)(val & (~1));
20377         val_conv.is_owned = (val & 1) || (val == 0);
20378         val_conv = ChannelAnnouncement_clone(&val_conv);
20379         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
20380 }
20381
20382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int8_tArray node_one_arg, int64_t one_to_two_arg, int8_tArray node_two_arg, int64_t two_to_one_arg, int64_t capacity_sats_arg, int64_t announcement_message_arg) {
20383         LDKChannelFeatures features_arg_conv;
20384         features_arg_conv.inner = (void*)(features_arg & (~1));
20385         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
20386         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
20387         LDKPublicKey node_one_arg_ref;
20388         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
20389         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
20390         LDKDirectionalChannelInfo one_to_two_arg_conv;
20391         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
20392         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
20393         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
20394         LDKPublicKey node_two_arg_ref;
20395         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
20396         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
20397         LDKDirectionalChannelInfo two_to_one_arg_conv;
20398         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
20399         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
20400         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
20401         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
20402         FREE((void*)capacity_sats_arg);
20403         LDKChannelAnnouncement announcement_message_arg_conv;
20404         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
20405         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
20406         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
20407         LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_ref, one_to_two_arg_conv, node_two_arg_ref, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
20408         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20409         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20410         long ret_ref = (long)ret_var.inner;
20411         if (ret_var.is_owned) {
20412                 ret_ref |= 1;
20413         }
20414         return ret_ref;
20415 }
20416
20417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20418         LDKChannelInfo orig_conv;
20419         orig_conv.inner = (void*)(orig & (~1));
20420         orig_conv.is_owned = false;
20421         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
20422         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20423         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20424         long ret_ref = (long)ret_var.inner;
20425         if (ret_var.is_owned) {
20426                 ret_ref |= 1;
20427         }
20428         return ret_ref;
20429 }
20430
20431 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
20432         LDKChannelInfo obj_conv;
20433         obj_conv.inner = (void*)(obj & (~1));
20434         obj_conv.is_owned = false;
20435         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
20436         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20437         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20438         CVec_u8Z_free(ret_var);
20439         return ret_arr;
20440 }
20441
20442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20443         LDKu8slice ser_ref;
20444         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20445         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20446         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20447         *ret_conv = ChannelInfo_read(ser_ref);
20448         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20449         return (long)ret_conv;
20450 }
20451
20452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20453         LDKRoutingFees this_obj_conv;
20454         this_obj_conv.inner = (void*)(this_obj & (~1));
20455         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20456         RoutingFees_free(this_obj_conv);
20457 }
20458
20459 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20460         LDKRoutingFees this_ptr_conv;
20461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20462         this_ptr_conv.is_owned = false;
20463         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
20464         return ret_val;
20465 }
20466
20467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20468         LDKRoutingFees this_ptr_conv;
20469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20470         this_ptr_conv.is_owned = false;
20471         RoutingFees_set_base_msat(&this_ptr_conv, val);
20472 }
20473
20474 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
20475         LDKRoutingFees this_ptr_conv;
20476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20477         this_ptr_conv.is_owned = false;
20478         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
20479         return ret_val;
20480 }
20481
20482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20483         LDKRoutingFees this_ptr_conv;
20484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20485         this_ptr_conv.is_owned = false;
20486         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
20487 }
20488
20489 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) {
20490         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
20491         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20492         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20493         long ret_ref = (long)ret_var.inner;
20494         if (ret_var.is_owned) {
20495                 ret_ref |= 1;
20496         }
20497         return ret_ref;
20498 }
20499
20500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20501         LDKRoutingFees orig_conv;
20502         orig_conv.inner = (void*)(orig & (~1));
20503         orig_conv.is_owned = false;
20504         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
20505         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20506         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20507         long ret_ref = (long)ret_var.inner;
20508         if (ret_var.is_owned) {
20509                 ret_ref |= 1;
20510         }
20511         return ret_ref;
20512 }
20513
20514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20515         LDKu8slice ser_ref;
20516         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20517         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20518         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20519         *ret_conv = RoutingFees_read(ser_ref);
20520         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20521         return (long)ret_conv;
20522 }
20523
20524 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
20525         LDKRoutingFees obj_conv;
20526         obj_conv.inner = (void*)(obj & (~1));
20527         obj_conv.is_owned = false;
20528         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
20529         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20530         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20531         CVec_u8Z_free(ret_var);
20532         return ret_arr;
20533 }
20534
20535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20536         LDKNodeAnnouncementInfo this_obj_conv;
20537         this_obj_conv.inner = (void*)(this_obj & (~1));
20538         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20539         NodeAnnouncementInfo_free(this_obj_conv);
20540 }
20541
20542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20543         LDKNodeAnnouncementInfo this_ptr_conv;
20544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20545         this_ptr_conv.is_owned = false;
20546         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
20547         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20548         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20549         long ret_ref = (long)ret_var.inner;
20550         if (ret_var.is_owned) {
20551                 ret_ref |= 1;
20552         }
20553         return ret_ref;
20554 }
20555
20556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20557         LDKNodeAnnouncementInfo this_ptr_conv;
20558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20559         this_ptr_conv.is_owned = false;
20560         LDKNodeFeatures val_conv;
20561         val_conv.inner = (void*)(val & (~1));
20562         val_conv.is_owned = (val & 1) || (val == 0);
20563         val_conv = NodeFeatures_clone(&val_conv);
20564         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
20565 }
20566
20567 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
20568         LDKNodeAnnouncementInfo this_ptr_conv;
20569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20570         this_ptr_conv.is_owned = false;
20571         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
20572         return ret_val;
20573 }
20574
20575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20576         LDKNodeAnnouncementInfo this_ptr_conv;
20577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20578         this_ptr_conv.is_owned = false;
20579         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
20580 }
20581
20582 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
20583         LDKNodeAnnouncementInfo this_ptr_conv;
20584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20585         this_ptr_conv.is_owned = false;
20586         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
20587         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
20588         return ret_arr;
20589 }
20590
20591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20592         LDKNodeAnnouncementInfo this_ptr_conv;
20593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20594         this_ptr_conv.is_owned = false;
20595         LDKThreeBytes val_ref;
20596         CHECK((*env)->GetArrayLength(env, val) == 3);
20597         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
20598         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
20599 }
20600
20601 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
20602         LDKNodeAnnouncementInfo this_ptr_conv;
20603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20604         this_ptr_conv.is_owned = false;
20605         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20606         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
20607         return ret_arr;
20608 }
20609
20610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20611         LDKNodeAnnouncementInfo this_ptr_conv;
20612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20613         this_ptr_conv.is_owned = false;
20614         LDKThirtyTwoBytes val_ref;
20615         CHECK((*env)->GetArrayLength(env, val) == 32);
20616         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20617         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
20618 }
20619
20620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20621         LDKNodeAnnouncementInfo this_ptr_conv;
20622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20623         this_ptr_conv.is_owned = false;
20624         LDKCVec_NetAddressZ val_constr;
20625         val_constr.datalen = (*env)->GetArrayLength(env, val);
20626         if (val_constr.datalen > 0)
20627                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20628         else
20629                 val_constr.data = NULL;
20630         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20631         for (size_t m = 0; m < val_constr.datalen; m++) {
20632                 int64_t val_conv_12 = val_vals[m];
20633                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
20634                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
20635                 val_constr.data[m] = val_conv_12_conv;
20636         }
20637         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20638         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
20639 }
20640
20641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
20642         LDKNodeAnnouncementInfo this_ptr_conv;
20643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20644         this_ptr_conv.is_owned = false;
20645         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
20646         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20647         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20648         long ret_ref = (long)ret_var.inner;
20649         if (ret_var.is_owned) {
20650                 ret_ref |= 1;
20651         }
20652         return ret_ref;
20653 }
20654
20655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20656         LDKNodeAnnouncementInfo this_ptr_conv;
20657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20658         this_ptr_conv.is_owned = false;
20659         LDKNodeAnnouncement val_conv;
20660         val_conv.inner = (void*)(val & (~1));
20661         val_conv.is_owned = (val & 1) || (val == 0);
20662         val_conv = NodeAnnouncement_clone(&val_conv);
20663         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
20664 }
20665
20666 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) {
20667         LDKNodeFeatures features_arg_conv;
20668         features_arg_conv.inner = (void*)(features_arg & (~1));
20669         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
20670         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
20671         LDKThreeBytes rgb_arg_ref;
20672         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
20673         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
20674         LDKThirtyTwoBytes alias_arg_ref;
20675         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
20676         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
20677         LDKCVec_NetAddressZ addresses_arg_constr;
20678         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
20679         if (addresses_arg_constr.datalen > 0)
20680                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20681         else
20682                 addresses_arg_constr.data = NULL;
20683         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
20684         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
20685                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
20686                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
20687                 FREE((void*)addresses_arg_conv_12);
20688                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
20689         }
20690         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
20691         LDKNodeAnnouncement announcement_message_arg_conv;
20692         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
20693         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
20694         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
20695         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
20696         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20697         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20698         long ret_ref = (long)ret_var.inner;
20699         if (ret_var.is_owned) {
20700                 ret_ref |= 1;
20701         }
20702         return ret_ref;
20703 }
20704
20705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20706         LDKNodeAnnouncementInfo orig_conv;
20707         orig_conv.inner = (void*)(orig & (~1));
20708         orig_conv.is_owned = false;
20709         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
20710         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20711         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20712         long ret_ref = (long)ret_var.inner;
20713         if (ret_var.is_owned) {
20714                 ret_ref |= 1;
20715         }
20716         return ret_ref;
20717 }
20718
20719 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
20720         LDKNodeAnnouncementInfo obj_conv;
20721         obj_conv.inner = (void*)(obj & (~1));
20722         obj_conv.is_owned = false;
20723         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
20724         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20725         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20726         CVec_u8Z_free(ret_var);
20727         return ret_arr;
20728 }
20729
20730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20731         LDKu8slice ser_ref;
20732         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20733         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20734         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20735         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
20736         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20737         return (long)ret_conv;
20738 }
20739
20740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20741         LDKNodeInfo this_obj_conv;
20742         this_obj_conv.inner = (void*)(this_obj & (~1));
20743         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20744         NodeInfo_free(this_obj_conv);
20745 }
20746
20747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20748         LDKNodeInfo this_ptr_conv;
20749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20750         this_ptr_conv.is_owned = false;
20751         LDKCVec_u64Z val_constr;
20752         val_constr.datalen = (*env)->GetArrayLength(env, val);
20753         if (val_constr.datalen > 0)
20754                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20755         else
20756                 val_constr.data = NULL;
20757         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20758         for (size_t g = 0; g < val_constr.datalen; g++) {
20759                 int64_t val_conv_6 = val_vals[g];
20760                 val_constr.data[g] = val_conv_6;
20761         }
20762         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20763         NodeInfo_set_channels(&this_ptr_conv, val_constr);
20764 }
20765
20766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
20767         LDKNodeInfo this_ptr_conv;
20768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20769         this_ptr_conv.is_owned = false;
20770         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
20771         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20772         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20773         long ret_ref = (long)ret_var.inner;
20774         if (ret_var.is_owned) {
20775                 ret_ref |= 1;
20776         }
20777         return ret_ref;
20778 }
20779
20780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20781         LDKNodeInfo this_ptr_conv;
20782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20783         this_ptr_conv.is_owned = false;
20784         LDKRoutingFees val_conv;
20785         val_conv.inner = (void*)(val & (~1));
20786         val_conv.is_owned = (val & 1) || (val == 0);
20787         val_conv = RoutingFees_clone(&val_conv);
20788         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
20789 }
20790
20791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
20792         LDKNodeInfo this_ptr_conv;
20793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20794         this_ptr_conv.is_owned = false;
20795         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
20796         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20797         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20798         long ret_ref = (long)ret_var.inner;
20799         if (ret_var.is_owned) {
20800                 ret_ref |= 1;
20801         }
20802         return ret_ref;
20803 }
20804
20805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20806         LDKNodeInfo this_ptr_conv;
20807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20808         this_ptr_conv.is_owned = false;
20809         LDKNodeAnnouncementInfo val_conv;
20810         val_conv.inner = (void*)(val & (~1));
20811         val_conv.is_owned = (val & 1) || (val == 0);
20812         val_conv = NodeAnnouncementInfo_clone(&val_conv);
20813         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
20814 }
20815
20816 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) {
20817         LDKCVec_u64Z channels_arg_constr;
20818         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
20819         if (channels_arg_constr.datalen > 0)
20820                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20821         else
20822                 channels_arg_constr.data = NULL;
20823         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
20824         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
20825                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
20826                 channels_arg_constr.data[g] = channels_arg_conv_6;
20827         }
20828         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
20829         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
20830         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
20831         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
20832         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
20833         LDKNodeAnnouncementInfo announcement_info_arg_conv;
20834         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
20835         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
20836         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
20837         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
20838         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20839         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20840         long ret_ref = (long)ret_var.inner;
20841         if (ret_var.is_owned) {
20842                 ret_ref |= 1;
20843         }
20844         return ret_ref;
20845 }
20846
20847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20848         LDKNodeInfo orig_conv;
20849         orig_conv.inner = (void*)(orig & (~1));
20850         orig_conv.is_owned = false;
20851         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
20852         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20853         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20854         long ret_ref = (long)ret_var.inner;
20855         if (ret_var.is_owned) {
20856                 ret_ref |= 1;
20857         }
20858         return ret_ref;
20859 }
20860
20861 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
20862         LDKNodeInfo obj_conv;
20863         obj_conv.inner = (void*)(obj & (~1));
20864         obj_conv.is_owned = false;
20865         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
20866         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20867         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20868         CVec_u8Z_free(ret_var);
20869         return ret_arr;
20870 }
20871
20872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20873         LDKu8slice ser_ref;
20874         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20875         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20876         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20877         *ret_conv = NodeInfo_read(ser_ref);
20878         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20879         return (long)ret_conv;
20880 }
20881
20882 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
20883         LDKNetworkGraph obj_conv;
20884         obj_conv.inner = (void*)(obj & (~1));
20885         obj_conv.is_owned = false;
20886         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
20887         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20888         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20889         CVec_u8Z_free(ret_var);
20890         return ret_arr;
20891 }
20892
20893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20894         LDKu8slice ser_ref;
20895         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20896         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20897         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20898         *ret_conv = NetworkGraph_read(ser_ref);
20899         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20900         return (long)ret_conv;
20901 }
20902
20903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
20904         LDKThirtyTwoBytes genesis_hash_ref;
20905         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
20906         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
20907         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
20908         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20909         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20910         long ret_ref = (long)ret_var.inner;
20911         if (ret_var.is_owned) {
20912                 ret_ref |= 1;
20913         }
20914         return ret_ref;
20915 }
20916
20917 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) {
20918         LDKNetworkGraph this_arg_conv;
20919         this_arg_conv.inner = (void*)(this_arg & (~1));
20920         this_arg_conv.is_owned = false;
20921         LDKNodeAnnouncement msg_conv;
20922         msg_conv.inner = (void*)(msg & (~1));
20923         msg_conv.is_owned = false;
20924         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20925         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
20926         return (long)ret_conv;
20927 }
20928
20929 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) {
20930         LDKNetworkGraph this_arg_conv;
20931         this_arg_conv.inner = (void*)(this_arg & (~1));
20932         this_arg_conv.is_owned = false;
20933         LDKUnsignedNodeAnnouncement msg_conv;
20934         msg_conv.inner = (void*)(msg & (~1));
20935         msg_conv.is_owned = false;
20936         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20937         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
20938         return (long)ret_conv;
20939 }
20940
20941 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) {
20942         LDKNetworkGraph this_arg_conv;
20943         this_arg_conv.inner = (void*)(this_arg & (~1));
20944         this_arg_conv.is_owned = false;
20945         LDKChannelAnnouncement msg_conv;
20946         msg_conv.inner = (void*)(msg & (~1));
20947         msg_conv.is_owned = false;
20948         LDKAccess *chain_access_conv_ptr = NULL;
20949         if (chain_access != 0) {
20950                 LDKAccess chain_access_conv;
20951                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20952                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
20953                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20954                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
20955                 }
20956                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20957                 *chain_access_conv_ptr = chain_access_conv;
20958         }
20959         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20960         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
20961         return (long)ret_conv;
20962 }
20963
20964 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) {
20965         LDKNetworkGraph this_arg_conv;
20966         this_arg_conv.inner = (void*)(this_arg & (~1));
20967         this_arg_conv.is_owned = false;
20968         LDKUnsignedChannelAnnouncement msg_conv;
20969         msg_conv.inner = (void*)(msg & (~1));
20970         msg_conv.is_owned = false;
20971         LDKAccess *chain_access_conv_ptr = NULL;
20972         if (chain_access != 0) {
20973                 LDKAccess chain_access_conv;
20974                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20975                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
20976                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20977                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
20978                 }
20979                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20980                 *chain_access_conv_ptr = chain_access_conv;
20981         }
20982         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20983         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
20984         return (long)ret_conv;
20985 }
20986
20987 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) {
20988         LDKNetworkGraph this_arg_conv;
20989         this_arg_conv.inner = (void*)(this_arg & (~1));
20990         this_arg_conv.is_owned = false;
20991         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
20992 }
20993
20994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
20995         LDKNetworkGraph this_arg_conv;
20996         this_arg_conv.inner = (void*)(this_arg & (~1));
20997         this_arg_conv.is_owned = false;
20998         LDKChannelUpdate msg_conv;
20999         msg_conv.inner = (void*)(msg & (~1));
21000         msg_conv.is_owned = false;
21001         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21002         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
21003         return (long)ret_conv;
21004 }
21005
21006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
21007         LDKNetworkGraph this_arg_conv;
21008         this_arg_conv.inner = (void*)(this_arg & (~1));
21009         this_arg_conv.is_owned = false;
21010         LDKUnsignedChannelUpdate msg_conv;
21011         msg_conv.inner = (void*)(msg & (~1));
21012         msg_conv.is_owned = false;
21013         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21014         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
21015         return (long)ret_conv;
21016 }
21017