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                         FREE((void*)arr_elem);
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                         FREE((void*)arr_elem);
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                         FREE((void*)arr_elem);
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                         FREE((void*)arr_elem);
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                         FREE((void*)arr_elem);
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                         FREE((void*)arr_elem);
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                         FREE((void*)arr_elem);
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                         FREE((void*)arr_elem);
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                 FREE((void*)b_conv_27);
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                         FREE((void*)arr_elem);
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         FREE((void*)b);
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                         FREE((void*)arr_elem);
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                 FREE((void*)b_conv_26);
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                         FREE((void*)arr_elem);
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*)ret);
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*)ret);
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*)ret);
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*)ret);
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*)ret);
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*)ret);
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                         FREE((void*)arr_elem);
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                         FREE((void*)arr_elem);
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*)ret);
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*)ret);
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*)ret_conv_14);
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*)ret);
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                         FREE((void*)arr_elem);
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*)ret_conv_18);
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*)ret_conv_7);
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*)ret);
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*)ret);
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*)ret);
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*)ret);
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*)ret);
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*)ret);
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*)ret_conv_63);
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*)ret);
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*)ret);
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*)ret);
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*)ret);
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                 FREE((void*)b_conv_27);
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                 FREE((void*)b_conv_26);
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                 FREE((void*)txdata_conv_24);
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                 FREE((void*)txdata_conv_24);
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                 FREE((void*)descriptors_conv_27);
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                 FREE((void*)outputs_conv_7);
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                 FREE((void*)txdata_conv_24);
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 void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
12726         LDKChannelManager this_arg_conv;
12727         this_arg_conv.inner = (void*)(this_arg & (~1));
12728         this_arg_conv.is_owned = false;
12729         ChannelManager_await_persistable_update(&this_arg_conv);
12730 }
12731
12732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
12733         LDKChannelManager this_arg_conv;
12734         this_arg_conv.inner = (void*)(this_arg & (~1));
12735         this_arg_conv.is_owned = false;
12736         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
12737         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
12738         return (long)ret;
12739 }
12740
12741 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
12742         LDKChannelManager obj_conv;
12743         obj_conv.inner = (void*)(obj & (~1));
12744         obj_conv.is_owned = false;
12745         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
12746         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
12747         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
12748         CVec_u8Z_free(ret_var);
12749         return ret_arr;
12750 }
12751
12752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12753         LDKChannelManagerReadArgs this_obj_conv;
12754         this_obj_conv.inner = (void*)(this_obj & (~1));
12755         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12756         ChannelManagerReadArgs_free(this_obj_conv);
12757 }
12758
12759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
12760         LDKChannelManagerReadArgs this_ptr_conv;
12761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12762         this_ptr_conv.is_owned = false;
12763         long ret_ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
12764         return ret_ret;
12765 }
12766
12767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12768         LDKChannelManagerReadArgs this_ptr_conv;
12769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12770         this_ptr_conv.is_owned = false;
12771         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
12772         if (val_conv.free == LDKKeysInterface_JCalls_free) {
12773                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12774                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
12775         }
12776         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
12777 }
12778
12779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
12780         LDKChannelManagerReadArgs this_ptr_conv;
12781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12782         this_ptr_conv.is_owned = false;
12783         long ret_ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
12784         return ret_ret;
12785 }
12786
12787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12788         LDKChannelManagerReadArgs this_ptr_conv;
12789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12790         this_ptr_conv.is_owned = false;
12791         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
12792         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
12793                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12794                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
12795         }
12796         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
12797 }
12798
12799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
12800         LDKChannelManagerReadArgs this_ptr_conv;
12801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12802         this_ptr_conv.is_owned = false;
12803         long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
12804         return ret_ret;
12805 }
12806
12807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12808         LDKChannelManagerReadArgs this_ptr_conv;
12809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12810         this_ptr_conv.is_owned = false;
12811         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
12812         if (val_conv.free == LDKWatch_JCalls_free) {
12813                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12814                 LDKWatch_JCalls_clone(val_conv.this_arg);
12815         }
12816         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
12817 }
12818
12819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
12820         LDKChannelManagerReadArgs this_ptr_conv;
12821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12822         this_ptr_conv.is_owned = false;
12823         long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
12824         return ret_ret;
12825 }
12826
12827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12828         LDKChannelManagerReadArgs this_ptr_conv;
12829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12830         this_ptr_conv.is_owned = false;
12831         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
12832         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
12833                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12834                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
12835         }
12836         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
12837 }
12838
12839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
12840         LDKChannelManagerReadArgs this_ptr_conv;
12841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12842         this_ptr_conv.is_owned = false;
12843         long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
12844         return ret_ret;
12845 }
12846
12847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12848         LDKChannelManagerReadArgs this_ptr_conv;
12849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12850         this_ptr_conv.is_owned = false;
12851         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
12852         if (val_conv.free == LDKLogger_JCalls_free) {
12853                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12854                 LDKLogger_JCalls_clone(val_conv.this_arg);
12855         }
12856         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
12857 }
12858
12859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
12860         LDKChannelManagerReadArgs this_ptr_conv;
12861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12862         this_ptr_conv.is_owned = false;
12863         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
12864         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12865         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12866         long ret_ref = (long)ret_var.inner;
12867         if (ret_var.is_owned) {
12868                 ret_ref |= 1;
12869         }
12870         return ret_ref;
12871 }
12872
12873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12874         LDKChannelManagerReadArgs this_ptr_conv;
12875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12876         this_ptr_conv.is_owned = false;
12877         LDKUserConfig val_conv;
12878         val_conv.inner = (void*)(val & (~1));
12879         val_conv.is_owned = (val & 1) || (val == 0);
12880         val_conv = UserConfig_clone(&val_conv);
12881         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
12882 }
12883
12884 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) {
12885         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
12886         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
12887                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12888                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
12889         }
12890         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12891         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
12892                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12893                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
12894         }
12895         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
12896         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
12897                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12898                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
12899         }
12900         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
12901         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
12902                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12903                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
12904         }
12905         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12906         if (logger_conv.free == LDKLogger_JCalls_free) {
12907                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12908                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12909         }
12910         LDKUserConfig default_config_conv;
12911         default_config_conv.inner = (void*)(default_config & (~1));
12912         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
12913         default_config_conv = UserConfig_clone(&default_config_conv);
12914         LDKCVec_ChannelMonitorZ channel_monitors_constr;
12915         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
12916         if (channel_monitors_constr.datalen > 0)
12917                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
12918         else
12919                 channel_monitors_constr.data = NULL;
12920         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
12921         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
12922                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
12923                 LDKChannelMonitor channel_monitors_conv_16_conv;
12924                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
12925                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
12926                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
12927         }
12928         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
12929         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);
12930         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12931         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12932         long ret_ref = (long)ret_var.inner;
12933         if (ret_var.is_owned) {
12934                 ret_ref |= 1;
12935         }
12936         return ret_ref;
12937 }
12938
12939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
12940         LDKu8slice ser_ref;
12941         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
12942         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
12943         LDKChannelManagerReadArgs arg_conv;
12944         arg_conv.inner = (void*)(arg & (~1));
12945         arg_conv.is_owned = (arg & 1) || (arg == 0);
12946         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
12947         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
12948         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
12949         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
12950         return (long)ret_conv;
12951 }
12952
12953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12954         LDKDecodeError this_obj_conv;
12955         this_obj_conv.inner = (void*)(this_obj & (~1));
12956         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12957         DecodeError_free(this_obj_conv);
12958 }
12959
12960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12961         LDKDecodeError orig_conv;
12962         orig_conv.inner = (void*)(orig & (~1));
12963         orig_conv.is_owned = false;
12964         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
12965         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12966         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12967         long ret_ref = (long)ret_var.inner;
12968         if (ret_var.is_owned) {
12969                 ret_ref |= 1;
12970         }
12971         return ret_ref;
12972 }
12973
12974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12975         LDKInit this_obj_conv;
12976         this_obj_conv.inner = (void*)(this_obj & (~1));
12977         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12978         Init_free(this_obj_conv);
12979 }
12980
12981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
12982         LDKInit this_ptr_conv;
12983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12984         this_ptr_conv.is_owned = false;
12985         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
12986         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12987         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12988         long ret_ref = (long)ret_var.inner;
12989         if (ret_var.is_owned) {
12990                 ret_ref |= 1;
12991         }
12992         return ret_ref;
12993 }
12994
12995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12996         LDKInit this_ptr_conv;
12997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12998         this_ptr_conv.is_owned = false;
12999         LDKInitFeatures val_conv;
13000         val_conv.inner = (void*)(val & (~1));
13001         val_conv.is_owned = (val & 1) || (val == 0);
13002         val_conv = InitFeatures_clone(&val_conv);
13003         Init_set_features(&this_ptr_conv, val_conv);
13004 }
13005
13006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
13007         LDKInitFeatures features_arg_conv;
13008         features_arg_conv.inner = (void*)(features_arg & (~1));
13009         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
13010         features_arg_conv = InitFeatures_clone(&features_arg_conv);
13011         LDKInit ret_var = Init_new(features_arg_conv);
13012         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13013         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13014         long ret_ref = (long)ret_var.inner;
13015         if (ret_var.is_owned) {
13016                 ret_ref |= 1;
13017         }
13018         return ret_ref;
13019 }
13020
13021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13022         LDKInit orig_conv;
13023         orig_conv.inner = (void*)(orig & (~1));
13024         orig_conv.is_owned = false;
13025         LDKInit ret_var = Init_clone(&orig_conv);
13026         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13027         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13028         long ret_ref = (long)ret_var.inner;
13029         if (ret_var.is_owned) {
13030                 ret_ref |= 1;
13031         }
13032         return ret_ref;
13033 }
13034
13035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13036         LDKErrorMessage this_obj_conv;
13037         this_obj_conv.inner = (void*)(this_obj & (~1));
13038         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13039         ErrorMessage_free(this_obj_conv);
13040 }
13041
13042 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13043         LDKErrorMessage this_ptr_conv;
13044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13045         this_ptr_conv.is_owned = false;
13046         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13047         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
13048         return ret_arr;
13049 }
13050
13051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13052         LDKErrorMessage this_ptr_conv;
13053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13054         this_ptr_conv.is_owned = false;
13055         LDKThirtyTwoBytes val_ref;
13056         CHECK((*env)->GetArrayLength(env, val) == 32);
13057         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13058         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
13059 }
13060
13061 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
13062         LDKErrorMessage this_ptr_conv;
13063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13064         this_ptr_conv.is_owned = false;
13065         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
13066         jstring _conv = str_ref_to_java(env, _str.chars, _str.len);
13067         return _conv;
13068 }
13069
13070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13071         LDKErrorMessage this_ptr_conv;
13072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13073         this_ptr_conv.is_owned = false;
13074         LDKCVec_u8Z val_ref;
13075         val_ref.datalen = (*env)->GetArrayLength(env, val);
13076         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
13077         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
13078         ErrorMessage_set_data(&this_ptr_conv, val_ref);
13079 }
13080
13081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray data_arg) {
13082         LDKThirtyTwoBytes channel_id_arg_ref;
13083         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13084         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13085         LDKCVec_u8Z data_arg_ref;
13086         data_arg_ref.datalen = (*env)->GetArrayLength(env, data_arg);
13087         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
13088         (*env)->GetByteArrayRegion(env, data_arg, 0, data_arg_ref.datalen, data_arg_ref.data);
13089         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
13090         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13091         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13092         long ret_ref = (long)ret_var.inner;
13093         if (ret_var.is_owned) {
13094                 ret_ref |= 1;
13095         }
13096         return ret_ref;
13097 }
13098
13099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13100         LDKErrorMessage orig_conv;
13101         orig_conv.inner = (void*)(orig & (~1));
13102         orig_conv.is_owned = false;
13103         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
13104         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13105         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13106         long ret_ref = (long)ret_var.inner;
13107         if (ret_var.is_owned) {
13108                 ret_ref |= 1;
13109         }
13110         return ret_ref;
13111 }
13112
13113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13114         LDKPing this_obj_conv;
13115         this_obj_conv.inner = (void*)(this_obj & (~1));
13116         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13117         Ping_free(this_obj_conv);
13118 }
13119
13120 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
13121         LDKPing this_ptr_conv;
13122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13123         this_ptr_conv.is_owned = false;
13124         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
13125         return ret_val;
13126 }
13127
13128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13129         LDKPing this_ptr_conv;
13130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13131         this_ptr_conv.is_owned = false;
13132         Ping_set_ponglen(&this_ptr_conv, val);
13133 }
13134
13135 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
13136         LDKPing this_ptr_conv;
13137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13138         this_ptr_conv.is_owned = false;
13139         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
13140         return ret_val;
13141 }
13142
13143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13144         LDKPing this_ptr_conv;
13145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13146         this_ptr_conv.is_owned = false;
13147         Ping_set_byteslen(&this_ptr_conv, val);
13148 }
13149
13150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
13151         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
13152         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13153         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13154         long ret_ref = (long)ret_var.inner;
13155         if (ret_var.is_owned) {
13156                 ret_ref |= 1;
13157         }
13158         return ret_ref;
13159 }
13160
13161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13162         LDKPing orig_conv;
13163         orig_conv.inner = (void*)(orig & (~1));
13164         orig_conv.is_owned = false;
13165         LDKPing ret_var = Ping_clone(&orig_conv);
13166         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13167         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13168         long ret_ref = (long)ret_var.inner;
13169         if (ret_var.is_owned) {
13170                 ret_ref |= 1;
13171         }
13172         return ret_ref;
13173 }
13174
13175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13176         LDKPong this_obj_conv;
13177         this_obj_conv.inner = (void*)(this_obj & (~1));
13178         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13179         Pong_free(this_obj_conv);
13180 }
13181
13182 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
13183         LDKPong this_ptr_conv;
13184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13185         this_ptr_conv.is_owned = false;
13186         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
13187         return ret_val;
13188 }
13189
13190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13191         LDKPong this_ptr_conv;
13192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13193         this_ptr_conv.is_owned = false;
13194         Pong_set_byteslen(&this_ptr_conv, val);
13195 }
13196
13197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
13198         LDKPong ret_var = Pong_new(byteslen_arg);
13199         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13200         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13201         long ret_ref = (long)ret_var.inner;
13202         if (ret_var.is_owned) {
13203                 ret_ref |= 1;
13204         }
13205         return ret_ref;
13206 }
13207
13208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13209         LDKPong orig_conv;
13210         orig_conv.inner = (void*)(orig & (~1));
13211         orig_conv.is_owned = false;
13212         LDKPong ret_var = Pong_clone(&orig_conv);
13213         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13214         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13215         long ret_ref = (long)ret_var.inner;
13216         if (ret_var.is_owned) {
13217                 ret_ref |= 1;
13218         }
13219         return ret_ref;
13220 }
13221
13222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13223         LDKOpenChannel this_obj_conv;
13224         this_obj_conv.inner = (void*)(this_obj & (~1));
13225         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13226         OpenChannel_free(this_obj_conv);
13227 }
13228
13229 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
13230         LDKOpenChannel this_ptr_conv;
13231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13232         this_ptr_conv.is_owned = false;
13233         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13234         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
13235         return ret_arr;
13236 }
13237
13238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13239         LDKOpenChannel this_ptr_conv;
13240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13241         this_ptr_conv.is_owned = false;
13242         LDKThirtyTwoBytes val_ref;
13243         CHECK((*env)->GetArrayLength(env, val) == 32);
13244         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13245         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
13246 }
13247
13248 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13249         LDKOpenChannel this_ptr_conv;
13250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13251         this_ptr_conv.is_owned = false;
13252         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13253         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
13254         return ret_arr;
13255 }
13256
13257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13258         LDKOpenChannel this_ptr_conv;
13259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13260         this_ptr_conv.is_owned = false;
13261         LDKThirtyTwoBytes val_ref;
13262         CHECK((*env)->GetArrayLength(env, val) == 32);
13263         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13264         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
13265 }
13266
13267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13268         LDKOpenChannel this_ptr_conv;
13269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13270         this_ptr_conv.is_owned = false;
13271         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
13272         return ret_val;
13273 }
13274
13275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13276         LDKOpenChannel this_ptr_conv;
13277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13278         this_ptr_conv.is_owned = false;
13279         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
13280 }
13281
13282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13283         LDKOpenChannel this_ptr_conv;
13284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13285         this_ptr_conv.is_owned = false;
13286         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
13287         return ret_val;
13288 }
13289
13290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13291         LDKOpenChannel this_ptr_conv;
13292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13293         this_ptr_conv.is_owned = false;
13294         OpenChannel_set_push_msat(&this_ptr_conv, val);
13295 }
13296
13297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13298         LDKOpenChannel this_ptr_conv;
13299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13300         this_ptr_conv.is_owned = false;
13301         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
13302         return ret_val;
13303 }
13304
13305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13306         LDKOpenChannel this_ptr_conv;
13307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13308         this_ptr_conv.is_owned = false;
13309         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
13310 }
13311
13312 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) {
13313         LDKOpenChannel this_ptr_conv;
13314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13315         this_ptr_conv.is_owned = false;
13316         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
13317         return ret_val;
13318 }
13319
13320 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) {
13321         LDKOpenChannel this_ptr_conv;
13322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13323         this_ptr_conv.is_owned = false;
13324         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13325 }
13326
13327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13328         LDKOpenChannel this_ptr_conv;
13329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13330         this_ptr_conv.is_owned = false;
13331         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
13332         return ret_val;
13333 }
13334
13335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13336         LDKOpenChannel this_ptr_conv;
13337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13338         this_ptr_conv.is_owned = false;
13339         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
13340 }
13341
13342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13343         LDKOpenChannel this_ptr_conv;
13344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13345         this_ptr_conv.is_owned = false;
13346         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
13347         return ret_val;
13348 }
13349
13350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13351         LDKOpenChannel this_ptr_conv;
13352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13353         this_ptr_conv.is_owned = false;
13354         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
13355 }
13356
13357 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
13358         LDKOpenChannel this_ptr_conv;
13359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13360         this_ptr_conv.is_owned = false;
13361         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
13362         return ret_val;
13363 }
13364
13365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13366         LDKOpenChannel this_ptr_conv;
13367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13368         this_ptr_conv.is_owned = false;
13369         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
13370 }
13371
13372 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13373         LDKOpenChannel this_ptr_conv;
13374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13375         this_ptr_conv.is_owned = false;
13376         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
13377         return ret_val;
13378 }
13379
13380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13381         LDKOpenChannel this_ptr_conv;
13382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13383         this_ptr_conv.is_owned = false;
13384         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
13385 }
13386
13387 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13388         LDKOpenChannel this_ptr_conv;
13389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13390         this_ptr_conv.is_owned = false;
13391         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
13392         return ret_val;
13393 }
13394
13395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13396         LDKOpenChannel this_ptr_conv;
13397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13398         this_ptr_conv.is_owned = false;
13399         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
13400 }
13401
13402 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13403         LDKOpenChannel this_ptr_conv;
13404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13405         this_ptr_conv.is_owned = false;
13406         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13407         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
13408         return ret_arr;
13409 }
13410
13411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13412         LDKOpenChannel this_ptr_conv;
13413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13414         this_ptr_conv.is_owned = false;
13415         LDKPublicKey val_ref;
13416         CHECK((*env)->GetArrayLength(env, val) == 33);
13417         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13418         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
13419 }
13420
13421 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13422         LDKOpenChannel this_ptr_conv;
13423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13424         this_ptr_conv.is_owned = false;
13425         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13426         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
13427         return ret_arr;
13428 }
13429
13430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13431         LDKOpenChannel this_ptr_conv;
13432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13433         this_ptr_conv.is_owned = false;
13434         LDKPublicKey val_ref;
13435         CHECK((*env)->GetArrayLength(env, val) == 33);
13436         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13437         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
13438 }
13439
13440 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13441         LDKOpenChannel this_ptr_conv;
13442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13443         this_ptr_conv.is_owned = false;
13444         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13445         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
13446         return ret_arr;
13447 }
13448
13449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13450         LDKOpenChannel this_ptr_conv;
13451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13452         this_ptr_conv.is_owned = false;
13453         LDKPublicKey val_ref;
13454         CHECK((*env)->GetArrayLength(env, val) == 33);
13455         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13456         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
13457 }
13458
13459 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13460         LDKOpenChannel this_ptr_conv;
13461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13462         this_ptr_conv.is_owned = false;
13463         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13464         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
13465         return ret_arr;
13466 }
13467
13468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13469         LDKOpenChannel this_ptr_conv;
13470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13471         this_ptr_conv.is_owned = false;
13472         LDKPublicKey val_ref;
13473         CHECK((*env)->GetArrayLength(env, val) == 33);
13474         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13475         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
13476 }
13477
13478 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13479         LDKOpenChannel this_ptr_conv;
13480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13481         this_ptr_conv.is_owned = false;
13482         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13483         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
13484         return ret_arr;
13485 }
13486
13487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13488         LDKOpenChannel this_ptr_conv;
13489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13490         this_ptr_conv.is_owned = false;
13491         LDKPublicKey val_ref;
13492         CHECK((*env)->GetArrayLength(env, val) == 33);
13493         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13494         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
13495 }
13496
13497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13498         LDKOpenChannel this_ptr_conv;
13499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13500         this_ptr_conv.is_owned = false;
13501         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13502         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
13503         return ret_arr;
13504 }
13505
13506 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) {
13507         LDKOpenChannel this_ptr_conv;
13508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13509         this_ptr_conv.is_owned = false;
13510         LDKPublicKey val_ref;
13511         CHECK((*env)->GetArrayLength(env, val) == 33);
13512         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13513         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
13514 }
13515
13516 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
13517         LDKOpenChannel this_ptr_conv;
13518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13519         this_ptr_conv.is_owned = false;
13520         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
13521         return ret_val;
13522 }
13523
13524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
13525         LDKOpenChannel this_ptr_conv;
13526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13527         this_ptr_conv.is_owned = false;
13528         OpenChannel_set_channel_flags(&this_ptr_conv, val);
13529 }
13530
13531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13532         LDKOpenChannel orig_conv;
13533         orig_conv.inner = (void*)(orig & (~1));
13534         orig_conv.is_owned = false;
13535         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
13536         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13537         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13538         long ret_ref = (long)ret_var.inner;
13539         if (ret_var.is_owned) {
13540                 ret_ref |= 1;
13541         }
13542         return ret_ref;
13543 }
13544
13545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13546         LDKAcceptChannel this_obj_conv;
13547         this_obj_conv.inner = (void*)(this_obj & (~1));
13548         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13549         AcceptChannel_free(this_obj_conv);
13550 }
13551
13552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13553         LDKAcceptChannel this_ptr_conv;
13554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13555         this_ptr_conv.is_owned = false;
13556         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13557         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
13558         return ret_arr;
13559 }
13560
13561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13562         LDKAcceptChannel this_ptr_conv;
13563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13564         this_ptr_conv.is_owned = false;
13565         LDKThirtyTwoBytes val_ref;
13566         CHECK((*env)->GetArrayLength(env, val) == 32);
13567         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13568         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
13569 }
13570
13571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13572         LDKAcceptChannel this_ptr_conv;
13573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13574         this_ptr_conv.is_owned = false;
13575         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
13576         return ret_val;
13577 }
13578
13579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13580         LDKAcceptChannel this_ptr_conv;
13581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13582         this_ptr_conv.is_owned = false;
13583         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
13584 }
13585
13586 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) {
13587         LDKAcceptChannel this_ptr_conv;
13588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13589         this_ptr_conv.is_owned = false;
13590         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
13591         return ret_val;
13592 }
13593
13594 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) {
13595         LDKAcceptChannel this_ptr_conv;
13596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13597         this_ptr_conv.is_owned = false;
13598         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13599 }
13600
13601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13602         LDKAcceptChannel this_ptr_conv;
13603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13604         this_ptr_conv.is_owned = false;
13605         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
13606         return ret_val;
13607 }
13608
13609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13610         LDKAcceptChannel this_ptr_conv;
13611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13612         this_ptr_conv.is_owned = false;
13613         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
13614 }
13615
13616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13617         LDKAcceptChannel this_ptr_conv;
13618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13619         this_ptr_conv.is_owned = false;
13620         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
13621         return ret_val;
13622 }
13623
13624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13625         LDKAcceptChannel this_ptr_conv;
13626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13627         this_ptr_conv.is_owned = false;
13628         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
13629 }
13630
13631 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13632         LDKAcceptChannel this_ptr_conv;
13633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13634         this_ptr_conv.is_owned = false;
13635         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
13636         return ret_val;
13637 }
13638
13639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13640         LDKAcceptChannel this_ptr_conv;
13641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13642         this_ptr_conv.is_owned = false;
13643         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
13644 }
13645
13646 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13647         LDKAcceptChannel this_ptr_conv;
13648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13649         this_ptr_conv.is_owned = false;
13650         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
13651         return ret_val;
13652 }
13653
13654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13655         LDKAcceptChannel this_ptr_conv;
13656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13657         this_ptr_conv.is_owned = false;
13658         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
13659 }
13660
13661 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13662         LDKAcceptChannel this_ptr_conv;
13663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13664         this_ptr_conv.is_owned = false;
13665         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
13666         return ret_val;
13667 }
13668
13669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13670         LDKAcceptChannel this_ptr_conv;
13671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13672         this_ptr_conv.is_owned = false;
13673         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
13674 }
13675
13676 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13677         LDKAcceptChannel this_ptr_conv;
13678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13679         this_ptr_conv.is_owned = false;
13680         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13681         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
13682         return ret_arr;
13683 }
13684
13685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13686         LDKAcceptChannel this_ptr_conv;
13687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13688         this_ptr_conv.is_owned = false;
13689         LDKPublicKey val_ref;
13690         CHECK((*env)->GetArrayLength(env, val) == 33);
13691         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13692         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
13693 }
13694
13695 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13696         LDKAcceptChannel this_ptr_conv;
13697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13698         this_ptr_conv.is_owned = false;
13699         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13700         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
13701         return ret_arr;
13702 }
13703
13704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13705         LDKAcceptChannel this_ptr_conv;
13706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13707         this_ptr_conv.is_owned = false;
13708         LDKPublicKey val_ref;
13709         CHECK((*env)->GetArrayLength(env, val) == 33);
13710         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13711         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
13712 }
13713
13714 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13715         LDKAcceptChannel this_ptr_conv;
13716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13717         this_ptr_conv.is_owned = false;
13718         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13719         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
13720         return ret_arr;
13721 }
13722
13723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13724         LDKAcceptChannel this_ptr_conv;
13725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13726         this_ptr_conv.is_owned = false;
13727         LDKPublicKey val_ref;
13728         CHECK((*env)->GetArrayLength(env, val) == 33);
13729         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13730         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
13731 }
13732
13733 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13734         LDKAcceptChannel this_ptr_conv;
13735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13736         this_ptr_conv.is_owned = false;
13737         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13738         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
13739         return ret_arr;
13740 }
13741
13742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13743         LDKAcceptChannel this_ptr_conv;
13744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13745         this_ptr_conv.is_owned = false;
13746         LDKPublicKey val_ref;
13747         CHECK((*env)->GetArrayLength(env, val) == 33);
13748         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13749         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
13750 }
13751
13752 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13753         LDKAcceptChannel this_ptr_conv;
13754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13755         this_ptr_conv.is_owned = false;
13756         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13757         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
13758         return ret_arr;
13759 }
13760
13761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13762         LDKAcceptChannel this_ptr_conv;
13763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13764         this_ptr_conv.is_owned = false;
13765         LDKPublicKey val_ref;
13766         CHECK((*env)->GetArrayLength(env, val) == 33);
13767         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13768         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
13769 }
13770
13771 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13772         LDKAcceptChannel this_ptr_conv;
13773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13774         this_ptr_conv.is_owned = false;
13775         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13776         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
13777         return ret_arr;
13778 }
13779
13780 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) {
13781         LDKAcceptChannel this_ptr_conv;
13782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13783         this_ptr_conv.is_owned = false;
13784         LDKPublicKey val_ref;
13785         CHECK((*env)->GetArrayLength(env, val) == 33);
13786         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13787         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
13788 }
13789
13790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13791         LDKAcceptChannel orig_conv;
13792         orig_conv.inner = (void*)(orig & (~1));
13793         orig_conv.is_owned = false;
13794         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
13795         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13796         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13797         long ret_ref = (long)ret_var.inner;
13798         if (ret_var.is_owned) {
13799                 ret_ref |= 1;
13800         }
13801         return ret_ref;
13802 }
13803
13804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13805         LDKFundingCreated this_obj_conv;
13806         this_obj_conv.inner = (void*)(this_obj & (~1));
13807         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13808         FundingCreated_free(this_obj_conv);
13809 }
13810
13811 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13812         LDKFundingCreated this_ptr_conv;
13813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13814         this_ptr_conv.is_owned = false;
13815         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13816         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
13817         return ret_arr;
13818 }
13819
13820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13821         LDKFundingCreated this_ptr_conv;
13822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13823         this_ptr_conv.is_owned = false;
13824         LDKThirtyTwoBytes val_ref;
13825         CHECK((*env)->GetArrayLength(env, val) == 32);
13826         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13827         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
13828 }
13829
13830 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
13831         LDKFundingCreated this_ptr_conv;
13832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13833         this_ptr_conv.is_owned = false;
13834         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13835         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
13836         return ret_arr;
13837 }
13838
13839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13840         LDKFundingCreated this_ptr_conv;
13841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13842         this_ptr_conv.is_owned = false;
13843         LDKThirtyTwoBytes val_ref;
13844         CHECK((*env)->GetArrayLength(env, val) == 32);
13845         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13846         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
13847 }
13848
13849 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
13850         LDKFundingCreated this_ptr_conv;
13851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13852         this_ptr_conv.is_owned = false;
13853         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
13854         return ret_val;
13855 }
13856
13857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13858         LDKFundingCreated this_ptr_conv;
13859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13860         this_ptr_conv.is_owned = false;
13861         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
13862 }
13863
13864 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
13865         LDKFundingCreated this_ptr_conv;
13866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13867         this_ptr_conv.is_owned = false;
13868         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
13869         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
13870         return ret_arr;
13871 }
13872
13873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13874         LDKFundingCreated this_ptr_conv;
13875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13876         this_ptr_conv.is_owned = false;
13877         LDKSignature val_ref;
13878         CHECK((*env)->GetArrayLength(env, val) == 64);
13879         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
13880         FundingCreated_set_signature(&this_ptr_conv, val_ref);
13881 }
13882
13883 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) {
13884         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
13885         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
13886         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
13887         LDKThirtyTwoBytes funding_txid_arg_ref;
13888         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
13889         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
13890         LDKSignature signature_arg_ref;
13891         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
13892         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
13893         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
13894         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13895         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13896         long ret_ref = (long)ret_var.inner;
13897         if (ret_var.is_owned) {
13898                 ret_ref |= 1;
13899         }
13900         return ret_ref;
13901 }
13902
13903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13904         LDKFundingCreated orig_conv;
13905         orig_conv.inner = (void*)(orig & (~1));
13906         orig_conv.is_owned = false;
13907         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
13908         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13909         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13910         long ret_ref = (long)ret_var.inner;
13911         if (ret_var.is_owned) {
13912                 ret_ref |= 1;
13913         }
13914         return ret_ref;
13915 }
13916
13917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13918         LDKFundingSigned this_obj_conv;
13919         this_obj_conv.inner = (void*)(this_obj & (~1));
13920         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13921         FundingSigned_free(this_obj_conv);
13922 }
13923
13924 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13925         LDKFundingSigned this_ptr_conv;
13926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13927         this_ptr_conv.is_owned = false;
13928         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13929         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
13930         return ret_arr;
13931 }
13932
13933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13934         LDKFundingSigned this_ptr_conv;
13935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13936         this_ptr_conv.is_owned = false;
13937         LDKThirtyTwoBytes val_ref;
13938         CHECK((*env)->GetArrayLength(env, val) == 32);
13939         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13940         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
13941 }
13942
13943 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
13944         LDKFundingSigned this_ptr_conv;
13945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13946         this_ptr_conv.is_owned = false;
13947         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
13948         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
13949         return ret_arr;
13950 }
13951
13952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13953         LDKFundingSigned this_ptr_conv;
13954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13955         this_ptr_conv.is_owned = false;
13956         LDKSignature val_ref;
13957         CHECK((*env)->GetArrayLength(env, val) == 64);
13958         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
13959         FundingSigned_set_signature(&this_ptr_conv, val_ref);
13960 }
13961
13962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
13963         LDKThirtyTwoBytes channel_id_arg_ref;
13964         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13965         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13966         LDKSignature signature_arg_ref;
13967         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
13968         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
13969         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
13970         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13971         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13972         long ret_ref = (long)ret_var.inner;
13973         if (ret_var.is_owned) {
13974                 ret_ref |= 1;
13975         }
13976         return ret_ref;
13977 }
13978
13979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13980         LDKFundingSigned orig_conv;
13981         orig_conv.inner = (void*)(orig & (~1));
13982         orig_conv.is_owned = false;
13983         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
13984         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13985         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13986         long ret_ref = (long)ret_var.inner;
13987         if (ret_var.is_owned) {
13988                 ret_ref |= 1;
13989         }
13990         return ret_ref;
13991 }
13992
13993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13994         LDKFundingLocked this_obj_conv;
13995         this_obj_conv.inner = (void*)(this_obj & (~1));
13996         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13997         FundingLocked_free(this_obj_conv);
13998 }
13999
14000 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14001         LDKFundingLocked this_ptr_conv;
14002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14003         this_ptr_conv.is_owned = false;
14004         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14005         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
14006         return ret_arr;
14007 }
14008
14009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14010         LDKFundingLocked this_ptr_conv;
14011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14012         this_ptr_conv.is_owned = false;
14013         LDKThirtyTwoBytes val_ref;
14014         CHECK((*env)->GetArrayLength(env, val) == 32);
14015         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14016         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
14017 }
14018
14019 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14020         LDKFundingLocked this_ptr_conv;
14021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14022         this_ptr_conv.is_owned = false;
14023         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14024         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
14025         return ret_arr;
14026 }
14027
14028 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) {
14029         LDKFundingLocked this_ptr_conv;
14030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14031         this_ptr_conv.is_owned = false;
14032         LDKPublicKey val_ref;
14033         CHECK((*env)->GetArrayLength(env, val) == 33);
14034         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14035         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
14036 }
14037
14038 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) {
14039         LDKThirtyTwoBytes channel_id_arg_ref;
14040         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14041         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14042         LDKPublicKey next_per_commitment_point_arg_ref;
14043         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
14044         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
14045         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
14046         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14047         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14048         long ret_ref = (long)ret_var.inner;
14049         if (ret_var.is_owned) {
14050                 ret_ref |= 1;
14051         }
14052         return ret_ref;
14053 }
14054
14055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14056         LDKFundingLocked orig_conv;
14057         orig_conv.inner = (void*)(orig & (~1));
14058         orig_conv.is_owned = false;
14059         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
14060         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14061         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14062         long ret_ref = (long)ret_var.inner;
14063         if (ret_var.is_owned) {
14064                 ret_ref |= 1;
14065         }
14066         return ret_ref;
14067 }
14068
14069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14070         LDKShutdown this_obj_conv;
14071         this_obj_conv.inner = (void*)(this_obj & (~1));
14072         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14073         Shutdown_free(this_obj_conv);
14074 }
14075
14076 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14077         LDKShutdown this_ptr_conv;
14078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14079         this_ptr_conv.is_owned = false;
14080         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14081         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
14082         return ret_arr;
14083 }
14084
14085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14086         LDKShutdown this_ptr_conv;
14087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14088         this_ptr_conv.is_owned = false;
14089         LDKThirtyTwoBytes val_ref;
14090         CHECK((*env)->GetArrayLength(env, val) == 32);
14091         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14092         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
14093 }
14094
14095 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14096         LDKShutdown this_ptr_conv;
14097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14098         this_ptr_conv.is_owned = false;
14099         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
14100         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14101         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14102         return ret_arr;
14103 }
14104
14105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14106         LDKShutdown this_ptr_conv;
14107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14108         this_ptr_conv.is_owned = false;
14109         LDKCVec_u8Z val_ref;
14110         val_ref.datalen = (*env)->GetArrayLength(env, val);
14111         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14112         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
14113         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
14114 }
14115
14116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
14117         LDKThirtyTwoBytes channel_id_arg_ref;
14118         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14119         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14120         LDKCVec_u8Z scriptpubkey_arg_ref;
14121         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
14122         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14123         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
14124         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
14125         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14126         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14127         long ret_ref = (long)ret_var.inner;
14128         if (ret_var.is_owned) {
14129                 ret_ref |= 1;
14130         }
14131         return ret_ref;
14132 }
14133
14134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14135         LDKShutdown orig_conv;
14136         orig_conv.inner = (void*)(orig & (~1));
14137         orig_conv.is_owned = false;
14138         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
14139         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14140         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14141         long ret_ref = (long)ret_var.inner;
14142         if (ret_var.is_owned) {
14143                 ret_ref |= 1;
14144         }
14145         return ret_ref;
14146 }
14147
14148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14149         LDKClosingSigned this_obj_conv;
14150         this_obj_conv.inner = (void*)(this_obj & (~1));
14151         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14152         ClosingSigned_free(this_obj_conv);
14153 }
14154
14155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14156         LDKClosingSigned this_ptr_conv;
14157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14158         this_ptr_conv.is_owned = false;
14159         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14160         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
14161         return ret_arr;
14162 }
14163
14164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14165         LDKClosingSigned this_ptr_conv;
14166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14167         this_ptr_conv.is_owned = false;
14168         LDKThirtyTwoBytes val_ref;
14169         CHECK((*env)->GetArrayLength(env, val) == 32);
14170         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14171         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
14172 }
14173
14174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14175         LDKClosingSigned this_ptr_conv;
14176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14177         this_ptr_conv.is_owned = false;
14178         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
14179         return ret_val;
14180 }
14181
14182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14183         LDKClosingSigned this_ptr_conv;
14184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14185         this_ptr_conv.is_owned = false;
14186         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
14187 }
14188
14189 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14190         LDKClosingSigned this_ptr_conv;
14191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14192         this_ptr_conv.is_owned = false;
14193         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14194         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
14195         return ret_arr;
14196 }
14197
14198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14199         LDKClosingSigned this_ptr_conv;
14200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14201         this_ptr_conv.is_owned = false;
14202         LDKSignature val_ref;
14203         CHECK((*env)->GetArrayLength(env, val) == 64);
14204         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14205         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
14206 }
14207
14208 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) {
14209         LDKThirtyTwoBytes channel_id_arg_ref;
14210         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14211         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14212         LDKSignature signature_arg_ref;
14213         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
14214         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
14215         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
14216         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14217         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14218         long ret_ref = (long)ret_var.inner;
14219         if (ret_var.is_owned) {
14220                 ret_ref |= 1;
14221         }
14222         return ret_ref;
14223 }
14224
14225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14226         LDKClosingSigned orig_conv;
14227         orig_conv.inner = (void*)(orig & (~1));
14228         orig_conv.is_owned = false;
14229         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
14230         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14231         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14232         long ret_ref = (long)ret_var.inner;
14233         if (ret_var.is_owned) {
14234                 ret_ref |= 1;
14235         }
14236         return ret_ref;
14237 }
14238
14239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14240         LDKUpdateAddHTLC this_obj_conv;
14241         this_obj_conv.inner = (void*)(this_obj & (~1));
14242         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14243         UpdateAddHTLC_free(this_obj_conv);
14244 }
14245
14246 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14247         LDKUpdateAddHTLC this_ptr_conv;
14248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14249         this_ptr_conv.is_owned = false;
14250         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14251         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
14252         return ret_arr;
14253 }
14254
14255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14256         LDKUpdateAddHTLC this_ptr_conv;
14257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14258         this_ptr_conv.is_owned = false;
14259         LDKThirtyTwoBytes val_ref;
14260         CHECK((*env)->GetArrayLength(env, val) == 32);
14261         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14262         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
14263 }
14264
14265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14266         LDKUpdateAddHTLC this_ptr_conv;
14267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14268         this_ptr_conv.is_owned = false;
14269         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
14270         return ret_val;
14271 }
14272
14273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14274         LDKUpdateAddHTLC this_ptr_conv;
14275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14276         this_ptr_conv.is_owned = false;
14277         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
14278 }
14279
14280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14281         LDKUpdateAddHTLC this_ptr_conv;
14282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14283         this_ptr_conv.is_owned = false;
14284         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
14285         return ret_val;
14286 }
14287
14288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14289         LDKUpdateAddHTLC this_ptr_conv;
14290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14291         this_ptr_conv.is_owned = false;
14292         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
14293 }
14294
14295 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14296         LDKUpdateAddHTLC this_ptr_conv;
14297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14298         this_ptr_conv.is_owned = false;
14299         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14300         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
14301         return ret_arr;
14302 }
14303
14304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14305         LDKUpdateAddHTLC this_ptr_conv;
14306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14307         this_ptr_conv.is_owned = false;
14308         LDKThirtyTwoBytes val_ref;
14309         CHECK((*env)->GetArrayLength(env, val) == 32);
14310         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14311         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
14312 }
14313
14314 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
14315         LDKUpdateAddHTLC this_ptr_conv;
14316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14317         this_ptr_conv.is_owned = false;
14318         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
14319         return ret_val;
14320 }
14321
14322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14323         LDKUpdateAddHTLC this_ptr_conv;
14324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14325         this_ptr_conv.is_owned = false;
14326         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
14327 }
14328
14329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14330         LDKUpdateAddHTLC orig_conv;
14331         orig_conv.inner = (void*)(orig & (~1));
14332         orig_conv.is_owned = false;
14333         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
14334         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14335         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14336         long ret_ref = (long)ret_var.inner;
14337         if (ret_var.is_owned) {
14338                 ret_ref |= 1;
14339         }
14340         return ret_ref;
14341 }
14342
14343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14344         LDKUpdateFulfillHTLC this_obj_conv;
14345         this_obj_conv.inner = (void*)(this_obj & (~1));
14346         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14347         UpdateFulfillHTLC_free(this_obj_conv);
14348 }
14349
14350 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14351         LDKUpdateFulfillHTLC this_ptr_conv;
14352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14353         this_ptr_conv.is_owned = false;
14354         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14355         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
14356         return ret_arr;
14357 }
14358
14359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14360         LDKUpdateFulfillHTLC this_ptr_conv;
14361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14362         this_ptr_conv.is_owned = false;
14363         LDKThirtyTwoBytes val_ref;
14364         CHECK((*env)->GetArrayLength(env, val) == 32);
14365         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14366         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
14367 }
14368
14369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14370         LDKUpdateFulfillHTLC this_ptr_conv;
14371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14372         this_ptr_conv.is_owned = false;
14373         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
14374         return ret_val;
14375 }
14376
14377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14378         LDKUpdateFulfillHTLC this_ptr_conv;
14379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14380         this_ptr_conv.is_owned = false;
14381         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
14382 }
14383
14384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
14385         LDKUpdateFulfillHTLC this_ptr_conv;
14386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14387         this_ptr_conv.is_owned = false;
14388         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14389         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
14390         return ret_arr;
14391 }
14392
14393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14394         LDKUpdateFulfillHTLC this_ptr_conv;
14395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14396         this_ptr_conv.is_owned = false;
14397         LDKThirtyTwoBytes val_ref;
14398         CHECK((*env)->GetArrayLength(env, val) == 32);
14399         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14400         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
14401 }
14402
14403 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) {
14404         LDKThirtyTwoBytes channel_id_arg_ref;
14405         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14406         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14407         LDKThirtyTwoBytes payment_preimage_arg_ref;
14408         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
14409         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
14410         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
14411         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14412         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14413         long ret_ref = (long)ret_var.inner;
14414         if (ret_var.is_owned) {
14415                 ret_ref |= 1;
14416         }
14417         return ret_ref;
14418 }
14419
14420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14421         LDKUpdateFulfillHTLC orig_conv;
14422         orig_conv.inner = (void*)(orig & (~1));
14423         orig_conv.is_owned = false;
14424         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
14425         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14426         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14427         long ret_ref = (long)ret_var.inner;
14428         if (ret_var.is_owned) {
14429                 ret_ref |= 1;
14430         }
14431         return ret_ref;
14432 }
14433
14434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14435         LDKUpdateFailHTLC this_obj_conv;
14436         this_obj_conv.inner = (void*)(this_obj & (~1));
14437         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14438         UpdateFailHTLC_free(this_obj_conv);
14439 }
14440
14441 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14442         LDKUpdateFailHTLC this_ptr_conv;
14443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14444         this_ptr_conv.is_owned = false;
14445         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14446         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
14447         return ret_arr;
14448 }
14449
14450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14451         LDKUpdateFailHTLC this_ptr_conv;
14452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14453         this_ptr_conv.is_owned = false;
14454         LDKThirtyTwoBytes val_ref;
14455         CHECK((*env)->GetArrayLength(env, val) == 32);
14456         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14457         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
14458 }
14459
14460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14461         LDKUpdateFailHTLC this_ptr_conv;
14462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14463         this_ptr_conv.is_owned = false;
14464         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
14465         return ret_val;
14466 }
14467
14468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14469         LDKUpdateFailHTLC this_ptr_conv;
14470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14471         this_ptr_conv.is_owned = false;
14472         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
14473 }
14474
14475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14476         LDKUpdateFailHTLC orig_conv;
14477         orig_conv.inner = (void*)(orig & (~1));
14478         orig_conv.is_owned = false;
14479         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
14480         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14481         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14482         long ret_ref = (long)ret_var.inner;
14483         if (ret_var.is_owned) {
14484                 ret_ref |= 1;
14485         }
14486         return ret_ref;
14487 }
14488
14489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14490         LDKUpdateFailMalformedHTLC this_obj_conv;
14491         this_obj_conv.inner = (void*)(this_obj & (~1));
14492         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14493         UpdateFailMalformedHTLC_free(this_obj_conv);
14494 }
14495
14496 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14497         LDKUpdateFailMalformedHTLC this_ptr_conv;
14498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14499         this_ptr_conv.is_owned = false;
14500         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14501         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
14502         return ret_arr;
14503 }
14504
14505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14506         LDKUpdateFailMalformedHTLC this_ptr_conv;
14507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14508         this_ptr_conv.is_owned = false;
14509         LDKThirtyTwoBytes val_ref;
14510         CHECK((*env)->GetArrayLength(env, val) == 32);
14511         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14512         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
14513 }
14514
14515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14516         LDKUpdateFailMalformedHTLC this_ptr_conv;
14517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14518         this_ptr_conv.is_owned = false;
14519         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
14520         return ret_val;
14521 }
14522
14523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14524         LDKUpdateFailMalformedHTLC this_ptr_conv;
14525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14526         this_ptr_conv.is_owned = false;
14527         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
14528 }
14529
14530 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
14531         LDKUpdateFailMalformedHTLC this_ptr_conv;
14532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14533         this_ptr_conv.is_owned = false;
14534         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
14535         return ret_val;
14536 }
14537
14538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14539         LDKUpdateFailMalformedHTLC this_ptr_conv;
14540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14541         this_ptr_conv.is_owned = false;
14542         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
14543 }
14544
14545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14546         LDKUpdateFailMalformedHTLC orig_conv;
14547         orig_conv.inner = (void*)(orig & (~1));
14548         orig_conv.is_owned = false;
14549         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
14550         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14551         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14552         long ret_ref = (long)ret_var.inner;
14553         if (ret_var.is_owned) {
14554                 ret_ref |= 1;
14555         }
14556         return ret_ref;
14557 }
14558
14559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14560         LDKCommitmentSigned this_obj_conv;
14561         this_obj_conv.inner = (void*)(this_obj & (~1));
14562         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14563         CommitmentSigned_free(this_obj_conv);
14564 }
14565
14566 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14567         LDKCommitmentSigned this_ptr_conv;
14568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14569         this_ptr_conv.is_owned = false;
14570         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14571         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
14572         return ret_arr;
14573 }
14574
14575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14576         LDKCommitmentSigned this_ptr_conv;
14577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14578         this_ptr_conv.is_owned = false;
14579         LDKThirtyTwoBytes val_ref;
14580         CHECK((*env)->GetArrayLength(env, val) == 32);
14581         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14582         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
14583 }
14584
14585 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14586         LDKCommitmentSigned this_ptr_conv;
14587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14588         this_ptr_conv.is_owned = false;
14589         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14590         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
14591         return ret_arr;
14592 }
14593
14594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14595         LDKCommitmentSigned this_ptr_conv;
14596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14597         this_ptr_conv.is_owned = false;
14598         LDKSignature val_ref;
14599         CHECK((*env)->GetArrayLength(env, val) == 64);
14600         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14601         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
14602 }
14603
14604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
14605         LDKCommitmentSigned this_ptr_conv;
14606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14607         this_ptr_conv.is_owned = false;
14608         LDKCVec_SignatureZ val_constr;
14609         val_constr.datalen = (*env)->GetArrayLength(env, val);
14610         if (val_constr.datalen > 0)
14611                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14612         else
14613                 val_constr.data = NULL;
14614         for (size_t i = 0; i < val_constr.datalen; i++) {
14615                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
14616                 LDKSignature val_conv_8_ref;
14617                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
14618                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
14619                 val_constr.data[i] = val_conv_8_ref;
14620         }
14621         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
14622 }
14623
14624 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) {
14625         LDKThirtyTwoBytes channel_id_arg_ref;
14626         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14627         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14628         LDKSignature signature_arg_ref;
14629         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
14630         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
14631         LDKCVec_SignatureZ htlc_signatures_arg_constr;
14632         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
14633         if (htlc_signatures_arg_constr.datalen > 0)
14634                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14635         else
14636                 htlc_signatures_arg_constr.data = NULL;
14637         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
14638                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
14639                 LDKSignature htlc_signatures_arg_conv_8_ref;
14640                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
14641                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
14642                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
14643         }
14644         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
14645         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14646         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14647         long ret_ref = (long)ret_var.inner;
14648         if (ret_var.is_owned) {
14649                 ret_ref |= 1;
14650         }
14651         return ret_ref;
14652 }
14653
14654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14655         LDKCommitmentSigned orig_conv;
14656         orig_conv.inner = (void*)(orig & (~1));
14657         orig_conv.is_owned = false;
14658         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
14659         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14660         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14661         long ret_ref = (long)ret_var.inner;
14662         if (ret_var.is_owned) {
14663                 ret_ref |= 1;
14664         }
14665         return ret_ref;
14666 }
14667
14668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14669         LDKRevokeAndACK this_obj_conv;
14670         this_obj_conv.inner = (void*)(this_obj & (~1));
14671         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14672         RevokeAndACK_free(this_obj_conv);
14673 }
14674
14675 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14676         LDKRevokeAndACK this_ptr_conv;
14677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14678         this_ptr_conv.is_owned = false;
14679         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14680         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
14681         return ret_arr;
14682 }
14683
14684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14685         LDKRevokeAndACK this_ptr_conv;
14686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14687         this_ptr_conv.is_owned = false;
14688         LDKThirtyTwoBytes val_ref;
14689         CHECK((*env)->GetArrayLength(env, val) == 32);
14690         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14691         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
14692 }
14693
14694 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
14695         LDKRevokeAndACK this_ptr_conv;
14696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14697         this_ptr_conv.is_owned = false;
14698         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14699         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
14700         return ret_arr;
14701 }
14702
14703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14704         LDKRevokeAndACK this_ptr_conv;
14705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14706         this_ptr_conv.is_owned = false;
14707         LDKThirtyTwoBytes val_ref;
14708         CHECK((*env)->GetArrayLength(env, val) == 32);
14709         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14710         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
14711 }
14712
14713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14714         LDKRevokeAndACK this_ptr_conv;
14715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14716         this_ptr_conv.is_owned = false;
14717         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14718         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
14719         return ret_arr;
14720 }
14721
14722 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) {
14723         LDKRevokeAndACK this_ptr_conv;
14724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14725         this_ptr_conv.is_owned = false;
14726         LDKPublicKey val_ref;
14727         CHECK((*env)->GetArrayLength(env, val) == 33);
14728         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14729         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
14730 }
14731
14732 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) {
14733         LDKThirtyTwoBytes channel_id_arg_ref;
14734         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14735         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14736         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
14737         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
14738         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
14739         LDKPublicKey next_per_commitment_point_arg_ref;
14740         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
14741         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
14742         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
14743         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14744         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14745         long ret_ref = (long)ret_var.inner;
14746         if (ret_var.is_owned) {
14747                 ret_ref |= 1;
14748         }
14749         return ret_ref;
14750 }
14751
14752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14753         LDKRevokeAndACK orig_conv;
14754         orig_conv.inner = (void*)(orig & (~1));
14755         orig_conv.is_owned = false;
14756         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
14757         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14758         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14759         long ret_ref = (long)ret_var.inner;
14760         if (ret_var.is_owned) {
14761                 ret_ref |= 1;
14762         }
14763         return ret_ref;
14764 }
14765
14766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14767         LDKUpdateFee this_obj_conv;
14768         this_obj_conv.inner = (void*)(this_obj & (~1));
14769         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14770         UpdateFee_free(this_obj_conv);
14771 }
14772
14773 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14774         LDKUpdateFee this_ptr_conv;
14775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14776         this_ptr_conv.is_owned = false;
14777         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14778         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
14779         return ret_arr;
14780 }
14781
14782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14783         LDKUpdateFee this_ptr_conv;
14784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14785         this_ptr_conv.is_owned = false;
14786         LDKThirtyTwoBytes val_ref;
14787         CHECK((*env)->GetArrayLength(env, val) == 32);
14788         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14789         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
14790 }
14791
14792 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
14793         LDKUpdateFee this_ptr_conv;
14794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14795         this_ptr_conv.is_owned = false;
14796         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
14797         return ret_val;
14798 }
14799
14800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14801         LDKUpdateFee this_ptr_conv;
14802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14803         this_ptr_conv.is_owned = false;
14804         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
14805 }
14806
14807 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) {
14808         LDKThirtyTwoBytes channel_id_arg_ref;
14809         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14810         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14811         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
14812         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14813         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14814         long ret_ref = (long)ret_var.inner;
14815         if (ret_var.is_owned) {
14816                 ret_ref |= 1;
14817         }
14818         return ret_ref;
14819 }
14820
14821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14822         LDKUpdateFee orig_conv;
14823         orig_conv.inner = (void*)(orig & (~1));
14824         orig_conv.is_owned = false;
14825         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
14826         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14827         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14828         long ret_ref = (long)ret_var.inner;
14829         if (ret_var.is_owned) {
14830                 ret_ref |= 1;
14831         }
14832         return ret_ref;
14833 }
14834
14835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14836         LDKDataLossProtect this_obj_conv;
14837         this_obj_conv.inner = (void*)(this_obj & (~1));
14838         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14839         DataLossProtect_free(this_obj_conv);
14840 }
14841
14842 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
14843         LDKDataLossProtect this_ptr_conv;
14844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14845         this_ptr_conv.is_owned = false;
14846         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14847         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
14848         return ret_arr;
14849 }
14850
14851 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) {
14852         LDKDataLossProtect this_ptr_conv;
14853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14854         this_ptr_conv.is_owned = false;
14855         LDKThirtyTwoBytes val_ref;
14856         CHECK((*env)->GetArrayLength(env, val) == 32);
14857         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14858         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
14859 }
14860
14861 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14862         LDKDataLossProtect this_ptr_conv;
14863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14864         this_ptr_conv.is_owned = false;
14865         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14866         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
14867         return ret_arr;
14868 }
14869
14870 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) {
14871         LDKDataLossProtect this_ptr_conv;
14872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14873         this_ptr_conv.is_owned = false;
14874         LDKPublicKey val_ref;
14875         CHECK((*env)->GetArrayLength(env, val) == 33);
14876         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14877         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
14878 }
14879
14880 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) {
14881         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
14882         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
14883         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
14884         LDKPublicKey my_current_per_commitment_point_arg_ref;
14885         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
14886         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
14887         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
14888         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14889         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14890         long ret_ref = (long)ret_var.inner;
14891         if (ret_var.is_owned) {
14892                 ret_ref |= 1;
14893         }
14894         return ret_ref;
14895 }
14896
14897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14898         LDKDataLossProtect orig_conv;
14899         orig_conv.inner = (void*)(orig & (~1));
14900         orig_conv.is_owned = false;
14901         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
14902         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14903         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14904         long ret_ref = (long)ret_var.inner;
14905         if (ret_var.is_owned) {
14906                 ret_ref |= 1;
14907         }
14908         return ret_ref;
14909 }
14910
14911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14912         LDKChannelReestablish this_obj_conv;
14913         this_obj_conv.inner = (void*)(this_obj & (~1));
14914         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14915         ChannelReestablish_free(this_obj_conv);
14916 }
14917
14918 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14919         LDKChannelReestablish this_ptr_conv;
14920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14921         this_ptr_conv.is_owned = false;
14922         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14923         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
14924         return ret_arr;
14925 }
14926
14927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14928         LDKChannelReestablish this_ptr_conv;
14929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14930         this_ptr_conv.is_owned = false;
14931         LDKThirtyTwoBytes val_ref;
14932         CHECK((*env)->GetArrayLength(env, val) == 32);
14933         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14934         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
14935 }
14936
14937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
14938         LDKChannelReestablish this_ptr_conv;
14939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14940         this_ptr_conv.is_owned = false;
14941         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
14942         return ret_val;
14943 }
14944
14945 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) {
14946         LDKChannelReestablish this_ptr_conv;
14947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14948         this_ptr_conv.is_owned = false;
14949         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
14950 }
14951
14952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
14953         LDKChannelReestablish this_ptr_conv;
14954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14955         this_ptr_conv.is_owned = false;
14956         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
14957         return ret_val;
14958 }
14959
14960 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) {
14961         LDKChannelReestablish this_ptr_conv;
14962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14963         this_ptr_conv.is_owned = false;
14964         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
14965 }
14966
14967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14968         LDKChannelReestablish orig_conv;
14969         orig_conv.inner = (void*)(orig & (~1));
14970         orig_conv.is_owned = false;
14971         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
14972         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14973         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14974         long ret_ref = (long)ret_var.inner;
14975         if (ret_var.is_owned) {
14976                 ret_ref |= 1;
14977         }
14978         return ret_ref;
14979 }
14980
14981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14982         LDKAnnouncementSignatures this_obj_conv;
14983         this_obj_conv.inner = (void*)(this_obj & (~1));
14984         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14985         AnnouncementSignatures_free(this_obj_conv);
14986 }
14987
14988 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14989         LDKAnnouncementSignatures this_ptr_conv;
14990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14991         this_ptr_conv.is_owned = false;
14992         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14993         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
14994         return ret_arr;
14995 }
14996
14997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14998         LDKAnnouncementSignatures this_ptr_conv;
14999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15000         this_ptr_conv.is_owned = false;
15001         LDKThirtyTwoBytes val_ref;
15002         CHECK((*env)->GetArrayLength(env, val) == 32);
15003         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15004         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
15005 }
15006
15007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15008         LDKAnnouncementSignatures this_ptr_conv;
15009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15010         this_ptr_conv.is_owned = false;
15011         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
15012         return ret_val;
15013 }
15014
15015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15016         LDKAnnouncementSignatures this_ptr_conv;
15017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15018         this_ptr_conv.is_owned = false;
15019         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
15020 }
15021
15022 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15023         LDKAnnouncementSignatures this_ptr_conv;
15024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15025         this_ptr_conv.is_owned = false;
15026         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15027         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
15028         return ret_arr;
15029 }
15030
15031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15032         LDKAnnouncementSignatures this_ptr_conv;
15033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15034         this_ptr_conv.is_owned = false;
15035         LDKSignature val_ref;
15036         CHECK((*env)->GetArrayLength(env, val) == 64);
15037         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15038         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
15039 }
15040
15041 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15042         LDKAnnouncementSignatures this_ptr_conv;
15043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15044         this_ptr_conv.is_owned = false;
15045         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15046         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
15047         return ret_arr;
15048 }
15049
15050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15051         LDKAnnouncementSignatures this_ptr_conv;
15052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15053         this_ptr_conv.is_owned = false;
15054         LDKSignature val_ref;
15055         CHECK((*env)->GetArrayLength(env, val) == 64);
15056         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15057         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
15058 }
15059
15060 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) {
15061         LDKThirtyTwoBytes channel_id_arg_ref;
15062         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
15063         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
15064         LDKSignature node_signature_arg_ref;
15065         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
15066         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
15067         LDKSignature bitcoin_signature_arg_ref;
15068         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
15069         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
15070         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
15071         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15072         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15073         long ret_ref = (long)ret_var.inner;
15074         if (ret_var.is_owned) {
15075                 ret_ref |= 1;
15076         }
15077         return ret_ref;
15078 }
15079
15080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15081         LDKAnnouncementSignatures orig_conv;
15082         orig_conv.inner = (void*)(orig & (~1));
15083         orig_conv.is_owned = false;
15084         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
15085         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15086         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15087         long ret_ref = (long)ret_var.inner;
15088         if (ret_var.is_owned) {
15089                 ret_ref |= 1;
15090         }
15091         return ret_ref;
15092 }
15093
15094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15095         if ((this_ptr & 1) != 0) return;
15096         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
15097         FREE((void*)this_ptr);
15098         NetAddress_free(this_ptr_conv);
15099 }
15100
15101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15102         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
15103         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
15104         *ret_copy = NetAddress_clone(orig_conv);
15105         long ret_ref = (long)ret_copy;
15106         return ret_ref;
15107 }
15108
15109 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
15110         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
15111         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
15112         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15113         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15114         CVec_u8Z_free(ret_var);
15115         return ret_arr;
15116 }
15117
15118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15119         LDKu8slice ser_ref;
15120         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15121         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15122         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
15123         *ret_conv = Result_read(ser_ref);
15124         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15125         return (long)ret_conv;
15126 }
15127
15128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15129         LDKUnsignedNodeAnnouncement this_obj_conv;
15130         this_obj_conv.inner = (void*)(this_obj & (~1));
15131         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15132         UnsignedNodeAnnouncement_free(this_obj_conv);
15133 }
15134
15135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
15136         LDKUnsignedNodeAnnouncement this_ptr_conv;
15137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15138         this_ptr_conv.is_owned = false;
15139         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
15140         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15141         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15142         long ret_ref = (long)ret_var.inner;
15143         if (ret_var.is_owned) {
15144                 ret_ref |= 1;
15145         }
15146         return ret_ref;
15147 }
15148
15149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15150         LDKUnsignedNodeAnnouncement this_ptr_conv;
15151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15152         this_ptr_conv.is_owned = false;
15153         LDKNodeFeatures val_conv;
15154         val_conv.inner = (void*)(val & (~1));
15155         val_conv.is_owned = (val & 1) || (val == 0);
15156         val_conv = NodeFeatures_clone(&val_conv);
15157         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
15158 }
15159
15160 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
15161         LDKUnsignedNodeAnnouncement this_ptr_conv;
15162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15163         this_ptr_conv.is_owned = false;
15164         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
15165         return ret_val;
15166 }
15167
15168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15169         LDKUnsignedNodeAnnouncement this_ptr_conv;
15170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15171         this_ptr_conv.is_owned = false;
15172         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
15173 }
15174
15175 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15176         LDKUnsignedNodeAnnouncement this_ptr_conv;
15177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15178         this_ptr_conv.is_owned = false;
15179         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15180         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
15181         return ret_arr;
15182 }
15183
15184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15185         LDKUnsignedNodeAnnouncement this_ptr_conv;
15186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15187         this_ptr_conv.is_owned = false;
15188         LDKPublicKey val_ref;
15189         CHECK((*env)->GetArrayLength(env, val) == 33);
15190         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15191         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
15192 }
15193
15194 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
15195         LDKUnsignedNodeAnnouncement this_ptr_conv;
15196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15197         this_ptr_conv.is_owned = false;
15198         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
15199         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
15200         return ret_arr;
15201 }
15202
15203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15204         LDKUnsignedNodeAnnouncement this_ptr_conv;
15205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15206         this_ptr_conv.is_owned = false;
15207         LDKThreeBytes val_ref;
15208         CHECK((*env)->GetArrayLength(env, val) == 3);
15209         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
15210         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
15211 }
15212
15213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
15214         LDKUnsignedNodeAnnouncement this_ptr_conv;
15215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15216         this_ptr_conv.is_owned = false;
15217         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15218         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
15219         return ret_arr;
15220 }
15221
15222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15223         LDKUnsignedNodeAnnouncement this_ptr_conv;
15224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15225         this_ptr_conv.is_owned = false;
15226         LDKThirtyTwoBytes val_ref;
15227         CHECK((*env)->GetArrayLength(env, val) == 32);
15228         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15229         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
15230 }
15231
15232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
15233         LDKUnsignedNodeAnnouncement this_ptr_conv;
15234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15235         this_ptr_conv.is_owned = false;
15236         LDKCVec_NetAddressZ val_constr;
15237         val_constr.datalen = (*env)->GetArrayLength(env, val);
15238         if (val_constr.datalen > 0)
15239                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15240         else
15241                 val_constr.data = NULL;
15242         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
15243         for (size_t m = 0; m < val_constr.datalen; m++) {
15244                 int64_t val_conv_12 = val_vals[m];
15245                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
15246                 FREE((void*)val_conv_12);
15247                 val_constr.data[m] = val_conv_12_conv;
15248         }
15249         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
15250         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
15251 }
15252
15253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15254         LDKUnsignedNodeAnnouncement orig_conv;
15255         orig_conv.inner = (void*)(orig & (~1));
15256         orig_conv.is_owned = false;
15257         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
15258         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15259         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15260         long ret_ref = (long)ret_var.inner;
15261         if (ret_var.is_owned) {
15262                 ret_ref |= 1;
15263         }
15264         return ret_ref;
15265 }
15266
15267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15268         LDKNodeAnnouncement this_obj_conv;
15269         this_obj_conv.inner = (void*)(this_obj & (~1));
15270         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15271         NodeAnnouncement_free(this_obj_conv);
15272 }
15273
15274 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15275         LDKNodeAnnouncement this_ptr_conv;
15276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15277         this_ptr_conv.is_owned = false;
15278         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15279         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
15280         return ret_arr;
15281 }
15282
15283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15284         LDKNodeAnnouncement this_ptr_conv;
15285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15286         this_ptr_conv.is_owned = false;
15287         LDKSignature val_ref;
15288         CHECK((*env)->GetArrayLength(env, val) == 64);
15289         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15290         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
15291 }
15292
15293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
15294         LDKNodeAnnouncement this_ptr_conv;
15295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15296         this_ptr_conv.is_owned = false;
15297         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
15298         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15299         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15300         long ret_ref = (long)ret_var.inner;
15301         if (ret_var.is_owned) {
15302                 ret_ref |= 1;
15303         }
15304         return ret_ref;
15305 }
15306
15307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15308         LDKNodeAnnouncement this_ptr_conv;
15309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15310         this_ptr_conv.is_owned = false;
15311         LDKUnsignedNodeAnnouncement val_conv;
15312         val_conv.inner = (void*)(val & (~1));
15313         val_conv.is_owned = (val & 1) || (val == 0);
15314         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
15315         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
15316 }
15317
15318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
15319         LDKSignature signature_arg_ref;
15320         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
15321         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
15322         LDKUnsignedNodeAnnouncement contents_arg_conv;
15323         contents_arg_conv.inner = (void*)(contents_arg & (~1));
15324         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
15325         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
15326         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
15327         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15328         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15329         long ret_ref = (long)ret_var.inner;
15330         if (ret_var.is_owned) {
15331                 ret_ref |= 1;
15332         }
15333         return ret_ref;
15334 }
15335
15336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15337         LDKNodeAnnouncement orig_conv;
15338         orig_conv.inner = (void*)(orig & (~1));
15339         orig_conv.is_owned = false;
15340         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
15341         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15342         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15343         long ret_ref = (long)ret_var.inner;
15344         if (ret_var.is_owned) {
15345                 ret_ref |= 1;
15346         }
15347         return ret_ref;
15348 }
15349
15350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15351         LDKUnsignedChannelAnnouncement this_obj_conv;
15352         this_obj_conv.inner = (void*)(this_obj & (~1));
15353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15354         UnsignedChannelAnnouncement_free(this_obj_conv);
15355 }
15356
15357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
15358         LDKUnsignedChannelAnnouncement this_ptr_conv;
15359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15360         this_ptr_conv.is_owned = false;
15361         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
15362         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15363         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15364         long ret_ref = (long)ret_var.inner;
15365         if (ret_var.is_owned) {
15366                 ret_ref |= 1;
15367         }
15368         return ret_ref;
15369 }
15370
15371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15372         LDKUnsignedChannelAnnouncement this_ptr_conv;
15373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15374         this_ptr_conv.is_owned = false;
15375         LDKChannelFeatures val_conv;
15376         val_conv.inner = (void*)(val & (~1));
15377         val_conv.is_owned = (val & 1) || (val == 0);
15378         val_conv = ChannelFeatures_clone(&val_conv);
15379         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
15380 }
15381
15382 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15383         LDKUnsignedChannelAnnouncement this_ptr_conv;
15384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15385         this_ptr_conv.is_owned = false;
15386         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15387         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
15388         return ret_arr;
15389 }
15390
15391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15392         LDKUnsignedChannelAnnouncement this_ptr_conv;
15393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15394         this_ptr_conv.is_owned = false;
15395         LDKThirtyTwoBytes val_ref;
15396         CHECK((*env)->GetArrayLength(env, val) == 32);
15397         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15398         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
15399 }
15400
15401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15402         LDKUnsignedChannelAnnouncement this_ptr_conv;
15403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15404         this_ptr_conv.is_owned = false;
15405         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
15406         return ret_val;
15407 }
15408
15409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15410         LDKUnsignedChannelAnnouncement this_ptr_conv;
15411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15412         this_ptr_conv.is_owned = false;
15413         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
15414 }
15415
15416 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
15417         LDKUnsignedChannelAnnouncement this_ptr_conv;
15418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15419         this_ptr_conv.is_owned = false;
15420         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15421         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
15422         return ret_arr;
15423 }
15424
15425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15426         LDKUnsignedChannelAnnouncement this_ptr_conv;
15427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15428         this_ptr_conv.is_owned = false;
15429         LDKPublicKey val_ref;
15430         CHECK((*env)->GetArrayLength(env, val) == 33);
15431         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15432         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
15433 }
15434
15435 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
15436         LDKUnsignedChannelAnnouncement this_ptr_conv;
15437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15438         this_ptr_conv.is_owned = false;
15439         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15440         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
15441         return ret_arr;
15442 }
15443
15444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15445         LDKUnsignedChannelAnnouncement this_ptr_conv;
15446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15447         this_ptr_conv.is_owned = false;
15448         LDKPublicKey val_ref;
15449         CHECK((*env)->GetArrayLength(env, val) == 33);
15450         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15451         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
15452 }
15453
15454 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
15455         LDKUnsignedChannelAnnouncement this_ptr_conv;
15456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15457         this_ptr_conv.is_owned = false;
15458         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15459         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
15460         return ret_arr;
15461 }
15462
15463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15464         LDKUnsignedChannelAnnouncement this_ptr_conv;
15465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15466         this_ptr_conv.is_owned = false;
15467         LDKPublicKey val_ref;
15468         CHECK((*env)->GetArrayLength(env, val) == 33);
15469         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15470         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
15471 }
15472
15473 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
15474         LDKUnsignedChannelAnnouncement this_ptr_conv;
15475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15476         this_ptr_conv.is_owned = false;
15477         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15478         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
15479         return ret_arr;
15480 }
15481
15482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15483         LDKUnsignedChannelAnnouncement this_ptr_conv;
15484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15485         this_ptr_conv.is_owned = false;
15486         LDKPublicKey val_ref;
15487         CHECK((*env)->GetArrayLength(env, val) == 33);
15488         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15489         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
15490 }
15491
15492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15493         LDKUnsignedChannelAnnouncement orig_conv;
15494         orig_conv.inner = (void*)(orig & (~1));
15495         orig_conv.is_owned = false;
15496         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
15497         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15498         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15499         long ret_ref = (long)ret_var.inner;
15500         if (ret_var.is_owned) {
15501                 ret_ref |= 1;
15502         }
15503         return ret_ref;
15504 }
15505
15506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15507         LDKChannelAnnouncement this_obj_conv;
15508         this_obj_conv.inner = (void*)(this_obj & (~1));
15509         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15510         ChannelAnnouncement_free(this_obj_conv);
15511 }
15512
15513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
15514         LDKChannelAnnouncement this_ptr_conv;
15515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15516         this_ptr_conv.is_owned = false;
15517         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15518         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
15519         return ret_arr;
15520 }
15521
15522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15523         LDKChannelAnnouncement this_ptr_conv;
15524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15525         this_ptr_conv.is_owned = false;
15526         LDKSignature val_ref;
15527         CHECK((*env)->GetArrayLength(env, val) == 64);
15528         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15529         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
15530 }
15531
15532 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
15533         LDKChannelAnnouncement this_ptr_conv;
15534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15535         this_ptr_conv.is_owned = false;
15536         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15537         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
15538         return ret_arr;
15539 }
15540
15541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15542         LDKChannelAnnouncement this_ptr_conv;
15543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15544         this_ptr_conv.is_owned = false;
15545         LDKSignature val_ref;
15546         CHECK((*env)->GetArrayLength(env, val) == 64);
15547         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15548         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
15549 }
15550
15551 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
15552         LDKChannelAnnouncement this_ptr_conv;
15553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15554         this_ptr_conv.is_owned = false;
15555         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15556         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
15557         return ret_arr;
15558 }
15559
15560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15561         LDKChannelAnnouncement this_ptr_conv;
15562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15563         this_ptr_conv.is_owned = false;
15564         LDKSignature val_ref;
15565         CHECK((*env)->GetArrayLength(env, val) == 64);
15566         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15567         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
15568 }
15569
15570 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
15571         LDKChannelAnnouncement this_ptr_conv;
15572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15573         this_ptr_conv.is_owned = false;
15574         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15575         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
15576         return ret_arr;
15577 }
15578
15579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15580         LDKChannelAnnouncement this_ptr_conv;
15581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15582         this_ptr_conv.is_owned = false;
15583         LDKSignature val_ref;
15584         CHECK((*env)->GetArrayLength(env, val) == 64);
15585         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15586         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
15587 }
15588
15589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
15590         LDKChannelAnnouncement this_ptr_conv;
15591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15592         this_ptr_conv.is_owned = false;
15593         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
15594         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15595         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15596         long ret_ref = (long)ret_var.inner;
15597         if (ret_var.is_owned) {
15598                 ret_ref |= 1;
15599         }
15600         return ret_ref;
15601 }
15602
15603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15604         LDKChannelAnnouncement this_ptr_conv;
15605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15606         this_ptr_conv.is_owned = false;
15607         LDKUnsignedChannelAnnouncement val_conv;
15608         val_conv.inner = (void*)(val & (~1));
15609         val_conv.is_owned = (val & 1) || (val == 0);
15610         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
15611         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
15612 }
15613
15614 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) {
15615         LDKSignature node_signature_1_arg_ref;
15616         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
15617         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
15618         LDKSignature node_signature_2_arg_ref;
15619         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
15620         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
15621         LDKSignature bitcoin_signature_1_arg_ref;
15622         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
15623         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
15624         LDKSignature bitcoin_signature_2_arg_ref;
15625         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
15626         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
15627         LDKUnsignedChannelAnnouncement contents_arg_conv;
15628         contents_arg_conv.inner = (void*)(contents_arg & (~1));
15629         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
15630         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
15631         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);
15632         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15633         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15634         long ret_ref = (long)ret_var.inner;
15635         if (ret_var.is_owned) {
15636                 ret_ref |= 1;
15637         }
15638         return ret_ref;
15639 }
15640
15641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15642         LDKChannelAnnouncement orig_conv;
15643         orig_conv.inner = (void*)(orig & (~1));
15644         orig_conv.is_owned = false;
15645         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
15646         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15647         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15648         long ret_ref = (long)ret_var.inner;
15649         if (ret_var.is_owned) {
15650                 ret_ref |= 1;
15651         }
15652         return ret_ref;
15653 }
15654
15655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15656         LDKUnsignedChannelUpdate this_obj_conv;
15657         this_obj_conv.inner = (void*)(this_obj & (~1));
15658         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15659         UnsignedChannelUpdate_free(this_obj_conv);
15660 }
15661
15662 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15663         LDKUnsignedChannelUpdate this_ptr_conv;
15664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15665         this_ptr_conv.is_owned = false;
15666         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15667         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
15668         return ret_arr;
15669 }
15670
15671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15672         LDKUnsignedChannelUpdate this_ptr_conv;
15673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15674         this_ptr_conv.is_owned = false;
15675         LDKThirtyTwoBytes val_ref;
15676         CHECK((*env)->GetArrayLength(env, val) == 32);
15677         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15678         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
15679 }
15680
15681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15682         LDKUnsignedChannelUpdate this_ptr_conv;
15683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15684         this_ptr_conv.is_owned = false;
15685         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
15686         return ret_val;
15687 }
15688
15689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15690         LDKUnsignedChannelUpdate this_ptr_conv;
15691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15692         this_ptr_conv.is_owned = false;
15693         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
15694 }
15695
15696 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
15697         LDKUnsignedChannelUpdate this_ptr_conv;
15698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15699         this_ptr_conv.is_owned = false;
15700         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
15701         return ret_val;
15702 }
15703
15704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15705         LDKUnsignedChannelUpdate this_ptr_conv;
15706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15707         this_ptr_conv.is_owned = false;
15708         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
15709 }
15710
15711 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
15712         LDKUnsignedChannelUpdate this_ptr_conv;
15713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15714         this_ptr_conv.is_owned = false;
15715         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
15716         return ret_val;
15717 }
15718
15719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
15720         LDKUnsignedChannelUpdate this_ptr_conv;
15721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15722         this_ptr_conv.is_owned = false;
15723         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
15724 }
15725
15726 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
15727         LDKUnsignedChannelUpdate this_ptr_conv;
15728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15729         this_ptr_conv.is_owned = false;
15730         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
15731         return ret_val;
15732 }
15733
15734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15735         LDKUnsignedChannelUpdate this_ptr_conv;
15736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15737         this_ptr_conv.is_owned = false;
15738         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
15739 }
15740
15741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15742         LDKUnsignedChannelUpdate this_ptr_conv;
15743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15744         this_ptr_conv.is_owned = false;
15745         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
15746         return ret_val;
15747 }
15748
15749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15750         LDKUnsignedChannelUpdate this_ptr_conv;
15751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15752         this_ptr_conv.is_owned = false;
15753         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
15754 }
15755
15756 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15757         LDKUnsignedChannelUpdate this_ptr_conv;
15758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15759         this_ptr_conv.is_owned = false;
15760         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
15761         return ret_val;
15762 }
15763
15764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15765         LDKUnsignedChannelUpdate this_ptr_conv;
15766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15767         this_ptr_conv.is_owned = false;
15768         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
15769 }
15770
15771 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
15772         LDKUnsignedChannelUpdate this_ptr_conv;
15773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15774         this_ptr_conv.is_owned = false;
15775         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
15776         return ret_val;
15777 }
15778
15779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15780         LDKUnsignedChannelUpdate this_ptr_conv;
15781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15782         this_ptr_conv.is_owned = false;
15783         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
15784 }
15785
15786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15787         LDKUnsignedChannelUpdate orig_conv;
15788         orig_conv.inner = (void*)(orig & (~1));
15789         orig_conv.is_owned = false;
15790         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
15791         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15792         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15793         long ret_ref = (long)ret_var.inner;
15794         if (ret_var.is_owned) {
15795                 ret_ref |= 1;
15796         }
15797         return ret_ref;
15798 }
15799
15800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15801         LDKChannelUpdate this_obj_conv;
15802         this_obj_conv.inner = (void*)(this_obj & (~1));
15803         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15804         ChannelUpdate_free(this_obj_conv);
15805 }
15806
15807 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15808         LDKChannelUpdate this_ptr_conv;
15809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15810         this_ptr_conv.is_owned = false;
15811         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15812         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
15813         return ret_arr;
15814 }
15815
15816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15817         LDKChannelUpdate this_ptr_conv;
15818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15819         this_ptr_conv.is_owned = false;
15820         LDKSignature val_ref;
15821         CHECK((*env)->GetArrayLength(env, val) == 64);
15822         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15823         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
15824 }
15825
15826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
15827         LDKChannelUpdate this_ptr_conv;
15828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15829         this_ptr_conv.is_owned = false;
15830         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
15831         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15832         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15833         long ret_ref = (long)ret_var.inner;
15834         if (ret_var.is_owned) {
15835                 ret_ref |= 1;
15836         }
15837         return ret_ref;
15838 }
15839
15840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15841         LDKChannelUpdate this_ptr_conv;
15842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15843         this_ptr_conv.is_owned = false;
15844         LDKUnsignedChannelUpdate val_conv;
15845         val_conv.inner = (void*)(val & (~1));
15846         val_conv.is_owned = (val & 1) || (val == 0);
15847         val_conv = UnsignedChannelUpdate_clone(&val_conv);
15848         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
15849 }
15850
15851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
15852         LDKSignature signature_arg_ref;
15853         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
15854         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
15855         LDKUnsignedChannelUpdate contents_arg_conv;
15856         contents_arg_conv.inner = (void*)(contents_arg & (~1));
15857         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
15858         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
15859         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
15860         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15861         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15862         long ret_ref = (long)ret_var.inner;
15863         if (ret_var.is_owned) {
15864                 ret_ref |= 1;
15865         }
15866         return ret_ref;
15867 }
15868
15869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15870         LDKChannelUpdate orig_conv;
15871         orig_conv.inner = (void*)(orig & (~1));
15872         orig_conv.is_owned = false;
15873         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
15874         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15875         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15876         long ret_ref = (long)ret_var.inner;
15877         if (ret_var.is_owned) {
15878                 ret_ref |= 1;
15879         }
15880         return ret_ref;
15881 }
15882
15883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15884         LDKQueryChannelRange this_obj_conv;
15885         this_obj_conv.inner = (void*)(this_obj & (~1));
15886         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15887         QueryChannelRange_free(this_obj_conv);
15888 }
15889
15890 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15891         LDKQueryChannelRange this_ptr_conv;
15892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15893         this_ptr_conv.is_owned = false;
15894         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15895         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
15896         return ret_arr;
15897 }
15898
15899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15900         LDKQueryChannelRange this_ptr_conv;
15901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15902         this_ptr_conv.is_owned = false;
15903         LDKThirtyTwoBytes val_ref;
15904         CHECK((*env)->GetArrayLength(env, val) == 32);
15905         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15906         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
15907 }
15908
15909 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
15910         LDKQueryChannelRange this_ptr_conv;
15911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15912         this_ptr_conv.is_owned = false;
15913         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
15914         return ret_val;
15915 }
15916
15917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15918         LDKQueryChannelRange this_ptr_conv;
15919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15920         this_ptr_conv.is_owned = false;
15921         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
15922 }
15923
15924 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
15925         LDKQueryChannelRange this_ptr_conv;
15926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15927         this_ptr_conv.is_owned = false;
15928         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
15929         return ret_val;
15930 }
15931
15932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15933         LDKQueryChannelRange this_ptr_conv;
15934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15935         this_ptr_conv.is_owned = false;
15936         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
15937 }
15938
15939 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) {
15940         LDKThirtyTwoBytes chain_hash_arg_ref;
15941         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
15942         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
15943         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
15944         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15945         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15946         long ret_ref = (long)ret_var.inner;
15947         if (ret_var.is_owned) {
15948                 ret_ref |= 1;
15949         }
15950         return ret_ref;
15951 }
15952
15953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15954         LDKQueryChannelRange orig_conv;
15955         orig_conv.inner = (void*)(orig & (~1));
15956         orig_conv.is_owned = false;
15957         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
15958         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15959         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15960         long ret_ref = (long)ret_var.inner;
15961         if (ret_var.is_owned) {
15962                 ret_ref |= 1;
15963         }
15964         return ret_ref;
15965 }
15966
15967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15968         LDKReplyChannelRange this_obj_conv;
15969         this_obj_conv.inner = (void*)(this_obj & (~1));
15970         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15971         ReplyChannelRange_free(this_obj_conv);
15972 }
15973
15974 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15975         LDKReplyChannelRange this_ptr_conv;
15976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15977         this_ptr_conv.is_owned = false;
15978         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15979         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
15980         return ret_arr;
15981 }
15982
15983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15984         LDKReplyChannelRange this_ptr_conv;
15985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15986         this_ptr_conv.is_owned = false;
15987         LDKThirtyTwoBytes val_ref;
15988         CHECK((*env)->GetArrayLength(env, val) == 32);
15989         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15990         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
15991 }
15992
15993 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
15994         LDKReplyChannelRange this_ptr_conv;
15995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15996         this_ptr_conv.is_owned = false;
15997         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
15998         return ret_val;
15999 }
16000
16001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16002         LDKReplyChannelRange this_ptr_conv;
16003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16004         this_ptr_conv.is_owned = false;
16005         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
16006 }
16007
16008 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
16009         LDKReplyChannelRange this_ptr_conv;
16010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16011         this_ptr_conv.is_owned = false;
16012         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
16013         return ret_val;
16014 }
16015
16016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16017         LDKReplyChannelRange this_ptr_conv;
16018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16019         this_ptr_conv.is_owned = false;
16020         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
16021 }
16022
16023 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
16024         LDKReplyChannelRange this_ptr_conv;
16025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16026         this_ptr_conv.is_owned = false;
16027         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
16028         return ret_val;
16029 }
16030
16031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16032         LDKReplyChannelRange this_ptr_conv;
16033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16034         this_ptr_conv.is_owned = false;
16035         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
16036 }
16037
16038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16039         LDKReplyChannelRange this_ptr_conv;
16040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16041         this_ptr_conv.is_owned = false;
16042         LDKCVec_u64Z val_constr;
16043         val_constr.datalen = (*env)->GetArrayLength(env, val);
16044         if (val_constr.datalen > 0)
16045                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16046         else
16047                 val_constr.data = NULL;
16048         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16049         for (size_t g = 0; g < val_constr.datalen; g++) {
16050                 int64_t val_conv_6 = val_vals[g];
16051                 val_constr.data[g] = val_conv_6;
16052         }
16053         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16054         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
16055 }
16056
16057 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) {
16058         LDKThirtyTwoBytes chain_hash_arg_ref;
16059         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16060         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16061         LDKCVec_u64Z short_channel_ids_arg_constr;
16062         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
16063         if (short_channel_ids_arg_constr.datalen > 0)
16064                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16065         else
16066                 short_channel_ids_arg_constr.data = NULL;
16067         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
16068         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
16069                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
16070                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
16071         }
16072         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
16073         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
16074         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16075         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16076         long ret_ref = (long)ret_var.inner;
16077         if (ret_var.is_owned) {
16078                 ret_ref |= 1;
16079         }
16080         return ret_ref;
16081 }
16082
16083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16084         LDKReplyChannelRange orig_conv;
16085         orig_conv.inner = (void*)(orig & (~1));
16086         orig_conv.is_owned = false;
16087         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
16088         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16089         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16090         long ret_ref = (long)ret_var.inner;
16091         if (ret_var.is_owned) {
16092                 ret_ref |= 1;
16093         }
16094         return ret_ref;
16095 }
16096
16097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16098         LDKQueryShortChannelIds this_obj_conv;
16099         this_obj_conv.inner = (void*)(this_obj & (~1));
16100         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16101         QueryShortChannelIds_free(this_obj_conv);
16102 }
16103
16104 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16105         LDKQueryShortChannelIds this_ptr_conv;
16106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16107         this_ptr_conv.is_owned = false;
16108         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16109         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
16110         return ret_arr;
16111 }
16112
16113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16114         LDKQueryShortChannelIds this_ptr_conv;
16115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16116         this_ptr_conv.is_owned = false;
16117         LDKThirtyTwoBytes val_ref;
16118         CHECK((*env)->GetArrayLength(env, val) == 32);
16119         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16120         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
16121 }
16122
16123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16124         LDKQueryShortChannelIds this_ptr_conv;
16125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16126         this_ptr_conv.is_owned = false;
16127         LDKCVec_u64Z val_constr;
16128         val_constr.datalen = (*env)->GetArrayLength(env, val);
16129         if (val_constr.datalen > 0)
16130                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16131         else
16132                 val_constr.data = NULL;
16133         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16134         for (size_t g = 0; g < val_constr.datalen; g++) {
16135                 int64_t val_conv_6 = val_vals[g];
16136                 val_constr.data[g] = val_conv_6;
16137         }
16138         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16139         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
16140 }
16141
16142 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) {
16143         LDKThirtyTwoBytes chain_hash_arg_ref;
16144         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16145         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16146         LDKCVec_u64Z short_channel_ids_arg_constr;
16147         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
16148         if (short_channel_ids_arg_constr.datalen > 0)
16149                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16150         else
16151                 short_channel_ids_arg_constr.data = NULL;
16152         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
16153         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
16154                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
16155                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
16156         }
16157         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
16158         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
16159         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16160         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16161         long ret_ref = (long)ret_var.inner;
16162         if (ret_var.is_owned) {
16163                 ret_ref |= 1;
16164         }
16165         return ret_ref;
16166 }
16167
16168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16169         LDKQueryShortChannelIds orig_conv;
16170         orig_conv.inner = (void*)(orig & (~1));
16171         orig_conv.is_owned = false;
16172         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
16173         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16174         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16175         long ret_ref = (long)ret_var.inner;
16176         if (ret_var.is_owned) {
16177                 ret_ref |= 1;
16178         }
16179         return ret_ref;
16180 }
16181
16182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16183         LDKReplyShortChannelIdsEnd this_obj_conv;
16184         this_obj_conv.inner = (void*)(this_obj & (~1));
16185         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16186         ReplyShortChannelIdsEnd_free(this_obj_conv);
16187 }
16188
16189 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16190         LDKReplyShortChannelIdsEnd this_ptr_conv;
16191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16192         this_ptr_conv.is_owned = false;
16193         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16194         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
16195         return ret_arr;
16196 }
16197
16198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16199         LDKReplyShortChannelIdsEnd this_ptr_conv;
16200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16201         this_ptr_conv.is_owned = false;
16202         LDKThirtyTwoBytes val_ref;
16203         CHECK((*env)->GetArrayLength(env, val) == 32);
16204         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16205         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
16206 }
16207
16208 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
16209         LDKReplyShortChannelIdsEnd this_ptr_conv;
16210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16211         this_ptr_conv.is_owned = false;
16212         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
16213         return ret_val;
16214 }
16215
16216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16217         LDKReplyShortChannelIdsEnd this_ptr_conv;
16218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16219         this_ptr_conv.is_owned = false;
16220         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
16221 }
16222
16223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
16224         LDKThirtyTwoBytes chain_hash_arg_ref;
16225         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16226         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16227         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
16228         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16229         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16230         long ret_ref = (long)ret_var.inner;
16231         if (ret_var.is_owned) {
16232                 ret_ref |= 1;
16233         }
16234         return ret_ref;
16235 }
16236
16237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16238         LDKReplyShortChannelIdsEnd orig_conv;
16239         orig_conv.inner = (void*)(orig & (~1));
16240         orig_conv.is_owned = false;
16241         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
16242         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16243         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16244         long ret_ref = (long)ret_var.inner;
16245         if (ret_var.is_owned) {
16246                 ret_ref |= 1;
16247         }
16248         return ret_ref;
16249 }
16250
16251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16252         LDKGossipTimestampFilter this_obj_conv;
16253         this_obj_conv.inner = (void*)(this_obj & (~1));
16254         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16255         GossipTimestampFilter_free(this_obj_conv);
16256 }
16257
16258 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16259         LDKGossipTimestampFilter this_ptr_conv;
16260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16261         this_ptr_conv.is_owned = false;
16262         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16263         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
16264         return ret_arr;
16265 }
16266
16267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16268         LDKGossipTimestampFilter this_ptr_conv;
16269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16270         this_ptr_conv.is_owned = false;
16271         LDKThirtyTwoBytes val_ref;
16272         CHECK((*env)->GetArrayLength(env, val) == 32);
16273         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16274         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
16275 }
16276
16277 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
16278         LDKGossipTimestampFilter this_ptr_conv;
16279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16280         this_ptr_conv.is_owned = false;
16281         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
16282         return ret_val;
16283 }
16284
16285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16286         LDKGossipTimestampFilter this_ptr_conv;
16287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16288         this_ptr_conv.is_owned = false;
16289         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
16290 }
16291
16292 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
16293         LDKGossipTimestampFilter this_ptr_conv;
16294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16295         this_ptr_conv.is_owned = false;
16296         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
16297         return ret_val;
16298 }
16299
16300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16301         LDKGossipTimestampFilter this_ptr_conv;
16302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16303         this_ptr_conv.is_owned = false;
16304         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
16305 }
16306
16307 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) {
16308         LDKThirtyTwoBytes chain_hash_arg_ref;
16309         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16310         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16311         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
16312         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16313         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16314         long ret_ref = (long)ret_var.inner;
16315         if (ret_var.is_owned) {
16316                 ret_ref |= 1;
16317         }
16318         return ret_ref;
16319 }
16320
16321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16322         LDKGossipTimestampFilter orig_conv;
16323         orig_conv.inner = (void*)(orig & (~1));
16324         orig_conv.is_owned = false;
16325         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
16326         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16327         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16328         long ret_ref = (long)ret_var.inner;
16329         if (ret_var.is_owned) {
16330                 ret_ref |= 1;
16331         }
16332         return ret_ref;
16333 }
16334
16335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16336         if ((this_ptr & 1) != 0) return;
16337         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
16338         FREE((void*)this_ptr);
16339         ErrorAction_free(this_ptr_conv);
16340 }
16341
16342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16343         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
16344         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
16345         *ret_copy = ErrorAction_clone(orig_conv);
16346         long ret_ref = (long)ret_copy;
16347         return ret_ref;
16348 }
16349
16350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16351         LDKLightningError this_obj_conv;
16352         this_obj_conv.inner = (void*)(this_obj & (~1));
16353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16354         LightningError_free(this_obj_conv);
16355 }
16356
16357 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
16358         LDKLightningError this_ptr_conv;
16359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16360         this_ptr_conv.is_owned = false;
16361         LDKStr _str = LightningError_get_err(&this_ptr_conv);
16362         jstring _conv = str_ref_to_java(env, _str.chars, _str.len);
16363         return _conv;
16364 }
16365
16366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16367         LDKLightningError this_ptr_conv;
16368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16369         this_ptr_conv.is_owned = false;
16370         LDKCVec_u8Z val_ref;
16371         val_ref.datalen = (*env)->GetArrayLength(env, val);
16372         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
16373         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
16374         LightningError_set_err(&this_ptr_conv, val_ref);
16375 }
16376
16377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
16378         LDKLightningError this_ptr_conv;
16379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16380         this_ptr_conv.is_owned = false;
16381         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
16382         *ret_copy = LightningError_get_action(&this_ptr_conv);
16383         long ret_ref = (long)ret_copy;
16384         return ret_ref;
16385 }
16386
16387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16388         LDKLightningError this_ptr_conv;
16389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16390         this_ptr_conv.is_owned = false;
16391         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
16392         FREE((void*)val);
16393         LightningError_set_action(&this_ptr_conv, val_conv);
16394 }
16395
16396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, int8_tArray err_arg, int64_t action_arg) {
16397         LDKCVec_u8Z err_arg_ref;
16398         err_arg_ref.datalen = (*env)->GetArrayLength(env, err_arg);
16399         err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
16400         (*env)->GetByteArrayRegion(env, err_arg, 0, err_arg_ref.datalen, err_arg_ref.data);
16401         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
16402         FREE((void*)action_arg);
16403         LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
16404         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16405         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16406         long ret_ref = (long)ret_var.inner;
16407         if (ret_var.is_owned) {
16408                 ret_ref |= 1;
16409         }
16410         return ret_ref;
16411 }
16412
16413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16414         LDKLightningError orig_conv;
16415         orig_conv.inner = (void*)(orig & (~1));
16416         orig_conv.is_owned = false;
16417         LDKLightningError ret_var = LightningError_clone(&orig_conv);
16418         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16419         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16420         long ret_ref = (long)ret_var.inner;
16421         if (ret_var.is_owned) {
16422                 ret_ref |= 1;
16423         }
16424         return ret_ref;
16425 }
16426
16427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16428         LDKCommitmentUpdate this_obj_conv;
16429         this_obj_conv.inner = (void*)(this_obj & (~1));
16430         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16431         CommitmentUpdate_free(this_obj_conv);
16432 }
16433
16434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16435         LDKCommitmentUpdate this_ptr_conv;
16436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16437         this_ptr_conv.is_owned = false;
16438         LDKCVec_UpdateAddHTLCZ val_constr;
16439         val_constr.datalen = (*env)->GetArrayLength(env, val);
16440         if (val_constr.datalen > 0)
16441                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
16442         else
16443                 val_constr.data = NULL;
16444         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16445         for (size_t p = 0; p < val_constr.datalen; p++) {
16446                 int64_t val_conv_15 = val_vals[p];
16447                 LDKUpdateAddHTLC val_conv_15_conv;
16448                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
16449                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
16450                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
16451                 val_constr.data[p] = val_conv_15_conv;
16452         }
16453         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16454         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
16455 }
16456
16457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16458         LDKCommitmentUpdate this_ptr_conv;
16459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16460         this_ptr_conv.is_owned = false;
16461         LDKCVec_UpdateFulfillHTLCZ val_constr;
16462         val_constr.datalen = (*env)->GetArrayLength(env, val);
16463         if (val_constr.datalen > 0)
16464                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
16465         else
16466                 val_constr.data = NULL;
16467         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16468         for (size_t t = 0; t < val_constr.datalen; t++) {
16469                 int64_t val_conv_19 = val_vals[t];
16470                 LDKUpdateFulfillHTLC val_conv_19_conv;
16471                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
16472                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
16473                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
16474                 val_constr.data[t] = val_conv_19_conv;
16475         }
16476         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16477         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
16478 }
16479
16480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16481         LDKCommitmentUpdate this_ptr_conv;
16482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16483         this_ptr_conv.is_owned = false;
16484         LDKCVec_UpdateFailHTLCZ val_constr;
16485         val_constr.datalen = (*env)->GetArrayLength(env, val);
16486         if (val_constr.datalen > 0)
16487                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
16488         else
16489                 val_constr.data = NULL;
16490         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16491         for (size_t q = 0; q < val_constr.datalen; q++) {
16492                 int64_t val_conv_16 = val_vals[q];
16493                 LDKUpdateFailHTLC val_conv_16_conv;
16494                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
16495                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
16496                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
16497                 val_constr.data[q] = val_conv_16_conv;
16498         }
16499         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16500         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
16501 }
16502
16503 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) {
16504         LDKCommitmentUpdate this_ptr_conv;
16505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16506         this_ptr_conv.is_owned = false;
16507         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
16508         val_constr.datalen = (*env)->GetArrayLength(env, val);
16509         if (val_constr.datalen > 0)
16510                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
16511         else
16512                 val_constr.data = NULL;
16513         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16514         for (size_t z = 0; z < val_constr.datalen; z++) {
16515                 int64_t val_conv_25 = val_vals[z];
16516                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
16517                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
16518                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
16519                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
16520                 val_constr.data[z] = val_conv_25_conv;
16521         }
16522         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16523         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
16524 }
16525
16526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
16527         LDKCommitmentUpdate this_ptr_conv;
16528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16529         this_ptr_conv.is_owned = false;
16530         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
16531         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16532         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16533         long ret_ref = (long)ret_var.inner;
16534         if (ret_var.is_owned) {
16535                 ret_ref |= 1;
16536         }
16537         return ret_ref;
16538 }
16539
16540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16541         LDKCommitmentUpdate this_ptr_conv;
16542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16543         this_ptr_conv.is_owned = false;
16544         LDKUpdateFee val_conv;
16545         val_conv.inner = (void*)(val & (~1));
16546         val_conv.is_owned = (val & 1) || (val == 0);
16547         val_conv = UpdateFee_clone(&val_conv);
16548         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
16549 }
16550
16551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
16552         LDKCommitmentUpdate this_ptr_conv;
16553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16554         this_ptr_conv.is_owned = false;
16555         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
16556         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16557         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16558         long ret_ref = (long)ret_var.inner;
16559         if (ret_var.is_owned) {
16560                 ret_ref |= 1;
16561         }
16562         return ret_ref;
16563 }
16564
16565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16566         LDKCommitmentUpdate this_ptr_conv;
16567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16568         this_ptr_conv.is_owned = false;
16569         LDKCommitmentSigned val_conv;
16570         val_conv.inner = (void*)(val & (~1));
16571         val_conv.is_owned = (val & 1) || (val == 0);
16572         val_conv = CommitmentSigned_clone(&val_conv);
16573         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
16574 }
16575
16576 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) {
16577         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
16578         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
16579         if (update_add_htlcs_arg_constr.datalen > 0)
16580                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
16581         else
16582                 update_add_htlcs_arg_constr.data = NULL;
16583         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
16584         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
16585                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
16586                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
16587                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
16588                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
16589                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
16590                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
16591         }
16592         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
16593         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
16594         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
16595         if (update_fulfill_htlcs_arg_constr.datalen > 0)
16596                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
16597         else
16598                 update_fulfill_htlcs_arg_constr.data = NULL;
16599         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
16600         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
16601                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
16602                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
16603                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
16604                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
16605                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
16606                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
16607         }
16608         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
16609         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
16610         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
16611         if (update_fail_htlcs_arg_constr.datalen > 0)
16612                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
16613         else
16614                 update_fail_htlcs_arg_constr.data = NULL;
16615         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
16616         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
16617                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
16618                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
16619                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
16620                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
16621                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
16622                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
16623         }
16624         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
16625         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
16626         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
16627         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
16628                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
16629         else
16630                 update_fail_malformed_htlcs_arg_constr.data = NULL;
16631         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
16632         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
16633                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
16634                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
16635                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
16636                 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);
16637                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
16638                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
16639         }
16640         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
16641         LDKUpdateFee update_fee_arg_conv;
16642         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
16643         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
16644         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
16645         LDKCommitmentSigned commitment_signed_arg_conv;
16646         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
16647         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
16648         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
16649         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);
16650         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16651         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16652         long ret_ref = (long)ret_var.inner;
16653         if (ret_var.is_owned) {
16654                 ret_ref |= 1;
16655         }
16656         return ret_ref;
16657 }
16658
16659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16660         LDKCommitmentUpdate orig_conv;
16661         orig_conv.inner = (void*)(orig & (~1));
16662         orig_conv.is_owned = false;
16663         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
16664         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16665         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16666         long ret_ref = (long)ret_var.inner;
16667         if (ret_var.is_owned) {
16668                 ret_ref |= 1;
16669         }
16670         return ret_ref;
16671 }
16672
16673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16674         if ((this_ptr & 1) != 0) return;
16675         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
16676         FREE((void*)this_ptr);
16677         HTLCFailChannelUpdate_free(this_ptr_conv);
16678 }
16679
16680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16681         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
16682         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
16683         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
16684         long ret_ref = (long)ret_copy;
16685         return ret_ref;
16686 }
16687
16688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16689         if ((this_ptr & 1) != 0) return;
16690         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
16691         FREE((void*)this_ptr);
16692         ChannelMessageHandler_free(this_ptr_conv);
16693 }
16694
16695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16696         if ((this_ptr & 1) != 0) return;
16697         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
16698         FREE((void*)this_ptr);
16699         RoutingMessageHandler_free(this_ptr_conv);
16700 }
16701
16702 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
16703         LDKAcceptChannel obj_conv;
16704         obj_conv.inner = (void*)(obj & (~1));
16705         obj_conv.is_owned = false;
16706         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
16707         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16708         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16709         CVec_u8Z_free(ret_var);
16710         return ret_arr;
16711 }
16712
16713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16714         LDKu8slice ser_ref;
16715         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16716         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16717         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
16718         *ret_conv = AcceptChannel_read(ser_ref);
16719         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16720         return (long)ret_conv;
16721 }
16722
16723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
16724         LDKAnnouncementSignatures obj_conv;
16725         obj_conv.inner = (void*)(obj & (~1));
16726         obj_conv.is_owned = false;
16727         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
16728         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16729         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16730         CVec_u8Z_free(ret_var);
16731         return ret_arr;
16732 }
16733
16734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16735         LDKu8slice ser_ref;
16736         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16737         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16738         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
16739         *ret_conv = AnnouncementSignatures_read(ser_ref);
16740         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16741         return (long)ret_conv;
16742 }
16743
16744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
16745         LDKChannelReestablish obj_conv;
16746         obj_conv.inner = (void*)(obj & (~1));
16747         obj_conv.is_owned = false;
16748         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
16749         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16750         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16751         CVec_u8Z_free(ret_var);
16752         return ret_arr;
16753 }
16754
16755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16756         LDKu8slice ser_ref;
16757         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16758         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16759         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
16760         *ret_conv = ChannelReestablish_read(ser_ref);
16761         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16762         return (long)ret_conv;
16763 }
16764
16765 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
16766         LDKClosingSigned obj_conv;
16767         obj_conv.inner = (void*)(obj & (~1));
16768         obj_conv.is_owned = false;
16769         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
16770         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16771         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16772         CVec_u8Z_free(ret_var);
16773         return ret_arr;
16774 }
16775
16776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16777         LDKu8slice ser_ref;
16778         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16779         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16780         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
16781         *ret_conv = ClosingSigned_read(ser_ref);
16782         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16783         return (long)ret_conv;
16784 }
16785
16786 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
16787         LDKCommitmentSigned obj_conv;
16788         obj_conv.inner = (void*)(obj & (~1));
16789         obj_conv.is_owned = false;
16790         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
16791         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16792         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16793         CVec_u8Z_free(ret_var);
16794         return ret_arr;
16795 }
16796
16797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16798         LDKu8slice ser_ref;
16799         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16800         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16801         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
16802         *ret_conv = CommitmentSigned_read(ser_ref);
16803         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16804         return (long)ret_conv;
16805 }
16806
16807 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
16808         LDKFundingCreated obj_conv;
16809         obj_conv.inner = (void*)(obj & (~1));
16810         obj_conv.is_owned = false;
16811         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
16812         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16813         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16814         CVec_u8Z_free(ret_var);
16815         return ret_arr;
16816 }
16817
16818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16819         LDKu8slice ser_ref;
16820         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16821         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16822         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
16823         *ret_conv = FundingCreated_read(ser_ref);
16824         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16825         return (long)ret_conv;
16826 }
16827
16828 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
16829         LDKFundingSigned obj_conv;
16830         obj_conv.inner = (void*)(obj & (~1));
16831         obj_conv.is_owned = false;
16832         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
16833         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16834         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16835         CVec_u8Z_free(ret_var);
16836         return ret_arr;
16837 }
16838
16839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16840         LDKu8slice ser_ref;
16841         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16842         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16843         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
16844         *ret_conv = FundingSigned_read(ser_ref);
16845         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16846         return (long)ret_conv;
16847 }
16848
16849 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
16850         LDKFundingLocked obj_conv;
16851         obj_conv.inner = (void*)(obj & (~1));
16852         obj_conv.is_owned = false;
16853         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
16854         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16855         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16856         CVec_u8Z_free(ret_var);
16857         return ret_arr;
16858 }
16859
16860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16861         LDKu8slice ser_ref;
16862         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16863         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16864         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
16865         *ret_conv = FundingLocked_read(ser_ref);
16866         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16867         return (long)ret_conv;
16868 }
16869
16870 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
16871         LDKInit obj_conv;
16872         obj_conv.inner = (void*)(obj & (~1));
16873         obj_conv.is_owned = false;
16874         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
16875         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16876         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16877         CVec_u8Z_free(ret_var);
16878         return ret_arr;
16879 }
16880
16881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16882         LDKu8slice ser_ref;
16883         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16884         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16885         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
16886         *ret_conv = Init_read(ser_ref);
16887         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16888         return (long)ret_conv;
16889 }
16890
16891 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
16892         LDKOpenChannel obj_conv;
16893         obj_conv.inner = (void*)(obj & (~1));
16894         obj_conv.is_owned = false;
16895         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
16896         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16897         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16898         CVec_u8Z_free(ret_var);
16899         return ret_arr;
16900 }
16901
16902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16903         LDKu8slice ser_ref;
16904         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16905         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16906         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
16907         *ret_conv = OpenChannel_read(ser_ref);
16908         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16909         return (long)ret_conv;
16910 }
16911
16912 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
16913         LDKRevokeAndACK obj_conv;
16914         obj_conv.inner = (void*)(obj & (~1));
16915         obj_conv.is_owned = false;
16916         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
16917         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16918         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16919         CVec_u8Z_free(ret_var);
16920         return ret_arr;
16921 }
16922
16923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16924         LDKu8slice ser_ref;
16925         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16926         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16927         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
16928         *ret_conv = RevokeAndACK_read(ser_ref);
16929         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16930         return (long)ret_conv;
16931 }
16932
16933 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
16934         LDKShutdown obj_conv;
16935         obj_conv.inner = (void*)(obj & (~1));
16936         obj_conv.is_owned = false;
16937         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
16938         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16939         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16940         CVec_u8Z_free(ret_var);
16941         return ret_arr;
16942 }
16943
16944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16945         LDKu8slice ser_ref;
16946         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16947         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16948         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
16949         *ret_conv = Shutdown_read(ser_ref);
16950         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16951         return (long)ret_conv;
16952 }
16953
16954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
16955         LDKUpdateFailHTLC obj_conv;
16956         obj_conv.inner = (void*)(obj & (~1));
16957         obj_conv.is_owned = false;
16958         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
16959         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16960         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16961         CVec_u8Z_free(ret_var);
16962         return ret_arr;
16963 }
16964
16965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16966         LDKu8slice ser_ref;
16967         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16968         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16969         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
16970         *ret_conv = UpdateFailHTLC_read(ser_ref);
16971         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16972         return (long)ret_conv;
16973 }
16974
16975 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
16976         LDKUpdateFailMalformedHTLC obj_conv;
16977         obj_conv.inner = (void*)(obj & (~1));
16978         obj_conv.is_owned = false;
16979         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
16980         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16981         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16982         CVec_u8Z_free(ret_var);
16983         return ret_arr;
16984 }
16985
16986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16987         LDKu8slice ser_ref;
16988         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16989         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16990         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
16991         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
16992         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16993         return (long)ret_conv;
16994 }
16995
16996 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
16997         LDKUpdateFee obj_conv;
16998         obj_conv.inner = (void*)(obj & (~1));
16999         obj_conv.is_owned = false;
17000         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
17001         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17002         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17003         CVec_u8Z_free(ret_var);
17004         return ret_arr;
17005 }
17006
17007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17008         LDKu8slice ser_ref;
17009         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17010         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17011         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
17012         *ret_conv = UpdateFee_read(ser_ref);
17013         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17014         return (long)ret_conv;
17015 }
17016
17017 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
17018         LDKUpdateFulfillHTLC obj_conv;
17019         obj_conv.inner = (void*)(obj & (~1));
17020         obj_conv.is_owned = false;
17021         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
17022         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17023         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17024         CVec_u8Z_free(ret_var);
17025         return ret_arr;
17026 }
17027
17028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17029         LDKu8slice ser_ref;
17030         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17031         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17032         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
17033         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
17034         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17035         return (long)ret_conv;
17036 }
17037
17038 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
17039         LDKUpdateAddHTLC obj_conv;
17040         obj_conv.inner = (void*)(obj & (~1));
17041         obj_conv.is_owned = false;
17042         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
17043         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17044         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17045         CVec_u8Z_free(ret_var);
17046         return ret_arr;
17047 }
17048
17049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17050         LDKu8slice ser_ref;
17051         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17052         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17053         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
17054         *ret_conv = UpdateAddHTLC_read(ser_ref);
17055         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17056         return (long)ret_conv;
17057 }
17058
17059 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
17060         LDKPing obj_conv;
17061         obj_conv.inner = (void*)(obj & (~1));
17062         obj_conv.is_owned = false;
17063         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
17064         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17065         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17066         CVec_u8Z_free(ret_var);
17067         return ret_arr;
17068 }
17069
17070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17071         LDKu8slice ser_ref;
17072         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17073         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17074         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
17075         *ret_conv = Ping_read(ser_ref);
17076         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17077         return (long)ret_conv;
17078 }
17079
17080 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
17081         LDKPong obj_conv;
17082         obj_conv.inner = (void*)(obj & (~1));
17083         obj_conv.is_owned = false;
17084         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
17085         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17086         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17087         CVec_u8Z_free(ret_var);
17088         return ret_arr;
17089 }
17090
17091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17092         LDKu8slice ser_ref;
17093         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17094         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17095         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
17096         *ret_conv = Pong_read(ser_ref);
17097         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17098         return (long)ret_conv;
17099 }
17100
17101 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17102         LDKUnsignedChannelAnnouncement obj_conv;
17103         obj_conv.inner = (void*)(obj & (~1));
17104         obj_conv.is_owned = false;
17105         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
17106         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17107         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17108         CVec_u8Z_free(ret_var);
17109         return ret_arr;
17110 }
17111
17112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17113         LDKu8slice ser_ref;
17114         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17115         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17116         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
17117         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
17118         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17119         return (long)ret_conv;
17120 }
17121
17122 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17123         LDKChannelAnnouncement obj_conv;
17124         obj_conv.inner = (void*)(obj & (~1));
17125         obj_conv.is_owned = false;
17126         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
17127         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17128         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17129         CVec_u8Z_free(ret_var);
17130         return ret_arr;
17131 }
17132
17133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17134         LDKu8slice ser_ref;
17135         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17136         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17137         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
17138         *ret_conv = ChannelAnnouncement_read(ser_ref);
17139         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17140         return (long)ret_conv;
17141 }
17142
17143 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
17144         LDKUnsignedChannelUpdate obj_conv;
17145         obj_conv.inner = (void*)(obj & (~1));
17146         obj_conv.is_owned = false;
17147         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
17148         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17149         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17150         CVec_u8Z_free(ret_var);
17151         return ret_arr;
17152 }
17153
17154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17155         LDKu8slice ser_ref;
17156         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17157         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17158         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
17159         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
17160         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17161         return (long)ret_conv;
17162 }
17163
17164 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
17165         LDKChannelUpdate obj_conv;
17166         obj_conv.inner = (void*)(obj & (~1));
17167         obj_conv.is_owned = false;
17168         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
17169         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17170         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17171         CVec_u8Z_free(ret_var);
17172         return ret_arr;
17173 }
17174
17175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17176         LDKu8slice ser_ref;
17177         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17178         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17179         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
17180         *ret_conv = ChannelUpdate_read(ser_ref);
17181         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17182         return (long)ret_conv;
17183 }
17184
17185 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
17186         LDKErrorMessage obj_conv;
17187         obj_conv.inner = (void*)(obj & (~1));
17188         obj_conv.is_owned = false;
17189         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
17190         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17191         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17192         CVec_u8Z_free(ret_var);
17193         return ret_arr;
17194 }
17195
17196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17197         LDKu8slice ser_ref;
17198         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17199         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17200         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
17201         *ret_conv = ErrorMessage_read(ser_ref);
17202         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17203         return (long)ret_conv;
17204 }
17205
17206 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17207         LDKUnsignedNodeAnnouncement obj_conv;
17208         obj_conv.inner = (void*)(obj & (~1));
17209         obj_conv.is_owned = false;
17210         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
17211         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17212         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17213         CVec_u8Z_free(ret_var);
17214         return ret_arr;
17215 }
17216
17217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17218         LDKu8slice ser_ref;
17219         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17220         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17221         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
17222         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
17223         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17224         return (long)ret_conv;
17225 }
17226
17227 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17228         LDKNodeAnnouncement obj_conv;
17229         obj_conv.inner = (void*)(obj & (~1));
17230         obj_conv.is_owned = false;
17231         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
17232         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17233         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17234         CVec_u8Z_free(ret_var);
17235         return ret_arr;
17236 }
17237
17238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17239         LDKu8slice ser_ref;
17240         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17241         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17242         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
17243         *ret_conv = NodeAnnouncement_read(ser_ref);
17244         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17245         return (long)ret_conv;
17246 }
17247
17248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17249         LDKu8slice ser_ref;
17250         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17251         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17252         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
17253         *ret_conv = QueryShortChannelIds_read(ser_ref);
17254         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17255         return (long)ret_conv;
17256 }
17257
17258 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
17259         LDKQueryShortChannelIds obj_conv;
17260         obj_conv.inner = (void*)(obj & (~1));
17261         obj_conv.is_owned = false;
17262         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
17263         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17264         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17265         CVec_u8Z_free(ret_var);
17266         return ret_arr;
17267 }
17268
17269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17270         LDKu8slice ser_ref;
17271         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17272         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17273         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
17274         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
17275         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17276         return (long)ret_conv;
17277 }
17278
17279 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
17280         LDKReplyShortChannelIdsEnd obj_conv;
17281         obj_conv.inner = (void*)(obj & (~1));
17282         obj_conv.is_owned = false;
17283         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
17284         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17285         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17286         CVec_u8Z_free(ret_var);
17287         return ret_arr;
17288 }
17289
17290 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
17291         LDKQueryChannelRange this_arg_conv;
17292         this_arg_conv.inner = (void*)(this_arg & (~1));
17293         this_arg_conv.is_owned = false;
17294         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
17295         return ret_val;
17296 }
17297
17298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17299         LDKu8slice ser_ref;
17300         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17301         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17302         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
17303         *ret_conv = QueryChannelRange_read(ser_ref);
17304         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17305         return (long)ret_conv;
17306 }
17307
17308 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
17309         LDKQueryChannelRange obj_conv;
17310         obj_conv.inner = (void*)(obj & (~1));
17311         obj_conv.is_owned = false;
17312         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
17313         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17314         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17315         CVec_u8Z_free(ret_var);
17316         return ret_arr;
17317 }
17318
17319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17320         LDKu8slice ser_ref;
17321         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17322         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17323         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
17324         *ret_conv = ReplyChannelRange_read(ser_ref);
17325         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17326         return (long)ret_conv;
17327 }
17328
17329 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
17330         LDKReplyChannelRange obj_conv;
17331         obj_conv.inner = (void*)(obj & (~1));
17332         obj_conv.is_owned = false;
17333         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
17334         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17335         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17336         CVec_u8Z_free(ret_var);
17337         return ret_arr;
17338 }
17339
17340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17341         LDKu8slice ser_ref;
17342         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17343         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17344         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
17345         *ret_conv = GossipTimestampFilter_read(ser_ref);
17346         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17347         return (long)ret_conv;
17348 }
17349
17350 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
17351         LDKGossipTimestampFilter obj_conv;
17352         obj_conv.inner = (void*)(obj & (~1));
17353         obj_conv.is_owned = false;
17354         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
17355         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17356         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17357         CVec_u8Z_free(ret_var);
17358         return ret_arr;
17359 }
17360
17361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17362         LDKIgnoringMessageHandler this_obj_conv;
17363         this_obj_conv.inner = (void*)(this_obj & (~1));
17364         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17365         IgnoringMessageHandler_free(this_obj_conv);
17366 }
17367
17368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
17369         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
17370         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17371         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17372         long ret_ref = (long)ret_var.inner;
17373         if (ret_var.is_owned) {
17374                 ret_ref |= 1;
17375         }
17376         return ret_ref;
17377 }
17378
17379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17380         LDKIgnoringMessageHandler this_arg_conv;
17381         this_arg_conv.inner = (void*)(this_arg & (~1));
17382         this_arg_conv.is_owned = false;
17383         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
17384         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
17385         return (long)ret;
17386 }
17387
17388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
17389         LDKIgnoringMessageHandler this_arg_conv;
17390         this_arg_conv.inner = (void*)(this_arg & (~1));
17391         this_arg_conv.is_owned = false;
17392         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
17393         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
17394         return (long)ret;
17395 }
17396
17397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17398         LDKErroringMessageHandler this_obj_conv;
17399         this_obj_conv.inner = (void*)(this_obj & (~1));
17400         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17401         ErroringMessageHandler_free(this_obj_conv);
17402 }
17403
17404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
17405         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
17406         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17407         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17408         long ret_ref = (long)ret_var.inner;
17409         if (ret_var.is_owned) {
17410                 ret_ref |= 1;
17411         }
17412         return ret_ref;
17413 }
17414
17415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17416         LDKErroringMessageHandler this_arg_conv;
17417         this_arg_conv.inner = (void*)(this_arg & (~1));
17418         this_arg_conv.is_owned = false;
17419         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
17420         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
17421         return (long)ret;
17422 }
17423
17424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
17425         LDKErroringMessageHandler this_arg_conv;
17426         this_arg_conv.inner = (void*)(this_arg & (~1));
17427         this_arg_conv.is_owned = false;
17428         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
17429         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
17430         return (long)ret;
17431 }
17432
17433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17434         LDKMessageHandler this_obj_conv;
17435         this_obj_conv.inner = (void*)(this_obj & (~1));
17436         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17437         MessageHandler_free(this_obj_conv);
17438 }
17439
17440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
17441         LDKMessageHandler this_ptr_conv;
17442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17443         this_ptr_conv.is_owned = false;
17444         long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
17445         return ret_ret;
17446 }
17447
17448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17449         LDKMessageHandler this_ptr_conv;
17450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17451         this_ptr_conv.is_owned = false;
17452         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
17453         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
17454                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17455                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
17456         }
17457         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
17458 }
17459
17460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
17461         LDKMessageHandler this_ptr_conv;
17462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17463         this_ptr_conv.is_owned = false;
17464         long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
17465         return ret_ret;
17466 }
17467
17468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17469         LDKMessageHandler this_ptr_conv;
17470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17471         this_ptr_conv.is_owned = false;
17472         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
17473         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
17474                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17475                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
17476         }
17477         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
17478 }
17479
17480 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) {
17481         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
17482         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
17483                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17484                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
17485         }
17486         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
17487         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
17488                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17489                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
17490         }
17491         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
17492         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17493         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17494         long ret_ref = (long)ret_var.inner;
17495         if (ret_var.is_owned) {
17496                 ret_ref |= 1;
17497         }
17498         return ret_ref;
17499 }
17500
17501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17502         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
17503         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
17504         *ret = SocketDescriptor_clone(orig_conv);
17505         return (long)ret;
17506 }
17507
17508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17509         if ((this_ptr & 1) != 0) return;
17510         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
17511         FREE((void*)this_ptr);
17512         SocketDescriptor_free(this_ptr_conv);
17513 }
17514
17515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17516         LDKPeerHandleError this_obj_conv;
17517         this_obj_conv.inner = (void*)(this_obj & (~1));
17518         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17519         PeerHandleError_free(this_obj_conv);
17520 }
17521
17522 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
17523         LDKPeerHandleError this_ptr_conv;
17524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17525         this_ptr_conv.is_owned = false;
17526         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
17527         return ret_val;
17528 }
17529
17530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
17531         LDKPeerHandleError this_ptr_conv;
17532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17533         this_ptr_conv.is_owned = false;
17534         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
17535 }
17536
17537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
17538         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
17539         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17540         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17541         long ret_ref = (long)ret_var.inner;
17542         if (ret_var.is_owned) {
17543                 ret_ref |= 1;
17544         }
17545         return ret_ref;
17546 }
17547
17548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17549         LDKPeerHandleError orig_conv;
17550         orig_conv.inner = (void*)(orig & (~1));
17551         orig_conv.is_owned = false;
17552         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
17553         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17554         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17555         long ret_ref = (long)ret_var.inner;
17556         if (ret_var.is_owned) {
17557                 ret_ref |= 1;
17558         }
17559         return ret_ref;
17560 }
17561
17562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17563         LDKPeerManager this_obj_conv;
17564         this_obj_conv.inner = (void*)(this_obj & (~1));
17565         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17566         PeerManager_free(this_obj_conv);
17567 }
17568
17569 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) {
17570         LDKMessageHandler message_handler_conv;
17571         message_handler_conv.inner = (void*)(message_handler & (~1));
17572         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
17573         // Warning: we need a move here but no clone is available for LDKMessageHandler
17574         LDKSecretKey our_node_secret_ref;
17575         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
17576         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
17577         unsigned char ephemeral_random_data_arr[32];
17578         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
17579         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
17580         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
17581         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17582         if (logger_conv.free == LDKLogger_JCalls_free) {
17583                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17584                 LDKLogger_JCalls_clone(logger_conv.this_arg);
17585         }
17586         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
17587         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17588         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17589         long ret_ref = (long)ret_var.inner;
17590         if (ret_var.is_owned) {
17591                 ret_ref |= 1;
17592         }
17593         return ret_ref;
17594 }
17595
17596 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
17597         LDKPeerManager this_arg_conv;
17598         this_arg_conv.inner = (void*)(this_arg & (~1));
17599         this_arg_conv.is_owned = false;
17600         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
17601         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
17602         ;
17603         for (size_t i = 0; i < ret_var.datalen; i++) {
17604                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
17605                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
17606                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
17607         }
17608         FREE(ret_var.data);
17609         return ret_arr;
17610 }
17611
17612 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) {
17613         LDKPeerManager this_arg_conv;
17614         this_arg_conv.inner = (void*)(this_arg & (~1));
17615         this_arg_conv.is_owned = false;
17616         LDKPublicKey their_node_id_ref;
17617         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
17618         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
17619         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
17620         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
17621                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17622                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
17623         }
17624         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
17625         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
17626         return (long)ret_conv;
17627 }
17628
17629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
17630         LDKPeerManager this_arg_conv;
17631         this_arg_conv.inner = (void*)(this_arg & (~1));
17632         this_arg_conv.is_owned = false;
17633         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
17634         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
17635                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17636                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
17637         }
17638         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
17639         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
17640         return (long)ret_conv;
17641 }
17642
17643 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) {
17644         LDKPeerManager this_arg_conv;
17645         this_arg_conv.inner = (void*)(this_arg & (~1));
17646         this_arg_conv.is_owned = false;
17647         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
17648         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
17649         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
17650         return (long)ret_conv;
17651 }
17652
17653 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) {
17654         LDKPeerManager this_arg_conv;
17655         this_arg_conv.inner = (void*)(this_arg & (~1));
17656         this_arg_conv.is_owned = false;
17657         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
17658         LDKu8slice data_ref;
17659         data_ref.datalen = (*env)->GetArrayLength(env, data);
17660         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
17661         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
17662         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
17663         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
17664         return (long)ret_conv;
17665 }
17666
17667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
17668         LDKPeerManager this_arg_conv;
17669         this_arg_conv.inner = (void*)(this_arg & (~1));
17670         this_arg_conv.is_owned = false;
17671         PeerManager_process_events(&this_arg_conv);
17672 }
17673
17674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
17675         LDKPeerManager this_arg_conv;
17676         this_arg_conv.inner = (void*)(this_arg & (~1));
17677         this_arg_conv.is_owned = false;
17678         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
17679         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
17680 }
17681
17682 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) {
17683         LDKPeerManager this_arg_conv;
17684         this_arg_conv.inner = (void*)(this_arg & (~1));
17685         this_arg_conv.is_owned = false;
17686         LDKPublicKey node_id_ref;
17687         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17688         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17689         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
17690 }
17691
17692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
17693         LDKPeerManager this_arg_conv;
17694         this_arg_conv.inner = (void*)(this_arg & (~1));
17695         this_arg_conv.is_owned = false;
17696         PeerManager_timer_tick_occurred(&this_arg_conv);
17697 }
17698
17699 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
17700         unsigned char commitment_seed_arr[32];
17701         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
17702         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
17703         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
17704         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17705         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
17706         return ret_arr;
17707 }
17708
17709 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) {
17710         LDKPublicKey per_commitment_point_ref;
17711         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
17712         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17713         unsigned char base_secret_arr[32];
17714         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
17715         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
17716         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
17717         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
17718         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
17719         return (long)ret_conv;
17720 }
17721
17722 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) {
17723         LDKPublicKey per_commitment_point_ref;
17724         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
17725         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17726         LDKPublicKey base_point_ref;
17727         CHECK((*env)->GetArrayLength(env, base_point) == 33);
17728         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
17729         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
17730         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
17731         return (long)ret_conv;
17732 }
17733
17734 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) {
17735         unsigned char per_commitment_secret_arr[32];
17736         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
17737         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
17738         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
17739         unsigned char countersignatory_revocation_base_secret_arr[32];
17740         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
17741         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
17742         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
17743         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
17744         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
17745         return (long)ret_conv;
17746 }
17747
17748 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) {
17749         LDKPublicKey per_commitment_point_ref;
17750         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
17751         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17752         LDKPublicKey countersignatory_revocation_base_point_ref;
17753         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
17754         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
17755         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
17756         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
17757         return (long)ret_conv;
17758 }
17759
17760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17761         LDKTxCreationKeys this_obj_conv;
17762         this_obj_conv.inner = (void*)(this_obj & (~1));
17763         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17764         TxCreationKeys_free(this_obj_conv);
17765 }
17766
17767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17768         LDKTxCreationKeys this_ptr_conv;
17769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17770         this_ptr_conv.is_owned = false;
17771         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17772         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
17773         return ret_arr;
17774 }
17775
17776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17777         LDKTxCreationKeys this_ptr_conv;
17778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17779         this_ptr_conv.is_owned = false;
17780         LDKPublicKey val_ref;
17781         CHECK((*env)->GetArrayLength(env, val) == 33);
17782         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17783         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
17784 }
17785
17786 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17787         LDKTxCreationKeys this_ptr_conv;
17788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17789         this_ptr_conv.is_owned = false;
17790         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17791         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
17792         return ret_arr;
17793 }
17794
17795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17796         LDKTxCreationKeys this_ptr_conv;
17797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17798         this_ptr_conv.is_owned = false;
17799         LDKPublicKey val_ref;
17800         CHECK((*env)->GetArrayLength(env, val) == 33);
17801         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17802         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
17803 }
17804
17805 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17806         LDKTxCreationKeys this_ptr_conv;
17807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17808         this_ptr_conv.is_owned = false;
17809         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17810         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
17811         return ret_arr;
17812 }
17813
17814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17815         LDKTxCreationKeys this_ptr_conv;
17816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17817         this_ptr_conv.is_owned = false;
17818         LDKPublicKey val_ref;
17819         CHECK((*env)->GetArrayLength(env, val) == 33);
17820         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17821         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
17822 }
17823
17824 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17825         LDKTxCreationKeys this_ptr_conv;
17826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17827         this_ptr_conv.is_owned = false;
17828         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17829         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
17830         return ret_arr;
17831 }
17832
17833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17834         LDKTxCreationKeys this_ptr_conv;
17835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17836         this_ptr_conv.is_owned = false;
17837         LDKPublicKey val_ref;
17838         CHECK((*env)->GetArrayLength(env, val) == 33);
17839         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17840         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
17841 }
17842
17843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17844         LDKTxCreationKeys this_ptr_conv;
17845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17846         this_ptr_conv.is_owned = false;
17847         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17848         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
17849         return ret_arr;
17850 }
17851
17852 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) {
17853         LDKTxCreationKeys this_ptr_conv;
17854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17855         this_ptr_conv.is_owned = false;
17856         LDKPublicKey val_ref;
17857         CHECK((*env)->GetArrayLength(env, val) == 33);
17858         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17859         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
17860 }
17861
17862 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) {
17863         LDKPublicKey per_commitment_point_arg_ref;
17864         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
17865         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
17866         LDKPublicKey revocation_key_arg_ref;
17867         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
17868         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
17869         LDKPublicKey broadcaster_htlc_key_arg_ref;
17870         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
17871         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
17872         LDKPublicKey countersignatory_htlc_key_arg_ref;
17873         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
17874         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
17875         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
17876         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
17877         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
17878         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);
17879         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17880         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17881         long ret_ref = (long)ret_var.inner;
17882         if (ret_var.is_owned) {
17883                 ret_ref |= 1;
17884         }
17885         return ret_ref;
17886 }
17887
17888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17889         LDKTxCreationKeys orig_conv;
17890         orig_conv.inner = (void*)(orig & (~1));
17891         orig_conv.is_owned = false;
17892         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
17893         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17894         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17895         long ret_ref = (long)ret_var.inner;
17896         if (ret_var.is_owned) {
17897                 ret_ref |= 1;
17898         }
17899         return ret_ref;
17900 }
17901
17902 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
17903         LDKTxCreationKeys obj_conv;
17904         obj_conv.inner = (void*)(obj & (~1));
17905         obj_conv.is_owned = false;
17906         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
17907         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17908         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17909         CVec_u8Z_free(ret_var);
17910         return ret_arr;
17911 }
17912
17913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17914         LDKu8slice ser_ref;
17915         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17916         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17917         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
17918         *ret_conv = TxCreationKeys_read(ser_ref);
17919         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17920         return (long)ret_conv;
17921 }
17922
17923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17924         LDKChannelPublicKeys this_obj_conv;
17925         this_obj_conv.inner = (void*)(this_obj & (~1));
17926         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17927         ChannelPublicKeys_free(this_obj_conv);
17928 }
17929
17930 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17931         LDKChannelPublicKeys this_ptr_conv;
17932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17933         this_ptr_conv.is_owned = false;
17934         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17935         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
17936         return ret_arr;
17937 }
17938
17939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17940         LDKChannelPublicKeys this_ptr_conv;
17941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17942         this_ptr_conv.is_owned = false;
17943         LDKPublicKey val_ref;
17944         CHECK((*env)->GetArrayLength(env, val) == 33);
17945         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17946         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
17947 }
17948
17949 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17950         LDKChannelPublicKeys this_ptr_conv;
17951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17952         this_ptr_conv.is_owned = false;
17953         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17954         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
17955         return ret_arr;
17956 }
17957
17958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17959         LDKChannelPublicKeys this_ptr_conv;
17960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17961         this_ptr_conv.is_owned = false;
17962         LDKPublicKey val_ref;
17963         CHECK((*env)->GetArrayLength(env, val) == 33);
17964         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17965         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
17966 }
17967
17968 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17969         LDKChannelPublicKeys this_ptr_conv;
17970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17971         this_ptr_conv.is_owned = false;
17972         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17973         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
17974         return ret_arr;
17975 }
17976
17977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17978         LDKChannelPublicKeys this_ptr_conv;
17979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17980         this_ptr_conv.is_owned = false;
17981         LDKPublicKey val_ref;
17982         CHECK((*env)->GetArrayLength(env, val) == 33);
17983         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17984         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
17985 }
17986
17987 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17988         LDKChannelPublicKeys this_ptr_conv;
17989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17990         this_ptr_conv.is_owned = false;
17991         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17992         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
17993         return ret_arr;
17994 }
17995
17996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17997         LDKChannelPublicKeys this_ptr_conv;
17998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17999         this_ptr_conv.is_owned = false;
18000         LDKPublicKey val_ref;
18001         CHECK((*env)->GetArrayLength(env, val) == 33);
18002         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18003         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
18004 }
18005
18006 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18007         LDKChannelPublicKeys this_ptr_conv;
18008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18009         this_ptr_conv.is_owned = false;
18010         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18011         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
18012         return ret_arr;
18013 }
18014
18015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18016         LDKChannelPublicKeys this_ptr_conv;
18017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18018         this_ptr_conv.is_owned = false;
18019         LDKPublicKey val_ref;
18020         CHECK((*env)->GetArrayLength(env, val) == 33);
18021         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18022         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
18023 }
18024
18025 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) {
18026         LDKPublicKey funding_pubkey_arg_ref;
18027         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
18028         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
18029         LDKPublicKey revocation_basepoint_arg_ref;
18030         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
18031         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
18032         LDKPublicKey payment_point_arg_ref;
18033         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
18034         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
18035         LDKPublicKey delayed_payment_basepoint_arg_ref;
18036         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
18037         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
18038         LDKPublicKey htlc_basepoint_arg_ref;
18039         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
18040         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
18041         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);
18042         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18043         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18044         long ret_ref = (long)ret_var.inner;
18045         if (ret_var.is_owned) {
18046                 ret_ref |= 1;
18047         }
18048         return ret_ref;
18049 }
18050
18051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18052         LDKChannelPublicKeys orig_conv;
18053         orig_conv.inner = (void*)(orig & (~1));
18054         orig_conv.is_owned = false;
18055         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
18056         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18057         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18058         long ret_ref = (long)ret_var.inner;
18059         if (ret_var.is_owned) {
18060                 ret_ref |= 1;
18061         }
18062         return ret_ref;
18063 }
18064
18065 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
18066         LDKChannelPublicKeys obj_conv;
18067         obj_conv.inner = (void*)(obj & (~1));
18068         obj_conv.is_owned = false;
18069         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
18070         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18071         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18072         CVec_u8Z_free(ret_var);
18073         return ret_arr;
18074 }
18075
18076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18077         LDKu8slice ser_ref;
18078         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18079         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18080         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
18081         *ret_conv = ChannelPublicKeys_read(ser_ref);
18082         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18083         return (long)ret_conv;
18084 }
18085
18086 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) {
18087         LDKPublicKey per_commitment_point_ref;
18088         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
18089         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
18090         LDKPublicKey broadcaster_delayed_payment_base_ref;
18091         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
18092         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
18093         LDKPublicKey broadcaster_htlc_base_ref;
18094         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
18095         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
18096         LDKPublicKey countersignatory_revocation_base_ref;
18097         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
18098         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
18099         LDKPublicKey countersignatory_htlc_base_ref;
18100         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
18101         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
18102         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
18103         *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);
18104         return (long)ret_conv;
18105 }
18106
18107 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) {
18108         LDKPublicKey per_commitment_point_ref;
18109         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
18110         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
18111         LDKChannelPublicKeys broadcaster_keys_conv;
18112         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
18113         broadcaster_keys_conv.is_owned = false;
18114         LDKChannelPublicKeys countersignatory_keys_conv;
18115         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
18116         countersignatory_keys_conv.is_owned = false;
18117         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
18118         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
18119         return (long)ret_conv;
18120 }
18121
18122 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) {
18123         LDKPublicKey revocation_key_ref;
18124         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
18125         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
18126         LDKPublicKey broadcaster_delayed_payment_key_ref;
18127         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
18128         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
18129         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
18130         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18131         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18132         CVec_u8Z_free(ret_var);
18133         return ret_arr;
18134 }
18135
18136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18137         LDKHTLCOutputInCommitment this_obj_conv;
18138         this_obj_conv.inner = (void*)(this_obj & (~1));
18139         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18140         HTLCOutputInCommitment_free(this_obj_conv);
18141 }
18142
18143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
18144         LDKHTLCOutputInCommitment this_ptr_conv;
18145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18146         this_ptr_conv.is_owned = false;
18147         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
18148         return ret_val;
18149 }
18150
18151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18152         LDKHTLCOutputInCommitment this_ptr_conv;
18153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18154         this_ptr_conv.is_owned = false;
18155         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
18156 }
18157
18158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18159         LDKHTLCOutputInCommitment this_ptr_conv;
18160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18161         this_ptr_conv.is_owned = false;
18162         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
18163         return ret_val;
18164 }
18165
18166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18167         LDKHTLCOutputInCommitment this_ptr_conv;
18168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18169         this_ptr_conv.is_owned = false;
18170         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
18171 }
18172
18173 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
18174         LDKHTLCOutputInCommitment this_ptr_conv;
18175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18176         this_ptr_conv.is_owned = false;
18177         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
18178         return ret_val;
18179 }
18180
18181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18182         LDKHTLCOutputInCommitment this_ptr_conv;
18183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18184         this_ptr_conv.is_owned = false;
18185         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
18186 }
18187
18188 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18189         LDKHTLCOutputInCommitment this_ptr_conv;
18190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18191         this_ptr_conv.is_owned = false;
18192         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18193         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
18194         return ret_arr;
18195 }
18196
18197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18198         LDKHTLCOutputInCommitment this_ptr_conv;
18199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18200         this_ptr_conv.is_owned = false;
18201         LDKThirtyTwoBytes val_ref;
18202         CHECK((*env)->GetArrayLength(env, val) == 32);
18203         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18204         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
18205 }
18206
18207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
18208         LDKHTLCOutputInCommitment this_ptr_conv;
18209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18210         this_ptr_conv.is_owned = false;
18211         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
18212         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
18213         long ret_ref = (long)ret_copy;
18214         return ret_ref;
18215 }
18216
18217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18218         LDKHTLCOutputInCommitment this_ptr_conv;
18219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18220         this_ptr_conv.is_owned = false;
18221         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
18222         FREE((void*)val);
18223         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
18224 }
18225
18226 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) {
18227         LDKThirtyTwoBytes payment_hash_arg_ref;
18228         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
18229         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
18230         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
18231         FREE((void*)transaction_output_index_arg);
18232         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
18233         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18234         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18235         long ret_ref = (long)ret_var.inner;
18236         if (ret_var.is_owned) {
18237                 ret_ref |= 1;
18238         }
18239         return ret_ref;
18240 }
18241
18242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18243         LDKHTLCOutputInCommitment orig_conv;
18244         orig_conv.inner = (void*)(orig & (~1));
18245         orig_conv.is_owned = false;
18246         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
18247         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18248         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18249         long ret_ref = (long)ret_var.inner;
18250         if (ret_var.is_owned) {
18251                 ret_ref |= 1;
18252         }
18253         return ret_ref;
18254 }
18255
18256 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
18257         LDKHTLCOutputInCommitment obj_conv;
18258         obj_conv.inner = (void*)(obj & (~1));
18259         obj_conv.is_owned = false;
18260         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
18261         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18262         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18263         CVec_u8Z_free(ret_var);
18264         return ret_arr;
18265 }
18266
18267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18268         LDKu8slice ser_ref;
18269         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18270         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18271         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
18272         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
18273         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18274         return (long)ret_conv;
18275 }
18276
18277 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
18278         LDKHTLCOutputInCommitment htlc_conv;
18279         htlc_conv.inner = (void*)(htlc & (~1));
18280         htlc_conv.is_owned = false;
18281         LDKTxCreationKeys keys_conv;
18282         keys_conv.inner = (void*)(keys & (~1));
18283         keys_conv.is_owned = false;
18284         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
18285         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18286         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18287         CVec_u8Z_free(ret_var);
18288         return ret_arr;
18289 }
18290
18291 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
18292         LDKPublicKey broadcaster_ref;
18293         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
18294         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
18295         LDKPublicKey countersignatory_ref;
18296         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
18297         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
18298         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
18299         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18300         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18301         CVec_u8Z_free(ret_var);
18302         return ret_arr;
18303 }
18304
18305 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) {
18306         unsigned char prev_hash_arr[32];
18307         CHECK((*env)->GetArrayLength(env, prev_hash) == 32);
18308         (*env)->GetByteArrayRegion(env, prev_hash, 0, 32, prev_hash_arr);
18309         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
18310         LDKHTLCOutputInCommitment htlc_conv;
18311         htlc_conv.inner = (void*)(htlc & (~1));
18312         htlc_conv.is_owned = false;
18313         LDKPublicKey broadcaster_delayed_payment_key_ref;
18314         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
18315         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
18316         LDKPublicKey revocation_key_ref;
18317         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
18318         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
18319         LDKTransaction ret_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
18320         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18321         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18322         Transaction_free(ret_var);
18323         return ret_arr;
18324 }
18325
18326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18327         LDKChannelTransactionParameters this_obj_conv;
18328         this_obj_conv.inner = (void*)(this_obj & (~1));
18329         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18330         ChannelTransactionParameters_free(this_obj_conv);
18331 }
18332
18333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
18334         LDKChannelTransactionParameters this_ptr_conv;
18335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18336         this_ptr_conv.is_owned = false;
18337         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
18338         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18339         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18340         long ret_ref = (long)ret_var.inner;
18341         if (ret_var.is_owned) {
18342                 ret_ref |= 1;
18343         }
18344         return ret_ref;
18345 }
18346
18347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18348         LDKChannelTransactionParameters this_ptr_conv;
18349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18350         this_ptr_conv.is_owned = false;
18351         LDKChannelPublicKeys val_conv;
18352         val_conv.inner = (void*)(val & (~1));
18353         val_conv.is_owned = (val & 1) || (val == 0);
18354         val_conv = ChannelPublicKeys_clone(&val_conv);
18355         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
18356 }
18357
18358 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
18359         LDKChannelTransactionParameters this_ptr_conv;
18360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18361         this_ptr_conv.is_owned = false;
18362         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
18363         return ret_val;
18364 }
18365
18366 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) {
18367         LDKChannelTransactionParameters this_ptr_conv;
18368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18369         this_ptr_conv.is_owned = false;
18370         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
18371 }
18372
18373 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
18374         LDKChannelTransactionParameters this_ptr_conv;
18375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18376         this_ptr_conv.is_owned = false;
18377         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
18378         return ret_val;
18379 }
18380
18381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18382         LDKChannelTransactionParameters this_ptr_conv;
18383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18384         this_ptr_conv.is_owned = false;
18385         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
18386 }
18387
18388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
18389         LDKChannelTransactionParameters this_ptr_conv;
18390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18391         this_ptr_conv.is_owned = false;
18392         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
18393         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18394         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18395         long ret_ref = (long)ret_var.inner;
18396         if (ret_var.is_owned) {
18397                 ret_ref |= 1;
18398         }
18399         return ret_ref;
18400 }
18401
18402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18403         LDKChannelTransactionParameters this_ptr_conv;
18404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18405         this_ptr_conv.is_owned = false;
18406         LDKCounterpartyChannelTransactionParameters val_conv;
18407         val_conv.inner = (void*)(val & (~1));
18408         val_conv.is_owned = (val & 1) || (val == 0);
18409         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
18410         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
18411 }
18412
18413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18414         LDKChannelTransactionParameters this_ptr_conv;
18415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18416         this_ptr_conv.is_owned = false;
18417         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
18418         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18419         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18420         long ret_ref = (long)ret_var.inner;
18421         if (ret_var.is_owned) {
18422                 ret_ref |= 1;
18423         }
18424         return ret_ref;
18425 }
18426
18427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18428         LDKChannelTransactionParameters this_ptr_conv;
18429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18430         this_ptr_conv.is_owned = false;
18431         LDKOutPoint val_conv;
18432         val_conv.inner = (void*)(val & (~1));
18433         val_conv.is_owned = (val & 1) || (val == 0);
18434         val_conv = OutPoint_clone(&val_conv);
18435         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
18436 }
18437
18438 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) {
18439         LDKChannelPublicKeys holder_pubkeys_arg_conv;
18440         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
18441         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
18442         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
18443         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
18444         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
18445         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
18446         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
18447         LDKOutPoint funding_outpoint_arg_conv;
18448         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
18449         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
18450         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
18451         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);
18452         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18453         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18454         long ret_ref = (long)ret_var.inner;
18455         if (ret_var.is_owned) {
18456                 ret_ref |= 1;
18457         }
18458         return ret_ref;
18459 }
18460
18461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18462         LDKChannelTransactionParameters orig_conv;
18463         orig_conv.inner = (void*)(orig & (~1));
18464         orig_conv.is_owned = false;
18465         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
18466         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18467         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18468         long ret_ref = (long)ret_var.inner;
18469         if (ret_var.is_owned) {
18470                 ret_ref |= 1;
18471         }
18472         return ret_ref;
18473 }
18474
18475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18476         LDKCounterpartyChannelTransactionParameters this_obj_conv;
18477         this_obj_conv.inner = (void*)(this_obj & (~1));
18478         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18479         CounterpartyChannelTransactionParameters_free(this_obj_conv);
18480 }
18481
18482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
18483         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
18484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18485         this_ptr_conv.is_owned = false;
18486         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
18487         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18488         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18489         long ret_ref = (long)ret_var.inner;
18490         if (ret_var.is_owned) {
18491                 ret_ref |= 1;
18492         }
18493         return ret_ref;
18494 }
18495
18496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18497         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
18498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18499         this_ptr_conv.is_owned = false;
18500         LDKChannelPublicKeys val_conv;
18501         val_conv.inner = (void*)(val & (~1));
18502         val_conv.is_owned = (val & 1) || (val == 0);
18503         val_conv = ChannelPublicKeys_clone(&val_conv);
18504         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
18505 }
18506
18507 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
18508         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
18509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18510         this_ptr_conv.is_owned = false;
18511         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
18512         return ret_val;
18513 }
18514
18515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18516         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
18517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18518         this_ptr_conv.is_owned = false;
18519         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
18520 }
18521
18522 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) {
18523         LDKChannelPublicKeys pubkeys_arg_conv;
18524         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
18525         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
18526         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
18527         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
18528         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18529         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18530         long ret_ref = (long)ret_var.inner;
18531         if (ret_var.is_owned) {
18532                 ret_ref |= 1;
18533         }
18534         return ret_ref;
18535 }
18536
18537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18538         LDKCounterpartyChannelTransactionParameters orig_conv;
18539         orig_conv.inner = (void*)(orig & (~1));
18540         orig_conv.is_owned = false;
18541         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
18542         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18543         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18544         long ret_ref = (long)ret_var.inner;
18545         if (ret_var.is_owned) {
18546                 ret_ref |= 1;
18547         }
18548         return ret_ref;
18549 }
18550
18551 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
18552         LDKChannelTransactionParameters this_arg_conv;
18553         this_arg_conv.inner = (void*)(this_arg & (~1));
18554         this_arg_conv.is_owned = false;
18555         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
18556         return ret_val;
18557 }
18558
18559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(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         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
18564         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18565         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18566         long ret_ref = (long)ret_var.inner;
18567         if (ret_var.is_owned) {
18568                 ret_ref |= 1;
18569         }
18570         return ret_ref;
18571 }
18572
18573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
18574         LDKChannelTransactionParameters this_arg_conv;
18575         this_arg_conv.inner = (void*)(this_arg & (~1));
18576         this_arg_conv.is_owned = false;
18577         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
18578         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18579         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18580         long ret_ref = (long)ret_var.inner;
18581         if (ret_var.is_owned) {
18582                 ret_ref |= 1;
18583         }
18584         return ret_ref;
18585 }
18586
18587 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
18588         LDKCounterpartyChannelTransactionParameters obj_conv;
18589         obj_conv.inner = (void*)(obj & (~1));
18590         obj_conv.is_owned = false;
18591         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
18592         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18593         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18594         CVec_u8Z_free(ret_var);
18595         return ret_arr;
18596 }
18597
18598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18599         LDKu8slice ser_ref;
18600         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18601         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18602         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
18603         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
18604         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18605         return (long)ret_conv;
18606 }
18607
18608 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
18609         LDKChannelTransactionParameters obj_conv;
18610         obj_conv.inner = (void*)(obj & (~1));
18611         obj_conv.is_owned = false;
18612         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
18613         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18614         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18615         CVec_u8Z_free(ret_var);
18616         return ret_arr;
18617 }
18618
18619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18620         LDKu8slice ser_ref;
18621         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18622         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18623         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
18624         *ret_conv = ChannelTransactionParameters_read(ser_ref);
18625         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18626         return (long)ret_conv;
18627 }
18628
18629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18630         LDKDirectedChannelTransactionParameters this_obj_conv;
18631         this_obj_conv.inner = (void*)(this_obj & (~1));
18632         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18633         DirectedChannelTransactionParameters_free(this_obj_conv);
18634 }
18635
18636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
18637         LDKDirectedChannelTransactionParameters this_arg_conv;
18638         this_arg_conv.inner = (void*)(this_arg & (~1));
18639         this_arg_conv.is_owned = false;
18640         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
18641         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18642         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18643         long ret_ref = (long)ret_var.inner;
18644         if (ret_var.is_owned) {
18645                 ret_ref |= 1;
18646         }
18647         return ret_ref;
18648 }
18649
18650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
18651         LDKDirectedChannelTransactionParameters this_arg_conv;
18652         this_arg_conv.inner = (void*)(this_arg & (~1));
18653         this_arg_conv.is_owned = false;
18654         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
18655         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18656         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18657         long ret_ref = (long)ret_var.inner;
18658         if (ret_var.is_owned) {
18659                 ret_ref |= 1;
18660         }
18661         return ret_ref;
18662 }
18663
18664 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
18665         LDKDirectedChannelTransactionParameters this_arg_conv;
18666         this_arg_conv.inner = (void*)(this_arg & (~1));
18667         this_arg_conv.is_owned = false;
18668         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
18669         return ret_val;
18670 }
18671
18672 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(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         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
18677         return ret_val;
18678 }
18679
18680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(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         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
18685         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18686         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18687         long ret_ref = (long)ret_var.inner;
18688         if (ret_var.is_owned) {
18689                 ret_ref |= 1;
18690         }
18691         return ret_ref;
18692 }
18693
18694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18695         LDKHolderCommitmentTransaction this_obj_conv;
18696         this_obj_conv.inner = (void*)(this_obj & (~1));
18697         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18698         HolderCommitmentTransaction_free(this_obj_conv);
18699 }
18700
18701 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
18702         LDKHolderCommitmentTransaction this_ptr_conv;
18703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18704         this_ptr_conv.is_owned = false;
18705         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18706         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
18707         return ret_arr;
18708 }
18709
18710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18711         LDKHolderCommitmentTransaction this_ptr_conv;
18712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18713         this_ptr_conv.is_owned = false;
18714         LDKSignature val_ref;
18715         CHECK((*env)->GetArrayLength(env, val) == 64);
18716         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18717         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
18718 }
18719
18720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
18721         LDKHolderCommitmentTransaction this_ptr_conv;
18722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18723         this_ptr_conv.is_owned = false;
18724         LDKCVec_SignatureZ val_constr;
18725         val_constr.datalen = (*env)->GetArrayLength(env, val);
18726         if (val_constr.datalen > 0)
18727                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18728         else
18729                 val_constr.data = NULL;
18730         for (size_t i = 0; i < val_constr.datalen; i++) {
18731                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
18732                 LDKSignature val_conv_8_ref;
18733                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
18734                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
18735                 val_constr.data[i] = val_conv_8_ref;
18736         }
18737         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
18738 }
18739
18740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18741         LDKHolderCommitmentTransaction orig_conv;
18742         orig_conv.inner = (void*)(orig & (~1));
18743         orig_conv.is_owned = false;
18744         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
18745         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18746         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18747         long ret_ref = (long)ret_var.inner;
18748         if (ret_var.is_owned) {
18749                 ret_ref |= 1;
18750         }
18751         return ret_ref;
18752 }
18753
18754 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
18755         LDKHolderCommitmentTransaction obj_conv;
18756         obj_conv.inner = (void*)(obj & (~1));
18757         obj_conv.is_owned = false;
18758         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
18759         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18760         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18761         CVec_u8Z_free(ret_var);
18762         return ret_arr;
18763 }
18764
18765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18766         LDKu8slice ser_ref;
18767         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18768         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18769         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
18770         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
18771         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18772         return (long)ret_conv;
18773 }
18774
18775 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) {
18776         LDKCommitmentTransaction commitment_tx_conv;
18777         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
18778         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
18779         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
18780         LDKSignature counterparty_sig_ref;
18781         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
18782         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
18783         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
18784         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
18785         if (counterparty_htlc_sigs_constr.datalen > 0)
18786                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18787         else
18788                 counterparty_htlc_sigs_constr.data = NULL;
18789         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
18790                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
18791                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
18792                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
18793                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
18794                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
18795         }
18796         LDKPublicKey holder_funding_key_ref;
18797         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
18798         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
18799         LDKPublicKey counterparty_funding_key_ref;
18800         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
18801         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
18802         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
18803         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18804         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18805         long ret_ref = (long)ret_var.inner;
18806         if (ret_var.is_owned) {
18807                 ret_ref |= 1;
18808         }
18809         return ret_ref;
18810 }
18811
18812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18813         LDKBuiltCommitmentTransaction this_obj_conv;
18814         this_obj_conv.inner = (void*)(this_obj & (~1));
18815         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18816         BuiltCommitmentTransaction_free(this_obj_conv);
18817 }
18818
18819 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
18820         LDKBuiltCommitmentTransaction this_ptr_conv;
18821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18822         this_ptr_conv.is_owned = false;
18823         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
18824         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18825         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18826         Transaction_free(ret_var);
18827         return ret_arr;
18828 }
18829
18830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18831         LDKBuiltCommitmentTransaction this_ptr_conv;
18832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18833         this_ptr_conv.is_owned = false;
18834         LDKTransaction val_ref;
18835         val_ref.datalen = (*env)->GetArrayLength(env, val);
18836         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
18837         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
18838         val_ref.data_is_owned = true;
18839         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
18840 }
18841
18842 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
18843         LDKBuiltCommitmentTransaction this_ptr_conv;
18844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18845         this_ptr_conv.is_owned = false;
18846         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18847         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
18848         return ret_arr;
18849 }
18850
18851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18852         LDKBuiltCommitmentTransaction this_ptr_conv;
18853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18854         this_ptr_conv.is_owned = false;
18855         LDKThirtyTwoBytes val_ref;
18856         CHECK((*env)->GetArrayLength(env, val) == 32);
18857         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18858         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
18859 }
18860
18861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
18862         LDKTransaction transaction_arg_ref;
18863         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
18864         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
18865         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
18866         transaction_arg_ref.data_is_owned = true;
18867         LDKThirtyTwoBytes txid_arg_ref;
18868         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
18869         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
18870         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
18871         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18872         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18873         long ret_ref = (long)ret_var.inner;
18874         if (ret_var.is_owned) {
18875                 ret_ref |= 1;
18876         }
18877         return ret_ref;
18878 }
18879
18880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18881         LDKBuiltCommitmentTransaction orig_conv;
18882         orig_conv.inner = (void*)(orig & (~1));
18883         orig_conv.is_owned = false;
18884         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
18885         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18886         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18887         long ret_ref = (long)ret_var.inner;
18888         if (ret_var.is_owned) {
18889                 ret_ref |= 1;
18890         }
18891         return ret_ref;
18892 }
18893
18894 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
18895         LDKBuiltCommitmentTransaction obj_conv;
18896         obj_conv.inner = (void*)(obj & (~1));
18897         obj_conv.is_owned = false;
18898         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
18899         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18900         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18901         CVec_u8Z_free(ret_var);
18902         return ret_arr;
18903 }
18904
18905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18906         LDKu8slice ser_ref;
18907         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18908         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18909         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
18910         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
18911         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18912         return (long)ret_conv;
18913 }
18914
18915 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) {
18916         LDKBuiltCommitmentTransaction this_arg_conv;
18917         this_arg_conv.inner = (void*)(this_arg & (~1));
18918         this_arg_conv.is_owned = false;
18919         LDKu8slice funding_redeemscript_ref;
18920         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
18921         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
18922         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18923         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
18924         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
18925         return ret_arr;
18926 }
18927
18928 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) {
18929         LDKBuiltCommitmentTransaction this_arg_conv;
18930         this_arg_conv.inner = (void*)(this_arg & (~1));
18931         this_arg_conv.is_owned = false;
18932         unsigned char funding_key_arr[32];
18933         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
18934         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
18935         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
18936         LDKu8slice funding_redeemscript_ref;
18937         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
18938         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
18939         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18940         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
18941         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
18942         return ret_arr;
18943 }
18944
18945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18946         LDKCommitmentTransaction this_obj_conv;
18947         this_obj_conv.inner = (void*)(this_obj & (~1));
18948         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18949         CommitmentTransaction_free(this_obj_conv);
18950 }
18951
18952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18953         LDKCommitmentTransaction orig_conv;
18954         orig_conv.inner = (void*)(orig & (~1));
18955         orig_conv.is_owned = false;
18956         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
18957         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18958         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18959         long ret_ref = (long)ret_var.inner;
18960         if (ret_var.is_owned) {
18961                 ret_ref |= 1;
18962         }
18963         return ret_ref;
18964 }
18965
18966 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
18967         LDKCommitmentTransaction obj_conv;
18968         obj_conv.inner = (void*)(obj & (~1));
18969         obj_conv.is_owned = false;
18970         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
18971         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18972         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18973         CVec_u8Z_free(ret_var);
18974         return ret_arr;
18975 }
18976
18977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18978         LDKu8slice ser_ref;
18979         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18980         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18981         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
18982         *ret_conv = CommitmentTransaction_read(ser_ref);
18983         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18984         return (long)ret_conv;
18985 }
18986
18987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
18988         LDKCommitmentTransaction this_arg_conv;
18989         this_arg_conv.inner = (void*)(this_arg & (~1));
18990         this_arg_conv.is_owned = false;
18991         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
18992         return ret_val;
18993 }
18994
18995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(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_to_broadcaster_value_sat(&this_arg_conv);
19000         return ret_val;
19001 }
19002
19003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_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_countersignatory_value_sat(&this_arg_conv);
19008         return ret_val;
19009 }
19010
19011 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(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         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
19016         return ret_val;
19017 }
19018
19019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(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         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
19024         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19025         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19026         long ret_ref = (long)ret_var.inner;
19027         if (ret_var.is_owned) {
19028                 ret_ref |= 1;
19029         }
19030         return ret_ref;
19031 }
19032
19033 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) {
19034         LDKCommitmentTransaction this_arg_conv;
19035         this_arg_conv.inner = (void*)(this_arg & (~1));
19036         this_arg_conv.is_owned = false;
19037         LDKDirectedChannelTransactionParameters channel_parameters_conv;
19038         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
19039         channel_parameters_conv.is_owned = false;
19040         LDKChannelPublicKeys broadcaster_keys_conv;
19041         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
19042         broadcaster_keys_conv.is_owned = false;
19043         LDKChannelPublicKeys countersignatory_keys_conv;
19044         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
19045         countersignatory_keys_conv.is_owned = false;
19046         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
19047         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
19048         return (long)ret_conv;
19049 }
19050
19051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19052         LDKTrustedCommitmentTransaction this_obj_conv;
19053         this_obj_conv.inner = (void*)(this_obj & (~1));
19054         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19055         TrustedCommitmentTransaction_free(this_obj_conv);
19056 }
19057
19058 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
19059         LDKTrustedCommitmentTransaction this_arg_conv;
19060         this_arg_conv.inner = (void*)(this_arg & (~1));
19061         this_arg_conv.is_owned = false;
19062         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19063         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
19064         return ret_arr;
19065 }
19066
19067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
19068         LDKTrustedCommitmentTransaction this_arg_conv;
19069         this_arg_conv.inner = (void*)(this_arg & (~1));
19070         this_arg_conv.is_owned = false;
19071         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
19072         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19073         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19074         long ret_ref = (long)ret_var.inner;
19075         if (ret_var.is_owned) {
19076                 ret_ref |= 1;
19077         }
19078         return ret_ref;
19079 }
19080
19081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
19082         LDKTrustedCommitmentTransaction this_arg_conv;
19083         this_arg_conv.inner = (void*)(this_arg & (~1));
19084         this_arg_conv.is_owned = false;
19085         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
19086         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19087         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19088         long ret_ref = (long)ret_var.inner;
19089         if (ret_var.is_owned) {
19090                 ret_ref |= 1;
19091         }
19092         return ret_ref;
19093 }
19094
19095 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) {
19096         LDKTrustedCommitmentTransaction this_arg_conv;
19097         this_arg_conv.inner = (void*)(this_arg & (~1));
19098         this_arg_conv.is_owned = false;
19099         unsigned char htlc_base_key_arr[32];
19100         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
19101         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
19102         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
19103         LDKDirectedChannelTransactionParameters channel_parameters_conv;
19104         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
19105         channel_parameters_conv.is_owned = false;
19106         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
19107         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
19108         return (long)ret_conv;
19109 }
19110
19111 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) {
19112         LDKPublicKey broadcaster_payment_basepoint_ref;
19113         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
19114         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
19115         LDKPublicKey countersignatory_payment_basepoint_ref;
19116         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
19117         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
19118         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
19119         return ret_val;
19120 }
19121
19122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19123         LDKInitFeatures orig_conv;
19124         orig_conv.inner = (void*)(orig & (~1));
19125         orig_conv.is_owned = false;
19126         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
19127         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19128         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19129         long ret_ref = (long)ret_var.inner;
19130         if (ret_var.is_owned) {
19131                 ret_ref |= 1;
19132         }
19133         return ret_ref;
19134 }
19135
19136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19137         LDKNodeFeatures orig_conv;
19138         orig_conv.inner = (void*)(orig & (~1));
19139         orig_conv.is_owned = false;
19140         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
19141         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19142         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19143         long ret_ref = (long)ret_var.inner;
19144         if (ret_var.is_owned) {
19145                 ret_ref |= 1;
19146         }
19147         return ret_ref;
19148 }
19149
19150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19151         LDKChannelFeatures orig_conv;
19152         orig_conv.inner = (void*)(orig & (~1));
19153         orig_conv.is_owned = false;
19154         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
19155         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19156         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19157         long ret_ref = (long)ret_var.inner;
19158         if (ret_var.is_owned) {
19159                 ret_ref |= 1;
19160         }
19161         return ret_ref;
19162 }
19163
19164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19165         LDKInvoiceFeatures orig_conv;
19166         orig_conv.inner = (void*)(orig & (~1));
19167         orig_conv.is_owned = false;
19168         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
19169         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19170         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19171         long ret_ref = (long)ret_var.inner;
19172         if (ret_var.is_owned) {
19173                 ret_ref |= 1;
19174         }
19175         return ret_ref;
19176 }
19177
19178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19179         LDKInitFeatures this_obj_conv;
19180         this_obj_conv.inner = (void*)(this_obj & (~1));
19181         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19182         InitFeatures_free(this_obj_conv);
19183 }
19184
19185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19186         LDKNodeFeatures this_obj_conv;
19187         this_obj_conv.inner = (void*)(this_obj & (~1));
19188         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19189         NodeFeatures_free(this_obj_conv);
19190 }
19191
19192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19193         LDKChannelFeatures this_obj_conv;
19194         this_obj_conv.inner = (void*)(this_obj & (~1));
19195         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19196         ChannelFeatures_free(this_obj_conv);
19197 }
19198
19199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19200         LDKInvoiceFeatures this_obj_conv;
19201         this_obj_conv.inner = (void*)(this_obj & (~1));
19202         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19203         InvoiceFeatures_free(this_obj_conv);
19204 }
19205
19206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
19207         LDKInitFeatures ret_var = InitFeatures_empty();
19208         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19209         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19210         long ret_ref = (long)ret_var.inner;
19211         if (ret_var.is_owned) {
19212                 ret_ref |= 1;
19213         }
19214         return ret_ref;
19215 }
19216
19217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
19218         LDKInitFeatures ret_var = InitFeatures_known();
19219         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19220         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19221         long ret_ref = (long)ret_var.inner;
19222         if (ret_var.is_owned) {
19223                 ret_ref |= 1;
19224         }
19225         return ret_ref;
19226 }
19227
19228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
19229         LDKNodeFeatures ret_var = NodeFeatures_empty();
19230         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19231         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19232         long ret_ref = (long)ret_var.inner;
19233         if (ret_var.is_owned) {
19234                 ret_ref |= 1;
19235         }
19236         return ret_ref;
19237 }
19238
19239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
19240         LDKNodeFeatures ret_var = NodeFeatures_known();
19241         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19242         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19243         long ret_ref = (long)ret_var.inner;
19244         if (ret_var.is_owned) {
19245                 ret_ref |= 1;
19246         }
19247         return ret_ref;
19248 }
19249
19250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
19251         LDKChannelFeatures ret_var = ChannelFeatures_empty();
19252         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19253         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19254         long ret_ref = (long)ret_var.inner;
19255         if (ret_var.is_owned) {
19256                 ret_ref |= 1;
19257         }
19258         return ret_ref;
19259 }
19260
19261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
19262         LDKChannelFeatures ret_var = ChannelFeatures_known();
19263         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19264         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19265         long ret_ref = (long)ret_var.inner;
19266         if (ret_var.is_owned) {
19267                 ret_ref |= 1;
19268         }
19269         return ret_ref;
19270 }
19271
19272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
19273         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
19274         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19275         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19276         long ret_ref = (long)ret_var.inner;
19277         if (ret_var.is_owned) {
19278                 ret_ref |= 1;
19279         }
19280         return ret_ref;
19281 }
19282
19283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
19284         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
19285         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19286         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19287         long ret_ref = (long)ret_var.inner;
19288         if (ret_var.is_owned) {
19289                 ret_ref |= 1;
19290         }
19291         return ret_ref;
19292 }
19293
19294 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19295         LDKInitFeatures obj_conv;
19296         obj_conv.inner = (void*)(obj & (~1));
19297         obj_conv.is_owned = false;
19298         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
19299         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19300         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19301         CVec_u8Z_free(ret_var);
19302         return ret_arr;
19303 }
19304
19305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19306         LDKNodeFeatures obj_conv;
19307         obj_conv.inner = (void*)(obj & (~1));
19308         obj_conv.is_owned = false;
19309         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
19310         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19311         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19312         CVec_u8Z_free(ret_var);
19313         return ret_arr;
19314 }
19315
19316 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19317         LDKChannelFeatures obj_conv;
19318         obj_conv.inner = (void*)(obj & (~1));
19319         obj_conv.is_owned = false;
19320         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
19321         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19322         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19323         CVec_u8Z_free(ret_var);
19324         return ret_arr;
19325 }
19326
19327 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19328         LDKInvoiceFeatures obj_conv;
19329         obj_conv.inner = (void*)(obj & (~1));
19330         obj_conv.is_owned = false;
19331         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
19332         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19333         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19334         CVec_u8Z_free(ret_var);
19335         return ret_arr;
19336 }
19337
19338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19339         LDKu8slice ser_ref;
19340         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19341         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19342         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
19343         *ret_conv = InitFeatures_read(ser_ref);
19344         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19345         return (long)ret_conv;
19346 }
19347
19348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19349         LDKu8slice ser_ref;
19350         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19351         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19352         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
19353         *ret_conv = NodeFeatures_read(ser_ref);
19354         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19355         return (long)ret_conv;
19356 }
19357
19358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19359         LDKu8slice ser_ref;
19360         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19361         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19362         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
19363         *ret_conv = ChannelFeatures_read(ser_ref);
19364         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19365         return (long)ret_conv;
19366 }
19367
19368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19369         LDKu8slice ser_ref;
19370         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19371         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19372         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
19373         *ret_conv = InvoiceFeatures_read(ser_ref);
19374         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19375         return (long)ret_conv;
19376 }
19377
19378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19379         LDKRouteHop this_obj_conv;
19380         this_obj_conv.inner = (void*)(this_obj & (~1));
19381         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19382         RouteHop_free(this_obj_conv);
19383 }
19384
19385 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
19386         LDKRouteHop this_ptr_conv;
19387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19388         this_ptr_conv.is_owned = false;
19389         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19390         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
19391         return ret_arr;
19392 }
19393
19394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19395         LDKRouteHop this_ptr_conv;
19396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19397         this_ptr_conv.is_owned = false;
19398         LDKPublicKey val_ref;
19399         CHECK((*env)->GetArrayLength(env, val) == 33);
19400         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19401         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
19402 }
19403
19404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19405         LDKRouteHop this_ptr_conv;
19406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19407         this_ptr_conv.is_owned = false;
19408         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
19409         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19410         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19411         long ret_ref = (long)ret_var.inner;
19412         if (ret_var.is_owned) {
19413                 ret_ref |= 1;
19414         }
19415         return ret_ref;
19416 }
19417
19418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19419         LDKRouteHop this_ptr_conv;
19420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19421         this_ptr_conv.is_owned = false;
19422         LDKNodeFeatures val_conv;
19423         val_conv.inner = (void*)(val & (~1));
19424         val_conv.is_owned = (val & 1) || (val == 0);
19425         val_conv = NodeFeatures_clone(&val_conv);
19426         RouteHop_set_node_features(&this_ptr_conv, val_conv);
19427 }
19428
19429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19430         LDKRouteHop this_ptr_conv;
19431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19432         this_ptr_conv.is_owned = false;
19433         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
19434         return ret_val;
19435 }
19436
19437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19438         LDKRouteHop this_ptr_conv;
19439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19440         this_ptr_conv.is_owned = false;
19441         RouteHop_set_short_channel_id(&this_ptr_conv, val);
19442 }
19443
19444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19445         LDKRouteHop this_ptr_conv;
19446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19447         this_ptr_conv.is_owned = false;
19448         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
19449         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19450         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19451         long ret_ref = (long)ret_var.inner;
19452         if (ret_var.is_owned) {
19453                 ret_ref |= 1;
19454         }
19455         return ret_ref;
19456 }
19457
19458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19459         LDKRouteHop this_ptr_conv;
19460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19461         this_ptr_conv.is_owned = false;
19462         LDKChannelFeatures val_conv;
19463         val_conv.inner = (void*)(val & (~1));
19464         val_conv.is_owned = (val & 1) || (val == 0);
19465         val_conv = ChannelFeatures_clone(&val_conv);
19466         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
19467 }
19468
19469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19470         LDKRouteHop this_ptr_conv;
19471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19472         this_ptr_conv.is_owned = false;
19473         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
19474         return ret_val;
19475 }
19476
19477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19478         LDKRouteHop this_ptr_conv;
19479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19480         this_ptr_conv.is_owned = false;
19481         RouteHop_set_fee_msat(&this_ptr_conv, val);
19482 }
19483
19484 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
19485         LDKRouteHop this_ptr_conv;
19486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19487         this_ptr_conv.is_owned = false;
19488         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
19489         return ret_val;
19490 }
19491
19492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19493         LDKRouteHop this_ptr_conv;
19494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19495         this_ptr_conv.is_owned = false;
19496         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
19497 }
19498
19499 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) {
19500         LDKPublicKey pubkey_arg_ref;
19501         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
19502         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
19503         LDKNodeFeatures node_features_arg_conv;
19504         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
19505         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
19506         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
19507         LDKChannelFeatures channel_features_arg_conv;
19508         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
19509         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
19510         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
19511         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);
19512         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19513         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19514         long ret_ref = (long)ret_var.inner;
19515         if (ret_var.is_owned) {
19516                 ret_ref |= 1;
19517         }
19518         return ret_ref;
19519 }
19520
19521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19522         LDKRouteHop orig_conv;
19523         orig_conv.inner = (void*)(orig & (~1));
19524         orig_conv.is_owned = false;
19525         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
19526         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19527         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19528         long ret_ref = (long)ret_var.inner;
19529         if (ret_var.is_owned) {
19530                 ret_ref |= 1;
19531         }
19532         return ret_ref;
19533 }
19534
19535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19536         LDKRoute this_obj_conv;
19537         this_obj_conv.inner = (void*)(this_obj & (~1));
19538         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19539         Route_free(this_obj_conv);
19540 }
19541
19542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
19543         LDKRoute this_ptr_conv;
19544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19545         this_ptr_conv.is_owned = false;
19546         LDKCVec_CVec_RouteHopZZ val_constr;
19547         val_constr.datalen = (*env)->GetArrayLength(env, val);
19548         if (val_constr.datalen > 0)
19549                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
19550         else
19551                 val_constr.data = NULL;
19552         for (size_t m = 0; m < val_constr.datalen; m++) {
19553                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
19554                 LDKCVec_RouteHopZ val_conv_12_constr;
19555                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
19556                 if (val_conv_12_constr.datalen > 0)
19557                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19558                 else
19559                         val_conv_12_constr.data = NULL;
19560                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
19561                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
19562                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
19563                         LDKRouteHop val_conv_12_conv_10_conv;
19564                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
19565                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
19566                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
19567                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
19568                 }
19569                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
19570                 val_constr.data[m] = val_conv_12_constr;
19571         }
19572         Route_set_paths(&this_ptr_conv, val_constr);
19573 }
19574
19575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
19576         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
19577         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
19578         if (paths_arg_constr.datalen > 0)
19579                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
19580         else
19581                 paths_arg_constr.data = NULL;
19582         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
19583                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
19584                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
19585                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
19586                 if (paths_arg_conv_12_constr.datalen > 0)
19587                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19588                 else
19589                         paths_arg_conv_12_constr.data = NULL;
19590                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
19591                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
19592                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
19593                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
19594                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
19595                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
19596                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
19597                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
19598                 }
19599                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
19600                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
19601         }
19602         LDKRoute ret_var = Route_new(paths_arg_constr);
19603         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19604         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19605         long ret_ref = (long)ret_var.inner;
19606         if (ret_var.is_owned) {
19607                 ret_ref |= 1;
19608         }
19609         return ret_ref;
19610 }
19611
19612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19613         LDKRoute orig_conv;
19614         orig_conv.inner = (void*)(orig & (~1));
19615         orig_conv.is_owned = false;
19616         LDKRoute ret_var = Route_clone(&orig_conv);
19617         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19618         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19619         long ret_ref = (long)ret_var.inner;
19620         if (ret_var.is_owned) {
19621                 ret_ref |= 1;
19622         }
19623         return ret_ref;
19624 }
19625
19626 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
19627         LDKRoute obj_conv;
19628         obj_conv.inner = (void*)(obj & (~1));
19629         obj_conv.is_owned = false;
19630         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
19631         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19632         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19633         CVec_u8Z_free(ret_var);
19634         return ret_arr;
19635 }
19636
19637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19638         LDKu8slice ser_ref;
19639         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19640         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19641         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
19642         *ret_conv = Route_read(ser_ref);
19643         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19644         return (long)ret_conv;
19645 }
19646
19647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19648         LDKRouteHint this_obj_conv;
19649         this_obj_conv.inner = (void*)(this_obj & (~1));
19650         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19651         RouteHint_free(this_obj_conv);
19652 }
19653
19654 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19655         LDKRouteHint this_ptr_conv;
19656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19657         this_ptr_conv.is_owned = false;
19658         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19659         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHint_get_src_node_id(&this_ptr_conv).compressed_form);
19660         return ret_arr;
19661 }
19662
19663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19664         LDKRouteHint this_ptr_conv;
19665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19666         this_ptr_conv.is_owned = false;
19667         LDKPublicKey val_ref;
19668         CHECK((*env)->GetArrayLength(env, val) == 33);
19669         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19670         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
19671 }
19672
19673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19674         LDKRouteHint this_ptr_conv;
19675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19676         this_ptr_conv.is_owned = false;
19677         int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
19678         return ret_val;
19679 }
19680
19681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19682         LDKRouteHint this_ptr_conv;
19683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19684         this_ptr_conv.is_owned = false;
19685         RouteHint_set_short_channel_id(&this_ptr_conv, val);
19686 }
19687
19688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
19689         LDKRouteHint this_ptr_conv;
19690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19691         this_ptr_conv.is_owned = false;
19692         LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
19693         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19694         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19695         long ret_ref = (long)ret_var.inner;
19696         if (ret_var.is_owned) {
19697                 ret_ref |= 1;
19698         }
19699         return ret_ref;
19700 }
19701
19702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19703         LDKRouteHint this_ptr_conv;
19704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19705         this_ptr_conv.is_owned = false;
19706         LDKRoutingFees val_conv;
19707         val_conv.inner = (void*)(val & (~1));
19708         val_conv.is_owned = (val & 1) || (val == 0);
19709         val_conv = RoutingFees_clone(&val_conv);
19710         RouteHint_set_fees(&this_ptr_conv, val_conv);
19711 }
19712
19713 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
19714         LDKRouteHint this_ptr_conv;
19715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19716         this_ptr_conv.is_owned = false;
19717         int16_t ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
19718         return ret_val;
19719 }
19720
19721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19722         LDKRouteHint this_ptr_conv;
19723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19724         this_ptr_conv.is_owned = false;
19725         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
19726 }
19727
19728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19729         LDKRouteHint this_ptr_conv;
19730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19731         this_ptr_conv.is_owned = false;
19732         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
19733         *ret_copy = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
19734         long ret_ref = (long)ret_copy;
19735         return ret_ref;
19736 }
19737
19738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19739         LDKRouteHint this_ptr_conv;
19740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19741         this_ptr_conv.is_owned = false;
19742         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
19743         FREE((void*)val);
19744         RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
19745 }
19746
19747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19748         LDKRouteHint this_ptr_conv;
19749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19750         this_ptr_conv.is_owned = false;
19751         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
19752         *ret_copy = RouteHint_get_htlc_maximum_msat(&this_ptr_conv);
19753         long ret_ref = (long)ret_copy;
19754         return ret_ref;
19755 }
19756
19757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19758         LDKRouteHint this_ptr_conv;
19759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19760         this_ptr_conv.is_owned = false;
19761         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
19762         FREE((void*)val);
19763         RouteHint_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
19764 }
19765
19766 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) {
19767         LDKPublicKey src_node_id_arg_ref;
19768         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
19769         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
19770         LDKRoutingFees fees_arg_conv;
19771         fees_arg_conv.inner = (void*)(fees_arg & (~1));
19772         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
19773         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
19774         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
19775         FREE((void*)htlc_minimum_msat_arg);
19776         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
19777         FREE((void*)htlc_maximum_msat_arg);
19778         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);
19779         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19780         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19781         long ret_ref = (long)ret_var.inner;
19782         if (ret_var.is_owned) {
19783                 ret_ref |= 1;
19784         }
19785         return ret_ref;
19786 }
19787
19788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19789         LDKRouteHint orig_conv;
19790         orig_conv.inner = (void*)(orig & (~1));
19791         orig_conv.is_owned = false;
19792         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
19793         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19794         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19795         long ret_ref = (long)ret_var.inner;
19796         if (ret_var.is_owned) {
19797                 ret_ref |= 1;
19798         }
19799         return ret_ref;
19800 }
19801
19802 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) {
19803         LDKPublicKey our_node_id_ref;
19804         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
19805         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
19806         LDKNetworkGraph network_conv;
19807         network_conv.inner = (void*)(network & (~1));
19808         network_conv.is_owned = false;
19809         LDKPublicKey payee_ref;
19810         CHECK((*env)->GetArrayLength(env, payee) == 33);
19811         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
19812         LDKInvoiceFeatures payee_features_conv;
19813         payee_features_conv.inner = (void*)(payee_features & (~1));
19814         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
19815         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
19816         LDKCVec_ChannelDetailsZ first_hops_constr;
19817         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
19818         if (first_hops_constr.datalen > 0)
19819                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
19820         else
19821                 first_hops_constr.data = NULL;
19822         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
19823         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
19824                 int64_t first_hops_conv_16 = first_hops_vals[q];
19825                 LDKChannelDetails first_hops_conv_16_conv;
19826                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
19827                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
19828                 first_hops_constr.data[q] = first_hops_conv_16_conv;
19829         }
19830         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
19831         LDKCVec_RouteHintZ last_hops_constr;
19832         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
19833         if (last_hops_constr.datalen > 0)
19834                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
19835         else
19836                 last_hops_constr.data = NULL;
19837         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
19838         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
19839                 int64_t last_hops_conv_11 = last_hops_vals[l];
19840                 LDKRouteHint last_hops_conv_11_conv;
19841                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
19842                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
19843                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
19844                 last_hops_constr.data[l] = last_hops_conv_11_conv;
19845         }
19846         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
19847         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19848         if (logger_conv.free == LDKLogger_JCalls_free) {
19849                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19850                 LDKLogger_JCalls_clone(logger_conv.this_arg);
19851         }
19852         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
19853         *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);
19854         FREE(first_hops_constr.data);
19855         return (long)ret_conv;
19856 }
19857
19858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19859         LDKNetworkGraph this_obj_conv;
19860         this_obj_conv.inner = (void*)(this_obj & (~1));
19861         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19862         NetworkGraph_free(this_obj_conv);
19863 }
19864
19865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19866         LDKNetworkGraph orig_conv;
19867         orig_conv.inner = (void*)(orig & (~1));
19868         orig_conv.is_owned = false;
19869         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
19870         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19871         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19872         long ret_ref = (long)ret_var.inner;
19873         if (ret_var.is_owned) {
19874                 ret_ref |= 1;
19875         }
19876         return ret_ref;
19877 }
19878
19879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19880         LDKLockedNetworkGraph this_obj_conv;
19881         this_obj_conv.inner = (void*)(this_obj & (~1));
19882         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19883         LockedNetworkGraph_free(this_obj_conv);
19884 }
19885
19886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19887         LDKNetGraphMsgHandler this_obj_conv;
19888         this_obj_conv.inner = (void*)(this_obj & (~1));
19889         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19890         NetGraphMsgHandler_free(this_obj_conv);
19891 }
19892
19893 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) {
19894         LDKThirtyTwoBytes genesis_hash_ref;
19895         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
19896         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
19897         LDKAccess *chain_access_conv_ptr = NULL;
19898         if (chain_access != 0) {
19899                 LDKAccess chain_access_conv;
19900                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19901                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
19902                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19903                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
19904                 }
19905                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19906                 *chain_access_conv_ptr = chain_access_conv;
19907         }
19908         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19909         if (logger_conv.free == LDKLogger_JCalls_free) {
19910                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19911                 LDKLogger_JCalls_clone(logger_conv.this_arg);
19912         }
19913         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
19914         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19915         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19916         long ret_ref = (long)ret_var.inner;
19917         if (ret_var.is_owned) {
19918                 ret_ref |= 1;
19919         }
19920         return ret_ref;
19921 }
19922
19923 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) {
19924         LDKAccess *chain_access_conv_ptr = NULL;
19925         if (chain_access != 0) {
19926                 LDKAccess chain_access_conv;
19927                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19928                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
19929                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19930                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
19931                 }
19932                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19933                 *chain_access_conv_ptr = chain_access_conv;
19934         }
19935         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19936         if (logger_conv.free == LDKLogger_JCalls_free) {
19937                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19938                 LDKLogger_JCalls_clone(logger_conv.this_arg);
19939         }
19940         LDKNetworkGraph network_graph_conv;
19941         network_graph_conv.inner = (void*)(network_graph & (~1));
19942         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
19943         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
19944         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
19945         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19946         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19947         long ret_ref = (long)ret_var.inner;
19948         if (ret_var.is_owned) {
19949                 ret_ref |= 1;
19950         }
19951         return ret_ref;
19952 }
19953
19954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
19955         LDKNetGraphMsgHandler this_arg_conv;
19956         this_arg_conv.inner = (void*)(this_arg & (~1));
19957         this_arg_conv.is_owned = false;
19958         LDKAccess *chain_access_conv_ptr = NULL;
19959         if (chain_access != 0) {
19960                 LDKAccess chain_access_conv;
19961                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19962                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
19963                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19964                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
19965                 }
19966                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19967                 *chain_access_conv_ptr = chain_access_conv;
19968         }
19969         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
19970 }
19971
19972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
19973         LDKNetGraphMsgHandler this_arg_conv;
19974         this_arg_conv.inner = (void*)(this_arg & (~1));
19975         this_arg_conv.is_owned = false;
19976         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
19977         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19978         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19979         long ret_ref = (long)ret_var.inner;
19980         if (ret_var.is_owned) {
19981                 ret_ref |= 1;
19982         }
19983         return ret_ref;
19984 }
19985
19986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
19987         LDKLockedNetworkGraph this_arg_conv;
19988         this_arg_conv.inner = (void*)(this_arg & (~1));
19989         this_arg_conv.is_owned = false;
19990         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
19991         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19992         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19993         long ret_ref = (long)ret_var.inner;
19994         if (ret_var.is_owned) {
19995                 ret_ref |= 1;
19996         }
19997         return ret_ref;
19998 }
19999
20000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
20001         LDKNetGraphMsgHandler this_arg_conv;
20002         this_arg_conv.inner = (void*)(this_arg & (~1));
20003         this_arg_conv.is_owned = false;
20004         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
20005         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
20006         return (long)ret;
20007 }
20008
20009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
20010         LDKNetGraphMsgHandler this_arg_conv;
20011         this_arg_conv.inner = (void*)(this_arg & (~1));
20012         this_arg_conv.is_owned = false;
20013         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20014         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
20015         return (long)ret;
20016 }
20017
20018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20019         LDKDirectionalChannelInfo this_obj_conv;
20020         this_obj_conv.inner = (void*)(this_obj & (~1));
20021         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20022         DirectionalChannelInfo_free(this_obj_conv);
20023 }
20024
20025 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
20026         LDKDirectionalChannelInfo this_ptr_conv;
20027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20028         this_ptr_conv.is_owned = false;
20029         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
20030         return ret_val;
20031 }
20032
20033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20034         LDKDirectionalChannelInfo this_ptr_conv;
20035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20036         this_ptr_conv.is_owned = false;
20037         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
20038 }
20039
20040 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
20041         LDKDirectionalChannelInfo this_ptr_conv;
20042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20043         this_ptr_conv.is_owned = false;
20044         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
20045         return ret_val;
20046 }
20047
20048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20049         LDKDirectionalChannelInfo this_ptr_conv;
20050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20051         this_ptr_conv.is_owned = false;
20052         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
20053 }
20054
20055 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
20056         LDKDirectionalChannelInfo this_ptr_conv;
20057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20058         this_ptr_conv.is_owned = false;
20059         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
20060         return ret_val;
20061 }
20062
20063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20064         LDKDirectionalChannelInfo this_ptr_conv;
20065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20066         this_ptr_conv.is_owned = false;
20067         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
20068 }
20069
20070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20071         LDKDirectionalChannelInfo this_ptr_conv;
20072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20073         this_ptr_conv.is_owned = false;
20074         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
20075         return ret_val;
20076 }
20077
20078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20079         LDKDirectionalChannelInfo this_ptr_conv;
20080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20081         this_ptr_conv.is_owned = false;
20082         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
20083 }
20084
20085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20086         LDKDirectionalChannelInfo this_ptr_conv;
20087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20088         this_ptr_conv.is_owned = false;
20089         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20090         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
20091         long ret_ref = (long)ret_copy;
20092         return ret_ref;
20093 }
20094
20095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20096         LDKDirectionalChannelInfo this_ptr_conv;
20097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20098         this_ptr_conv.is_owned = false;
20099         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20100         FREE((void*)val);
20101         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
20102 }
20103
20104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
20105         LDKDirectionalChannelInfo this_ptr_conv;
20106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20107         this_ptr_conv.is_owned = false;
20108         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
20109         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20110         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20111         long ret_ref = (long)ret_var.inner;
20112         if (ret_var.is_owned) {
20113                 ret_ref |= 1;
20114         }
20115         return ret_ref;
20116 }
20117
20118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20119         LDKDirectionalChannelInfo this_ptr_conv;
20120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20121         this_ptr_conv.is_owned = false;
20122         LDKRoutingFees val_conv;
20123         val_conv.inner = (void*)(val & (~1));
20124         val_conv.is_owned = (val & 1) || (val == 0);
20125         val_conv = RoutingFees_clone(&val_conv);
20126         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
20127 }
20128
20129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
20130         LDKDirectionalChannelInfo this_ptr_conv;
20131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20132         this_ptr_conv.is_owned = false;
20133         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
20134         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20135         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20136         long ret_ref = (long)ret_var.inner;
20137         if (ret_var.is_owned) {
20138                 ret_ref |= 1;
20139         }
20140         return ret_ref;
20141 }
20142
20143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20144         LDKDirectionalChannelInfo this_ptr_conv;
20145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20146         this_ptr_conv.is_owned = false;
20147         LDKChannelUpdate val_conv;
20148         val_conv.inner = (void*)(val & (~1));
20149         val_conv.is_owned = (val & 1) || (val == 0);
20150         val_conv = ChannelUpdate_clone(&val_conv);
20151         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
20152 }
20153
20154 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) {
20155         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
20156         FREE((void*)htlc_maximum_msat_arg);
20157         LDKRoutingFees fees_arg_conv;
20158         fees_arg_conv.inner = (void*)(fees_arg & (~1));
20159         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
20160         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
20161         LDKChannelUpdate last_update_message_arg_conv;
20162         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
20163         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
20164         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
20165         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);
20166         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20167         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20168         long ret_ref = (long)ret_var.inner;
20169         if (ret_var.is_owned) {
20170                 ret_ref |= 1;
20171         }
20172         return ret_ref;
20173 }
20174
20175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20176         LDKDirectionalChannelInfo orig_conv;
20177         orig_conv.inner = (void*)(orig & (~1));
20178         orig_conv.is_owned = false;
20179         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
20180         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20181         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20182         long ret_ref = (long)ret_var.inner;
20183         if (ret_var.is_owned) {
20184                 ret_ref |= 1;
20185         }
20186         return ret_ref;
20187 }
20188
20189 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
20190         LDKDirectionalChannelInfo obj_conv;
20191         obj_conv.inner = (void*)(obj & (~1));
20192         obj_conv.is_owned = false;
20193         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
20194         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20195         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20196         CVec_u8Z_free(ret_var);
20197         return ret_arr;
20198 }
20199
20200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20201         LDKu8slice ser_ref;
20202         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20203         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20204         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
20205         *ret_conv = DirectionalChannelInfo_read(ser_ref);
20206         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20207         return (long)ret_conv;
20208 }
20209
20210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20211         LDKChannelInfo this_obj_conv;
20212         this_obj_conv.inner = (void*)(this_obj & (~1));
20213         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20214         ChannelInfo_free(this_obj_conv);
20215 }
20216
20217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20218         LDKChannelInfo this_ptr_conv;
20219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20220         this_ptr_conv.is_owned = false;
20221         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
20222         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20223         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20224         long ret_ref = (long)ret_var.inner;
20225         if (ret_var.is_owned) {
20226                 ret_ref |= 1;
20227         }
20228         return ret_ref;
20229 }
20230
20231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20232         LDKChannelInfo this_ptr_conv;
20233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20234         this_ptr_conv.is_owned = false;
20235         LDKChannelFeatures val_conv;
20236         val_conv.inner = (void*)(val & (~1));
20237         val_conv.is_owned = (val & 1) || (val == 0);
20238         val_conv = ChannelFeatures_clone(&val_conv);
20239         ChannelInfo_set_features(&this_ptr_conv, val_conv);
20240 }
20241
20242 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
20243         LDKChannelInfo this_ptr_conv;
20244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20245         this_ptr_conv.is_owned = false;
20246         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20247         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
20248         return ret_arr;
20249 }
20250
20251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20252         LDKChannelInfo this_ptr_conv;
20253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20254         this_ptr_conv.is_owned = false;
20255         LDKPublicKey val_ref;
20256         CHECK((*env)->GetArrayLength(env, val) == 33);
20257         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20258         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
20259 }
20260
20261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
20262         LDKChannelInfo this_ptr_conv;
20263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20264         this_ptr_conv.is_owned = false;
20265         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
20266         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20267         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20268         long ret_ref = (long)ret_var.inner;
20269         if (ret_var.is_owned) {
20270                 ret_ref |= 1;
20271         }
20272         return ret_ref;
20273 }
20274
20275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20276         LDKChannelInfo this_ptr_conv;
20277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20278         this_ptr_conv.is_owned = false;
20279         LDKDirectionalChannelInfo val_conv;
20280         val_conv.inner = (void*)(val & (~1));
20281         val_conv.is_owned = (val & 1) || (val == 0);
20282         val_conv = DirectionalChannelInfo_clone(&val_conv);
20283         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
20284 }
20285
20286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
20287         LDKChannelInfo this_ptr_conv;
20288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20289         this_ptr_conv.is_owned = false;
20290         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20291         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
20292         return ret_arr;
20293 }
20294
20295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20296         LDKChannelInfo this_ptr_conv;
20297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20298         this_ptr_conv.is_owned = false;
20299         LDKPublicKey val_ref;
20300         CHECK((*env)->GetArrayLength(env, val) == 33);
20301         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20302         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
20303 }
20304
20305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
20306         LDKChannelInfo this_ptr_conv;
20307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20308         this_ptr_conv.is_owned = false;
20309         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
20310         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20311         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20312         long ret_ref = (long)ret_var.inner;
20313         if (ret_var.is_owned) {
20314                 ret_ref |= 1;
20315         }
20316         return ret_ref;
20317 }
20318
20319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20320         LDKChannelInfo this_ptr_conv;
20321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20322         this_ptr_conv.is_owned = false;
20323         LDKDirectionalChannelInfo val_conv;
20324         val_conv.inner = (void*)(val & (~1));
20325         val_conv.is_owned = (val & 1) || (val == 0);
20326         val_conv = DirectionalChannelInfo_clone(&val_conv);
20327         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
20328 }
20329
20330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
20331         LDKChannelInfo this_ptr_conv;
20332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20333         this_ptr_conv.is_owned = false;
20334         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20335         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
20336         long ret_ref = (long)ret_copy;
20337         return ret_ref;
20338 }
20339
20340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20341         LDKChannelInfo this_ptr_conv;
20342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20343         this_ptr_conv.is_owned = false;
20344         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20345         FREE((void*)val);
20346         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
20347 }
20348
20349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
20350         LDKChannelInfo this_ptr_conv;
20351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20352         this_ptr_conv.is_owned = false;
20353         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
20354         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20355         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20356         long ret_ref = (long)ret_var.inner;
20357         if (ret_var.is_owned) {
20358                 ret_ref |= 1;
20359         }
20360         return ret_ref;
20361 }
20362
20363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20364         LDKChannelInfo this_ptr_conv;
20365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20366         this_ptr_conv.is_owned = false;
20367         LDKChannelAnnouncement val_conv;
20368         val_conv.inner = (void*)(val & (~1));
20369         val_conv.is_owned = (val & 1) || (val == 0);
20370         val_conv = ChannelAnnouncement_clone(&val_conv);
20371         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
20372 }
20373
20374 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) {
20375         LDKChannelFeatures features_arg_conv;
20376         features_arg_conv.inner = (void*)(features_arg & (~1));
20377         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
20378         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
20379         LDKPublicKey node_one_arg_ref;
20380         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
20381         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
20382         LDKDirectionalChannelInfo one_to_two_arg_conv;
20383         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
20384         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
20385         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
20386         LDKPublicKey node_two_arg_ref;
20387         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
20388         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
20389         LDKDirectionalChannelInfo two_to_one_arg_conv;
20390         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
20391         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
20392         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
20393         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
20394         FREE((void*)capacity_sats_arg);
20395         LDKChannelAnnouncement announcement_message_arg_conv;
20396         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
20397         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
20398         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
20399         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);
20400         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20401         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20402         long ret_ref = (long)ret_var.inner;
20403         if (ret_var.is_owned) {
20404                 ret_ref |= 1;
20405         }
20406         return ret_ref;
20407 }
20408
20409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20410         LDKChannelInfo orig_conv;
20411         orig_conv.inner = (void*)(orig & (~1));
20412         orig_conv.is_owned = false;
20413         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
20414         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20415         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20416         long ret_ref = (long)ret_var.inner;
20417         if (ret_var.is_owned) {
20418                 ret_ref |= 1;
20419         }
20420         return ret_ref;
20421 }
20422
20423 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
20424         LDKChannelInfo obj_conv;
20425         obj_conv.inner = (void*)(obj & (~1));
20426         obj_conv.is_owned = false;
20427         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
20428         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20429         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20430         CVec_u8Z_free(ret_var);
20431         return ret_arr;
20432 }
20433
20434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20435         LDKu8slice ser_ref;
20436         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20437         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20438         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20439         *ret_conv = ChannelInfo_read(ser_ref);
20440         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20441         return (long)ret_conv;
20442 }
20443
20444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20445         LDKRoutingFees this_obj_conv;
20446         this_obj_conv.inner = (void*)(this_obj & (~1));
20447         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20448         RoutingFees_free(this_obj_conv);
20449 }
20450
20451 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20452         LDKRoutingFees this_ptr_conv;
20453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20454         this_ptr_conv.is_owned = false;
20455         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
20456         return ret_val;
20457 }
20458
20459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20460         LDKRoutingFees this_ptr_conv;
20461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20462         this_ptr_conv.is_owned = false;
20463         RoutingFees_set_base_msat(&this_ptr_conv, val);
20464 }
20465
20466 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
20467         LDKRoutingFees this_ptr_conv;
20468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20469         this_ptr_conv.is_owned = false;
20470         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
20471         return ret_val;
20472 }
20473
20474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20475         LDKRoutingFees this_ptr_conv;
20476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20477         this_ptr_conv.is_owned = false;
20478         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
20479 }
20480
20481 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) {
20482         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
20483         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20484         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20485         long ret_ref = (long)ret_var.inner;
20486         if (ret_var.is_owned) {
20487                 ret_ref |= 1;
20488         }
20489         return ret_ref;
20490 }
20491
20492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20493         LDKRoutingFees orig_conv;
20494         orig_conv.inner = (void*)(orig & (~1));
20495         orig_conv.is_owned = false;
20496         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
20497         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20498         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20499         long ret_ref = (long)ret_var.inner;
20500         if (ret_var.is_owned) {
20501                 ret_ref |= 1;
20502         }
20503         return ret_ref;
20504 }
20505
20506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20507         LDKu8slice ser_ref;
20508         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20509         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20510         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20511         *ret_conv = RoutingFees_read(ser_ref);
20512         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20513         return (long)ret_conv;
20514 }
20515
20516 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
20517         LDKRoutingFees obj_conv;
20518         obj_conv.inner = (void*)(obj & (~1));
20519         obj_conv.is_owned = false;
20520         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
20521         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20522         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20523         CVec_u8Z_free(ret_var);
20524         return ret_arr;
20525 }
20526
20527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20528         LDKNodeAnnouncementInfo this_obj_conv;
20529         this_obj_conv.inner = (void*)(this_obj & (~1));
20530         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20531         NodeAnnouncementInfo_free(this_obj_conv);
20532 }
20533
20534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20535         LDKNodeAnnouncementInfo this_ptr_conv;
20536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20537         this_ptr_conv.is_owned = false;
20538         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
20539         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20540         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20541         long ret_ref = (long)ret_var.inner;
20542         if (ret_var.is_owned) {
20543                 ret_ref |= 1;
20544         }
20545         return ret_ref;
20546 }
20547
20548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20549         LDKNodeAnnouncementInfo this_ptr_conv;
20550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20551         this_ptr_conv.is_owned = false;
20552         LDKNodeFeatures val_conv;
20553         val_conv.inner = (void*)(val & (~1));
20554         val_conv.is_owned = (val & 1) || (val == 0);
20555         val_conv = NodeFeatures_clone(&val_conv);
20556         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
20557 }
20558
20559 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
20560         LDKNodeAnnouncementInfo this_ptr_conv;
20561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20562         this_ptr_conv.is_owned = false;
20563         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
20564         return ret_val;
20565 }
20566
20567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20568         LDKNodeAnnouncementInfo this_ptr_conv;
20569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20570         this_ptr_conv.is_owned = false;
20571         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
20572 }
20573
20574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
20575         LDKNodeAnnouncementInfo this_ptr_conv;
20576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20577         this_ptr_conv.is_owned = false;
20578         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
20579         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
20580         return ret_arr;
20581 }
20582
20583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20584         LDKNodeAnnouncementInfo this_ptr_conv;
20585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20586         this_ptr_conv.is_owned = false;
20587         LDKThreeBytes val_ref;
20588         CHECK((*env)->GetArrayLength(env, val) == 3);
20589         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
20590         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
20591 }
20592
20593 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
20594         LDKNodeAnnouncementInfo this_ptr_conv;
20595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20596         this_ptr_conv.is_owned = false;
20597         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20598         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
20599         return ret_arr;
20600 }
20601
20602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20603         LDKNodeAnnouncementInfo this_ptr_conv;
20604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20605         this_ptr_conv.is_owned = false;
20606         LDKThirtyTwoBytes val_ref;
20607         CHECK((*env)->GetArrayLength(env, val) == 32);
20608         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20609         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
20610 }
20611
20612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20613         LDKNodeAnnouncementInfo this_ptr_conv;
20614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20615         this_ptr_conv.is_owned = false;
20616         LDKCVec_NetAddressZ val_constr;
20617         val_constr.datalen = (*env)->GetArrayLength(env, val);
20618         if (val_constr.datalen > 0)
20619                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20620         else
20621                 val_constr.data = NULL;
20622         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20623         for (size_t m = 0; m < val_constr.datalen; m++) {
20624                 int64_t val_conv_12 = val_vals[m];
20625                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
20626                 FREE((void*)val_conv_12);
20627                 val_constr.data[m] = val_conv_12_conv;
20628         }
20629         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20630         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
20631 }
20632
20633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
20634         LDKNodeAnnouncementInfo this_ptr_conv;
20635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20636         this_ptr_conv.is_owned = false;
20637         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
20638         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20639         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20640         long ret_ref = (long)ret_var.inner;
20641         if (ret_var.is_owned) {
20642                 ret_ref |= 1;
20643         }
20644         return ret_ref;
20645 }
20646
20647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20648         LDKNodeAnnouncementInfo this_ptr_conv;
20649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20650         this_ptr_conv.is_owned = false;
20651         LDKNodeAnnouncement val_conv;
20652         val_conv.inner = (void*)(val & (~1));
20653         val_conv.is_owned = (val & 1) || (val == 0);
20654         val_conv = NodeAnnouncement_clone(&val_conv);
20655         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
20656 }
20657
20658 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) {
20659         LDKNodeFeatures features_arg_conv;
20660         features_arg_conv.inner = (void*)(features_arg & (~1));
20661         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
20662         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
20663         LDKThreeBytes rgb_arg_ref;
20664         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
20665         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
20666         LDKThirtyTwoBytes alias_arg_ref;
20667         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
20668         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
20669         LDKCVec_NetAddressZ addresses_arg_constr;
20670         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
20671         if (addresses_arg_constr.datalen > 0)
20672                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20673         else
20674                 addresses_arg_constr.data = NULL;
20675         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
20676         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
20677                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
20678                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
20679                 FREE((void*)addresses_arg_conv_12);
20680                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
20681         }
20682         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
20683         LDKNodeAnnouncement announcement_message_arg_conv;
20684         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
20685         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
20686         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
20687         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
20688         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20689         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20690         long ret_ref = (long)ret_var.inner;
20691         if (ret_var.is_owned) {
20692                 ret_ref |= 1;
20693         }
20694         return ret_ref;
20695 }
20696
20697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20698         LDKNodeAnnouncementInfo orig_conv;
20699         orig_conv.inner = (void*)(orig & (~1));
20700         orig_conv.is_owned = false;
20701         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
20702         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20703         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20704         long ret_ref = (long)ret_var.inner;
20705         if (ret_var.is_owned) {
20706                 ret_ref |= 1;
20707         }
20708         return ret_ref;
20709 }
20710
20711 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
20712         LDKNodeAnnouncementInfo obj_conv;
20713         obj_conv.inner = (void*)(obj & (~1));
20714         obj_conv.is_owned = false;
20715         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
20716         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20717         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20718         CVec_u8Z_free(ret_var);
20719         return ret_arr;
20720 }
20721
20722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20723         LDKu8slice ser_ref;
20724         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20725         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20726         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20727         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
20728         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20729         return (long)ret_conv;
20730 }
20731
20732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20733         LDKNodeInfo this_obj_conv;
20734         this_obj_conv.inner = (void*)(this_obj & (~1));
20735         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20736         NodeInfo_free(this_obj_conv);
20737 }
20738
20739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20740         LDKNodeInfo this_ptr_conv;
20741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20742         this_ptr_conv.is_owned = false;
20743         LDKCVec_u64Z val_constr;
20744         val_constr.datalen = (*env)->GetArrayLength(env, val);
20745         if (val_constr.datalen > 0)
20746                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20747         else
20748                 val_constr.data = NULL;
20749         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20750         for (size_t g = 0; g < val_constr.datalen; g++) {
20751                 int64_t val_conv_6 = val_vals[g];
20752                 val_constr.data[g] = val_conv_6;
20753         }
20754         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20755         NodeInfo_set_channels(&this_ptr_conv, val_constr);
20756 }
20757
20758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
20759         LDKNodeInfo this_ptr_conv;
20760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20761         this_ptr_conv.is_owned = false;
20762         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
20763         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20764         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20765         long ret_ref = (long)ret_var.inner;
20766         if (ret_var.is_owned) {
20767                 ret_ref |= 1;
20768         }
20769         return ret_ref;
20770 }
20771
20772 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) {
20773         LDKNodeInfo this_ptr_conv;
20774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20775         this_ptr_conv.is_owned = false;
20776         LDKRoutingFees val_conv;
20777         val_conv.inner = (void*)(val & (~1));
20778         val_conv.is_owned = (val & 1) || (val == 0);
20779         val_conv = RoutingFees_clone(&val_conv);
20780         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
20781 }
20782
20783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
20784         LDKNodeInfo this_ptr_conv;
20785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20786         this_ptr_conv.is_owned = false;
20787         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
20788         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20789         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20790         long ret_ref = (long)ret_var.inner;
20791         if (ret_var.is_owned) {
20792                 ret_ref |= 1;
20793         }
20794         return ret_ref;
20795 }
20796
20797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20798         LDKNodeInfo this_ptr_conv;
20799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20800         this_ptr_conv.is_owned = false;
20801         LDKNodeAnnouncementInfo val_conv;
20802         val_conv.inner = (void*)(val & (~1));
20803         val_conv.is_owned = (val & 1) || (val == 0);
20804         val_conv = NodeAnnouncementInfo_clone(&val_conv);
20805         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
20806 }
20807
20808 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) {
20809         LDKCVec_u64Z channels_arg_constr;
20810         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
20811         if (channels_arg_constr.datalen > 0)
20812                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20813         else
20814                 channels_arg_constr.data = NULL;
20815         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
20816         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
20817                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
20818                 channels_arg_constr.data[g] = channels_arg_conv_6;
20819         }
20820         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
20821         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
20822         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
20823         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
20824         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
20825         LDKNodeAnnouncementInfo announcement_info_arg_conv;
20826         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
20827         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
20828         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
20829         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
20830         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20831         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20832         long ret_ref = (long)ret_var.inner;
20833         if (ret_var.is_owned) {
20834                 ret_ref |= 1;
20835         }
20836         return ret_ref;
20837 }
20838
20839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20840         LDKNodeInfo orig_conv;
20841         orig_conv.inner = (void*)(orig & (~1));
20842         orig_conv.is_owned = false;
20843         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
20844         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20845         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20846         long ret_ref = (long)ret_var.inner;
20847         if (ret_var.is_owned) {
20848                 ret_ref |= 1;
20849         }
20850         return ret_ref;
20851 }
20852
20853 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
20854         LDKNodeInfo obj_conv;
20855         obj_conv.inner = (void*)(obj & (~1));
20856         obj_conv.is_owned = false;
20857         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
20858         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20859         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20860         CVec_u8Z_free(ret_var);
20861         return ret_arr;
20862 }
20863
20864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20865         LDKu8slice ser_ref;
20866         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20867         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20868         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20869         *ret_conv = NodeInfo_read(ser_ref);
20870         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20871         return (long)ret_conv;
20872 }
20873
20874 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
20875         LDKNetworkGraph obj_conv;
20876         obj_conv.inner = (void*)(obj & (~1));
20877         obj_conv.is_owned = false;
20878         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
20879         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20880         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20881         CVec_u8Z_free(ret_var);
20882         return ret_arr;
20883 }
20884
20885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20886         LDKu8slice ser_ref;
20887         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20888         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20889         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20890         *ret_conv = NetworkGraph_read(ser_ref);
20891         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20892         return (long)ret_conv;
20893 }
20894
20895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
20896         LDKThirtyTwoBytes genesis_hash_ref;
20897         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
20898         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
20899         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
20900         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20901         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20902         long ret_ref = (long)ret_var.inner;
20903         if (ret_var.is_owned) {
20904                 ret_ref |= 1;
20905         }
20906         return ret_ref;
20907 }
20908
20909 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) {
20910         LDKNetworkGraph this_arg_conv;
20911         this_arg_conv.inner = (void*)(this_arg & (~1));
20912         this_arg_conv.is_owned = false;
20913         LDKNodeAnnouncement msg_conv;
20914         msg_conv.inner = (void*)(msg & (~1));
20915         msg_conv.is_owned = false;
20916         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20917         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
20918         return (long)ret_conv;
20919 }
20920
20921 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) {
20922         LDKNetworkGraph this_arg_conv;
20923         this_arg_conv.inner = (void*)(this_arg & (~1));
20924         this_arg_conv.is_owned = false;
20925         LDKUnsignedNodeAnnouncement msg_conv;
20926         msg_conv.inner = (void*)(msg & (~1));
20927         msg_conv.is_owned = false;
20928         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20929         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
20930         return (long)ret_conv;
20931 }
20932
20933 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) {
20934         LDKNetworkGraph this_arg_conv;
20935         this_arg_conv.inner = (void*)(this_arg & (~1));
20936         this_arg_conv.is_owned = false;
20937         LDKChannelAnnouncement msg_conv;
20938         msg_conv.inner = (void*)(msg & (~1));
20939         msg_conv.is_owned = false;
20940         LDKAccess *chain_access_conv_ptr = NULL;
20941         if (chain_access != 0) {
20942                 LDKAccess chain_access_conv;
20943                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20944                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
20945                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20946                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
20947                 }
20948                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20949                 *chain_access_conv_ptr = chain_access_conv;
20950         }
20951         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20952         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
20953         return (long)ret_conv;
20954 }
20955
20956 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) {
20957         LDKNetworkGraph this_arg_conv;
20958         this_arg_conv.inner = (void*)(this_arg & (~1));
20959         this_arg_conv.is_owned = false;
20960         LDKUnsignedChannelAnnouncement msg_conv;
20961         msg_conv.inner = (void*)(msg & (~1));
20962         msg_conv.is_owned = false;
20963         LDKAccess *chain_access_conv_ptr = NULL;
20964         if (chain_access != 0) {
20965                 LDKAccess chain_access_conv;
20966                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20967                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
20968                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20969                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
20970                 }
20971                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20972                 *chain_access_conv_ptr = chain_access_conv;
20973         }
20974         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20975         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
20976         return (long)ret_conv;
20977 }
20978
20979 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) {
20980         LDKNetworkGraph this_arg_conv;
20981         this_arg_conv.inner = (void*)(this_arg & (~1));
20982         this_arg_conv.is_owned = false;
20983         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
20984 }
20985
20986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
20987         LDKNetworkGraph this_arg_conv;
20988         this_arg_conv.inner = (void*)(this_arg & (~1));
20989         this_arg_conv.is_owned = false;
20990         LDKChannelUpdate msg_conv;
20991         msg_conv.inner = (void*)(msg & (~1));
20992         msg_conv.is_owned = false;
20993         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20994         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
20995         return (long)ret_conv;
20996 }
20997
20998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
20999         LDKNetworkGraph this_arg_conv;
21000         this_arg_conv.inner = (void*)(this_arg & (~1));
21001         this_arg_conv.is_owned = false;
21002         LDKUnsignedChannelUpdate msg_conv;
21003         msg_conv.inner = (void*)(msg & (~1));
21004         msg_conv.is_owned = false;
21005         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21006         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
21007         return (long)ret_conv;
21008 }
21009