Update auto-generated bindings
[ldk-java] / src / main / jni / bindings.c.body
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 LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
217         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
218                 case 0: return LDKIOError_NotFound;
219                 case 1: return LDKIOError_PermissionDenied;
220                 case 2: return LDKIOError_ConnectionRefused;
221                 case 3: return LDKIOError_ConnectionReset;
222                 case 4: return LDKIOError_ConnectionAborted;
223                 case 5: return LDKIOError_NotConnected;
224                 case 6: return LDKIOError_AddrInUse;
225                 case 7: return LDKIOError_AddrNotAvailable;
226                 case 8: return LDKIOError_BrokenPipe;
227                 case 9: return LDKIOError_AlreadyExists;
228                 case 10: return LDKIOError_WouldBlock;
229                 case 11: return LDKIOError_InvalidInput;
230                 case 12: return LDKIOError_InvalidData;
231                 case 13: return LDKIOError_TimedOut;
232                 case 14: return LDKIOError_WriteZero;
233                 case 15: return LDKIOError_Interrupted;
234                 case 16: return LDKIOError_Other;
235                 case 17: return LDKIOError_UnexpectedEof;
236         }
237         abort();
238 }
239 static jclass LDKIOError_class = NULL;
240 static jfieldID LDKIOError_LDKIOError_NotFound = NULL;
241 static jfieldID LDKIOError_LDKIOError_PermissionDenied = NULL;
242 static jfieldID LDKIOError_LDKIOError_ConnectionRefused = NULL;
243 static jfieldID LDKIOError_LDKIOError_ConnectionReset = NULL;
244 static jfieldID LDKIOError_LDKIOError_ConnectionAborted = NULL;
245 static jfieldID LDKIOError_LDKIOError_NotConnected = NULL;
246 static jfieldID LDKIOError_LDKIOError_AddrInUse = NULL;
247 static jfieldID LDKIOError_LDKIOError_AddrNotAvailable = NULL;
248 static jfieldID LDKIOError_LDKIOError_BrokenPipe = NULL;
249 static jfieldID LDKIOError_LDKIOError_AlreadyExists = NULL;
250 static jfieldID LDKIOError_LDKIOError_WouldBlock = NULL;
251 static jfieldID LDKIOError_LDKIOError_InvalidInput = NULL;
252 static jfieldID LDKIOError_LDKIOError_InvalidData = NULL;
253 static jfieldID LDKIOError_LDKIOError_TimedOut = NULL;
254 static jfieldID LDKIOError_LDKIOError_WriteZero = NULL;
255 static jfieldID LDKIOError_LDKIOError_Interrupted = NULL;
256 static jfieldID LDKIOError_LDKIOError_Other = NULL;
257 static jfieldID LDKIOError_LDKIOError_UnexpectedEof = NULL;
258 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKIOError_init (JNIEnv *env, jclass clz) {
259         LDKIOError_class = (*env)->NewGlobalRef(env, clz);
260         CHECK(LDKIOError_class != NULL);
261         LDKIOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/LDKIOError;");
262         CHECK(LDKIOError_LDKIOError_NotFound != NULL);
263         LDKIOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/LDKIOError;");
264         CHECK(LDKIOError_LDKIOError_PermissionDenied != NULL);
265         LDKIOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/LDKIOError;");
266         CHECK(LDKIOError_LDKIOError_ConnectionRefused != NULL);
267         LDKIOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/LDKIOError;");
268         CHECK(LDKIOError_LDKIOError_ConnectionReset != NULL);
269         LDKIOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/LDKIOError;");
270         CHECK(LDKIOError_LDKIOError_ConnectionAborted != NULL);
271         LDKIOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/LDKIOError;");
272         CHECK(LDKIOError_LDKIOError_NotConnected != NULL);
273         LDKIOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/LDKIOError;");
274         CHECK(LDKIOError_LDKIOError_AddrInUse != NULL);
275         LDKIOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/LDKIOError;");
276         CHECK(LDKIOError_LDKIOError_AddrNotAvailable != NULL);
277         LDKIOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/LDKIOError;");
278         CHECK(LDKIOError_LDKIOError_BrokenPipe != NULL);
279         LDKIOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/LDKIOError;");
280         CHECK(LDKIOError_LDKIOError_AlreadyExists != NULL);
281         LDKIOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/LDKIOError;");
282         CHECK(LDKIOError_LDKIOError_WouldBlock != NULL);
283         LDKIOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/LDKIOError;");
284         CHECK(LDKIOError_LDKIOError_InvalidInput != NULL);
285         LDKIOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/LDKIOError;");
286         CHECK(LDKIOError_LDKIOError_InvalidData != NULL);
287         LDKIOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/LDKIOError;");
288         CHECK(LDKIOError_LDKIOError_TimedOut != NULL);
289         LDKIOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/LDKIOError;");
290         CHECK(LDKIOError_LDKIOError_WriteZero != NULL);
291         LDKIOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/LDKIOError;");
292         CHECK(LDKIOError_LDKIOError_Interrupted != NULL);
293         LDKIOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_Other", "Lorg/ldk/enums/LDKIOError;");
294         CHECK(LDKIOError_LDKIOError_Other != NULL);
295         LDKIOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/LDKIOError;");
296         CHECK(LDKIOError_LDKIOError_UnexpectedEof != NULL);
297 }
298 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
299         switch (val) {
300                 case LDKIOError_NotFound:
301                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_NotFound);
302                 case LDKIOError_PermissionDenied:
303                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_PermissionDenied);
304                 case LDKIOError_ConnectionRefused:
305                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_ConnectionRefused);
306                 case LDKIOError_ConnectionReset:
307                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_ConnectionReset);
308                 case LDKIOError_ConnectionAborted:
309                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_ConnectionAborted);
310                 case LDKIOError_NotConnected:
311                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_NotConnected);
312                 case LDKIOError_AddrInUse:
313                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_AddrInUse);
314                 case LDKIOError_AddrNotAvailable:
315                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_AddrNotAvailable);
316                 case LDKIOError_BrokenPipe:
317                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_BrokenPipe);
318                 case LDKIOError_AlreadyExists:
319                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_AlreadyExists);
320                 case LDKIOError_WouldBlock:
321                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_WouldBlock);
322                 case LDKIOError_InvalidInput:
323                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_InvalidInput);
324                 case LDKIOError_InvalidData:
325                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_InvalidData);
326                 case LDKIOError_TimedOut:
327                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_TimedOut);
328                 case LDKIOError_WriteZero:
329                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_WriteZero);
330                 case LDKIOError_Interrupted:
331                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_Interrupted);
332                 case LDKIOError_Other:
333                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_Other);
334                 case LDKIOError_UnexpectedEof:
335                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_UnexpectedEof);
336                 default: abort();
337         }
338 }
339
340 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
341         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
342                 case 0: return LDKLevel_Off;
343                 case 1: return LDKLevel_Error;
344                 case 2: return LDKLevel_Warn;
345                 case 3: return LDKLevel_Info;
346                 case 4: return LDKLevel_Debug;
347                 case 5: return LDKLevel_Trace;
348         }
349         abort();
350 }
351 static jclass LDKLevel_class = NULL;
352 static jfieldID LDKLevel_LDKLevel_Off = NULL;
353 static jfieldID LDKLevel_LDKLevel_Error = NULL;
354 static jfieldID LDKLevel_LDKLevel_Warn = NULL;
355 static jfieldID LDKLevel_LDKLevel_Info = NULL;
356 static jfieldID LDKLevel_LDKLevel_Debug = NULL;
357 static jfieldID LDKLevel_LDKLevel_Trace = NULL;
358 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKLevel_init (JNIEnv *env, jclass clz) {
359         LDKLevel_class = (*env)->NewGlobalRef(env, clz);
360         CHECK(LDKLevel_class != NULL);
361         LDKLevel_LDKLevel_Off = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Off", "Lorg/ldk/enums/LDKLevel;");
362         CHECK(LDKLevel_LDKLevel_Off != NULL);
363         LDKLevel_LDKLevel_Error = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Error", "Lorg/ldk/enums/LDKLevel;");
364         CHECK(LDKLevel_LDKLevel_Error != NULL);
365         LDKLevel_LDKLevel_Warn = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Warn", "Lorg/ldk/enums/LDKLevel;");
366         CHECK(LDKLevel_LDKLevel_Warn != NULL);
367         LDKLevel_LDKLevel_Info = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Info", "Lorg/ldk/enums/LDKLevel;");
368         CHECK(LDKLevel_LDKLevel_Info != NULL);
369         LDKLevel_LDKLevel_Debug = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Debug", "Lorg/ldk/enums/LDKLevel;");
370         CHECK(LDKLevel_LDKLevel_Debug != NULL);
371         LDKLevel_LDKLevel_Trace = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Trace", "Lorg/ldk/enums/LDKLevel;");
372         CHECK(LDKLevel_LDKLevel_Trace != NULL);
373 }
374 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
375         switch (val) {
376                 case LDKLevel_Off:
377                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Off);
378                 case LDKLevel_Error:
379                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Error);
380                 case LDKLevel_Warn:
381                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Warn);
382                 case LDKLevel_Info:
383                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Info);
384                 case LDKLevel_Debug:
385                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Debug);
386                 case LDKLevel_Trace:
387                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Trace);
388                 default: abort();
389         }
390 }
391
392 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
393         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
394                 case 0: return LDKNetwork_Bitcoin;
395                 case 1: return LDKNetwork_Testnet;
396                 case 2: return LDKNetwork_Regtest;
397                 case 3: return LDKNetwork_Signet;
398         }
399         abort();
400 }
401 static jclass LDKNetwork_class = NULL;
402 static jfieldID LDKNetwork_LDKNetwork_Bitcoin = NULL;
403 static jfieldID LDKNetwork_LDKNetwork_Testnet = NULL;
404 static jfieldID LDKNetwork_LDKNetwork_Regtest = NULL;
405 static jfieldID LDKNetwork_LDKNetwork_Signet = NULL;
406 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKNetwork_init (JNIEnv *env, jclass clz) {
407         LDKNetwork_class = (*env)->NewGlobalRef(env, clz);
408         CHECK(LDKNetwork_class != NULL);
409         LDKNetwork_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/LDKNetwork;");
410         CHECK(LDKNetwork_LDKNetwork_Bitcoin != NULL);
411         LDKNetwork_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/LDKNetwork;");
412         CHECK(LDKNetwork_LDKNetwork_Testnet != NULL);
413         LDKNetwork_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/LDKNetwork;");
414         CHECK(LDKNetwork_LDKNetwork_Regtest != NULL);
415         LDKNetwork_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Signet", "Lorg/ldk/enums/LDKNetwork;");
416         CHECK(LDKNetwork_LDKNetwork_Signet != NULL);
417 }
418 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
419         switch (val) {
420                 case LDKNetwork_Bitcoin:
421                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Bitcoin);
422                 case LDKNetwork_Testnet:
423                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Testnet);
424                 case LDKNetwork_Regtest:
425                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Regtest);
426                 case LDKNetwork_Signet:
427                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Signet);
428                 default: abort();
429         }
430 }
431
432 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
433         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
434                 case 0: return LDKSecp256k1Error_IncorrectSignature;
435                 case 1: return LDKSecp256k1Error_InvalidMessage;
436                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
437                 case 3: return LDKSecp256k1Error_InvalidSignature;
438                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
439                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
440                 case 6: return LDKSecp256k1Error_InvalidTweak;
441                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
442                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
443         }
444         abort();
445 }
446 static jclass LDKSecp256k1Error_class = NULL;
447 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
448 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
449 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
450 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
451 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
452 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
453 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
454 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
455 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
456 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKSecp256k1Error_init (JNIEnv *env, jclass clz) {
457         LDKSecp256k1Error_class = (*env)->NewGlobalRef(env, clz);
458         CHECK(LDKSecp256k1Error_class != NULL);
459         LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
460         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
461         LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/LDKSecp256k1Error;");
462         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
463         LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
464         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
465         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
466         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
467         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
468         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
469         LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/LDKSecp256k1Error;");
470         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
471         LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/LDKSecp256k1Error;");
472         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
473         LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/LDKSecp256k1Error;");
474         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
475         LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/LDKSecp256k1Error;");
476         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
477 }
478 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
479         switch (val) {
480                 case LDKSecp256k1Error_IncorrectSignature:
481                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature);
482                 case LDKSecp256k1Error_InvalidMessage:
483                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage);
484                 case LDKSecp256k1Error_InvalidPublicKey:
485                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
486                 case LDKSecp256k1Error_InvalidSignature:
487                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature);
488                 case LDKSecp256k1Error_InvalidSecretKey:
489                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
490                 case LDKSecp256k1Error_InvalidRecoveryId:
491                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
492                 case LDKSecp256k1Error_InvalidTweak:
493                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak);
494                 case LDKSecp256k1Error_TweakCheckFailed:
495                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
496                 case LDKSecp256k1Error_NotEnoughMemory:
497                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
498                 default: abort();
499         }
500 }
501
502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
503         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
504         ret->datalen = (*env)->GetArrayLength(env, elems);
505         if (ret->datalen == 0) {
506                 ret->data = NULL;
507         } else {
508                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
509                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
510                 for (size_t i = 0; i < ret->datalen; i++) {
511                         ret->data[i] = java_elems[i];
512                 }
513                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
514         }
515         return (long)ret;
516 }
517 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
518         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
519         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
520         return ret;
521 }
522 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
523         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
524 }
525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
526         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
527         CHECK(val->result_ok);
528         LDKChannelConfig res_var = (*val->contents.result);
529         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
530         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
531         long res_ref = (long)res_var.inner & ~1;
532         return res_ref;
533 }
534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
535         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
536         CHECK(!val->result_ok);
537         LDKDecodeError err_var = (*val->contents.err);
538         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
539         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
540         long err_ref = (long)err_var.inner & ~1;
541         return err_ref;
542 }
543 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
544         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
545 }
546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
547         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
548         CHECK(val->result_ok);
549         LDKOutPoint res_var = (*val->contents.result);
550         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
551         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
552         long res_ref = (long)res_var.inner & ~1;
553         return res_ref;
554 }
555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
556         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
557         CHECK(!val->result_ok);
558         LDKDecodeError err_var = (*val->contents.err);
559         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
560         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
561         long err_ref = (long)err_var.inner & ~1;
562         return err_ref;
563 }
564 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
565         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
566 }
567 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
568         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
569         CHECK(val->result_ok);
570         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
571         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
572         return res_arr;
573 }
574 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
575         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
576         CHECK(!val->result_ok);
577         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
578         return err_conv;
579 }
580 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
581         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
582 }
583 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
584         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
585         CHECK(val->result_ok);
586         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
587         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
588         return res_arr;
589 }
590 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
591         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
592         CHECK(!val->result_ok);
593         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
594         return err_conv;
595 }
596 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
597         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
598 }
599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
600         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
601         CHECK(val->result_ok);
602         LDKTxCreationKeys res_var = (*val->contents.result);
603         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
604         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
605         long res_ref = (long)res_var.inner & ~1;
606         return res_ref;
607 }
608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
609         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
610         CHECK(!val->result_ok);
611         LDKDecodeError err_var = (*val->contents.err);
612         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
613         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
614         long err_ref = (long)err_var.inner & ~1;
615         return err_ref;
616 }
617 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
618         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
619 }
620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
621         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
622         CHECK(val->result_ok);
623         LDKChannelPublicKeys res_var = (*val->contents.result);
624         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
625         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
626         long res_ref = (long)res_var.inner & ~1;
627         return res_ref;
628 }
629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
630         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
631         CHECK(!val->result_ok);
632         LDKDecodeError err_var = (*val->contents.err);
633         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
634         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
635         long err_ref = (long)err_var.inner & ~1;
636         return err_ref;
637 }
638 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
639         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
640 }
641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
642         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
643         CHECK(val->result_ok);
644         LDKTxCreationKeys res_var = (*val->contents.result);
645         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
646         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
647         long res_ref = (long)res_var.inner & ~1;
648         return res_ref;
649 }
650 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
651         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
652         CHECK(!val->result_ok);
653         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
654         return err_conv;
655 }
656 static jclass LDKCOption_u32Z_Some_class = NULL;
657 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
658 static jclass LDKCOption_u32Z_None_class = NULL;
659 static jmethodID LDKCOption_u32Z_None_meth = NULL;
660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
661         LDKCOption_u32Z_Some_class =
662                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
663         CHECK(LDKCOption_u32Z_Some_class != NULL);
664         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
665         CHECK(LDKCOption_u32Z_Some_meth != NULL);
666         LDKCOption_u32Z_None_class =
667                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
668         CHECK(LDKCOption_u32Z_None_class != NULL);
669         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
670         CHECK(LDKCOption_u32Z_None_meth != NULL);
671 }
672 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
673         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
674         switch(obj->tag) {
675                 case LDKCOption_u32Z_Some: {
676                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
677                 }
678                 case LDKCOption_u32Z_None: {
679                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
680                 }
681                 default: abort();
682         }
683 }
684 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
685         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
686 }
687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
688         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
689         CHECK(val->result_ok);
690         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
691         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
692         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
693         long res_ref = (long)res_var.inner & ~1;
694         return res_ref;
695 }
696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
697         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
698         CHECK(!val->result_ok);
699         LDKDecodeError err_var = (*val->contents.err);
700         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
701         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
702         long err_ref = (long)err_var.inner & ~1;
703         return err_ref;
704 }
705 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
706         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
707 }
708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
709         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
710         CHECK(val->result_ok);
711         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
712         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
713         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
714         long res_ref = (long)res_var.inner & ~1;
715         return res_ref;
716 }
717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
718         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
719         CHECK(!val->result_ok);
720         LDKDecodeError err_var = (*val->contents.err);
721         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
722         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
723         long err_ref = (long)err_var.inner & ~1;
724         return err_ref;
725 }
726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
727         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
728 }
729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
730         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
731         CHECK(val->result_ok);
732         LDKChannelTransactionParameters res_var = (*val->contents.result);
733         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
734         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
735         long res_ref = (long)res_var.inner & ~1;
736         return res_ref;
737 }
738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
739         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
740         CHECK(!val->result_ok);
741         LDKDecodeError err_var = (*val->contents.err);
742         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
743         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
744         long err_ref = (long)err_var.inner & ~1;
745         return err_ref;
746 }
747 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
748         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
749 }
750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
751         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
752         CHECK(val->result_ok);
753         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
754         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
755         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
756         long res_ref = (long)res_var.inner & ~1;
757         return res_ref;
758 }
759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
760         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
761         CHECK(!val->result_ok);
762         LDKDecodeError err_var = (*val->contents.err);
763         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
764         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
765         long err_ref = (long)err_var.inner & ~1;
766         return err_ref;
767 }
768 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
769         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
770 }
771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
772         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
773         CHECK(val->result_ok);
774         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
775         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
776         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
777         long res_ref = (long)res_var.inner & ~1;
778         return res_ref;
779 }
780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
781         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
782         CHECK(!val->result_ok);
783         LDKDecodeError err_var = (*val->contents.err);
784         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
785         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
786         long err_ref = (long)err_var.inner & ~1;
787         return err_ref;
788 }
789 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
790         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
791 }
792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
793         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
794         CHECK(val->result_ok);
795         LDKCommitmentTransaction res_var = (*val->contents.result);
796         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
797         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
798         long res_ref = (long)res_var.inner & ~1;
799         return res_ref;
800 }
801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
802         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
803         CHECK(!val->result_ok);
804         LDKDecodeError err_var = (*val->contents.err);
805         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
806         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
807         long err_ref = (long)err_var.inner & ~1;
808         return err_ref;
809 }
810 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
811         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
812 }
813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
814         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
815         CHECK(val->result_ok);
816         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
817         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
818         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
819         long res_ref = (long)res_var.inner & ~1;
820         return res_ref;
821 }
822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
823         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
824         CHECK(!val->result_ok);
825         return *val->contents.err;
826 }
827 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
828         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
829 }
830 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
831         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
832         CHECK(val->result_ok);
833         LDKCVec_SignatureZ res_var = (*val->contents.result);
834         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
835         ;
836         for (size_t i = 0; i < res_var.datalen; i++) {
837                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
838                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
839                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
840         }
841         return res_arr;
842 }
843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
844         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
845         CHECK(!val->result_ok);
846         return *val->contents.err;
847 }
848 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
849         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
850 }
851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
852         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
853         CHECK(val->result_ok);
854         LDKChannelMonitorUpdate res_var = (*val->contents.result);
855         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
856         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
857         long res_ref = (long)res_var.inner & ~1;
858         return res_ref;
859 }
860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
861         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
862         CHECK(!val->result_ok);
863         LDKDecodeError err_var = (*val->contents.err);
864         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
865         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
866         long err_ref = (long)err_var.inner & ~1;
867         return err_ref;
868 }
869 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
870         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
871 }
872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
873         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
874         CHECK(val->result_ok);
875         LDKHTLCUpdate res_var = (*val->contents.result);
876         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
877         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
878         long res_ref = (long)res_var.inner & ~1;
879         return res_ref;
880 }
881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
882         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
883         CHECK(!val->result_ok);
884         LDKDecodeError err_var = (*val->contents.err);
885         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
886         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
887         long err_ref = (long)err_var.inner & ~1;
888         return err_ref;
889 }
890 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
891         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
892 }
893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
894         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
895         CHECK(val->result_ok);
896         return *val->contents.result;
897 }
898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
899         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
900         CHECK(!val->result_ok);
901         LDKMonitorUpdateError err_var = (*val->contents.err);
902         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
903         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
904         long err_ref = (long)err_var.inner & ~1;
905         return err_ref;
906 }
907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
908         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
909         LDKOutPoint a_conv;
910         a_conv.inner = (void*)(a & (~1));
911         a_conv.is_owned = (a & 1) || (a == 0);
912         a_conv = OutPoint_clone(&a_conv);
913         ret->a = a_conv;
914         LDKCVec_u8Z b_ref;
915         b_ref.datalen = (*env)->GetArrayLength(env, b);
916         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
917         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
918         ret->b = b_ref;
919         return (long)ret;
920 }
921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
922         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
923         LDKOutPoint a_var = tuple->a;
924         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
925         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
926         long a_ref = (long)a_var.inner & ~1;
927         return a_ref;
928 }
929 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
930         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
931         LDKCVec_u8Z b_var = tuple->b;
932         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
933         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
934         return b_arr;
935 }
936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
937         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
938         ret->a = a;
939         LDKCVec_u8Z b_ref;
940         b_ref.datalen = (*env)->GetArrayLength(env, b);
941         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
942         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
943         ret->b = b_ref;
944         return (long)ret;
945 }
946 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
947         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
948         return tuple->a;
949 }
950 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
951         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
952         LDKCVec_u8Z b_var = tuple->b;
953         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
954         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
955         return b_arr;
956 }
957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
958         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
959         ret->datalen = (*env)->GetArrayLength(env, elems);
960         if (ret->datalen == 0) {
961                 ret->data = NULL;
962         } else {
963                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
964                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
965                 for (size_t i = 0; i < ret->datalen; i++) {
966                         int64_t arr_elem = java_elems[i];
967                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
968                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_u32ScriptZ
969                         ret->data[i] = arr_elem_conv;
970                 }
971                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
972         }
973         return (long)ret;
974 }
975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
976         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
977         LDKThirtyTwoBytes a_ref;
978         CHECK((*env)->GetArrayLength(env, a) == 32);
979         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
980         ret->a = a_ref;
981         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
982         b_constr.datalen = (*env)->GetArrayLength(env, b);
983         if (b_constr.datalen > 0)
984                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
985         else
986                 b_constr.data = NULL;
987         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
988         for (size_t b = 0; b < b_constr.datalen; b++) {
989                 int64_t b_conv_27 = b_vals[b];
990                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
991                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_u32ScriptZ
992                 b_constr.data[b] = b_conv_27_conv;
993         }
994         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
995         ret->b = b_constr;
996         return (long)ret;
997 }
998 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
999         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
1000         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
1001         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
1002         return a_arr;
1003 }
1004 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1005         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
1006         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
1007         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
1008         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
1009         for (size_t b = 0; b < b_var.datalen; b++) {
1010                 long b_conv_27_ref = (long)(&b_var.data[b]) | 1;
1011                 b_arr_ptr[b] = b_conv_27_ref;
1012         }
1013         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
1014         return b_arr;
1015 }
1016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1017         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
1018         ret->datalen = (*env)->GetArrayLength(env, elems);
1019         if (ret->datalen == 0) {
1020                 ret->data = NULL;
1021         } else {
1022                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
1023                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1024                 for (size_t i = 0; i < ret->datalen; i++) {
1025                         int64_t arr_elem = java_elems[i];
1026                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
1027                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ
1028                         ret->data[i] = arr_elem_conv;
1029                 }
1030                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1031         }
1032         return (long)ret;
1033 }
1034 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1035 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1036 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1037 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1039         LDKMonitorEvent_HTLCEvent_class =
1040                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1041         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1042         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1043         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1044         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1045                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1046         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1047         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "(J)V");
1048         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1049 }
1050 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1051         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1052         switch(obj->tag) {
1053                 case LDKMonitorEvent_HTLCEvent: {
1054                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1055                         CHECK((((long)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1056                         CHECK((((long)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1057                         long htlc_event_ref = (long)htlc_event_var.inner & ~1;
1058                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1059                 }
1060                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1061                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
1062                         CHECK((((long)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1063                         CHECK((((long)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1064                         long commitment_tx_broadcasted_ref = (long)commitment_tx_broadcasted_var.inner & ~1;
1065                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref);
1066                 }
1067                 default: abort();
1068         }
1069 }
1070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1071         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1072         ret->datalen = (*env)->GetArrayLength(env, elems);
1073         if (ret->datalen == 0) {
1074                 ret->data = NULL;
1075         } else {
1076                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1077                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1078                 for (size_t i = 0; i < ret->datalen; i++) {
1079                         int64_t arr_elem = java_elems[i];
1080                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1081                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1082                         ret->data[i] = arr_elem_conv;
1083                 }
1084                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1085         }
1086         return (long)ret;
1087 }
1088 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1089         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1090         for (size_t i = 0; i < ret.datalen; i++) {
1091                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1092         }
1093         return ret;
1094 }
1095 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1096 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1097 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1098 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1099 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1100 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1102         LDKSpendableOutputDescriptor_StaticOutput_class =
1103                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1104         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1105         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1106         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1107         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1108                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1109         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1110         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1111         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1112         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1113                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1114         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1115         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1116         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1117 }
1118 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1119         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1120         switch(obj->tag) {
1121                 case LDKSpendableOutputDescriptor_StaticOutput: {
1122                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1123                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1124                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1125                         long outpoint_ref = (long)outpoint_var.inner & ~1;
1126                         long output_ref = ((long)&obj->static_output.output) | 1;
1127                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (long)output_ref);
1128                 }
1129                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1130                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1131                         CHECK((((long)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1132                         CHECK((((long)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1133                         long delayed_payment_output_ref = (long)delayed_payment_output_var.inner & ~1;
1134                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1135                 }
1136                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1137                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1138                         CHECK((((long)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1139                         CHECK((((long)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1140                         long static_payment_output_ref = (long)static_payment_output_var.inner & ~1;
1141                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1142                 }
1143                 default: abort();
1144         }
1145 }
1146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1147         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1148         ret->datalen = (*env)->GetArrayLength(env, elems);
1149         if (ret->datalen == 0) {
1150                 ret->data = NULL;
1151         } else {
1152                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1153                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1154                 for (size_t i = 0; i < ret->datalen; i++) {
1155                         int64_t arr_elem = java_elems[i];
1156                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1157                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1158                         ret->data[i] = arr_elem_conv;
1159                 }
1160                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1161         }
1162         return (long)ret;
1163 }
1164 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1165         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1166         for (size_t i = 0; i < ret.datalen; i++) {
1167                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1168         }
1169         return ret;
1170 }
1171 static jclass LDKEvent_FundingGenerationReady_class = NULL;
1172 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
1173 static jclass LDKEvent_PaymentReceived_class = NULL;
1174 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
1175 static jclass LDKEvent_PaymentSent_class = NULL;
1176 static jmethodID LDKEvent_PaymentSent_meth = NULL;
1177 static jclass LDKEvent_PaymentFailed_class = NULL;
1178 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
1179 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
1180 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
1181 static jclass LDKEvent_SpendableOutputs_class = NULL;
1182 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
1183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
1184         LDKEvent_FundingGenerationReady_class =
1185                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
1186         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
1187         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
1188         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
1189         LDKEvent_PaymentReceived_class =
1190                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
1191         CHECK(LDKEvent_PaymentReceived_class != NULL);
1192         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[BJ)V");
1193         CHECK(LDKEvent_PaymentReceived_meth != NULL);
1194         LDKEvent_PaymentSent_class =
1195                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
1196         CHECK(LDKEvent_PaymentSent_class != NULL);
1197         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
1198         CHECK(LDKEvent_PaymentSent_meth != NULL);
1199         LDKEvent_PaymentFailed_class =
1200                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
1201         CHECK(LDKEvent_PaymentFailed_class != NULL);
1202         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
1203         CHECK(LDKEvent_PaymentFailed_meth != NULL);
1204         LDKEvent_PendingHTLCsForwardable_class =
1205                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
1206         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
1207         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
1208         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
1209         LDKEvent_SpendableOutputs_class =
1210                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
1211         CHECK(LDKEvent_SpendableOutputs_class != NULL);
1212         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
1213         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
1214 }
1215 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1216         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1217         switch(obj->tag) {
1218                 case LDKEvent_FundingGenerationReady: {
1219                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
1220                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
1221                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1222                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
1223                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
1224                         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);
1225                 }
1226                 case LDKEvent_PaymentReceived: {
1227                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1228                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
1229                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1230                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
1231                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_secret_arr, obj->payment_received.amt);
1232                 }
1233                 case LDKEvent_PaymentSent: {
1234                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1235                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
1236                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
1237                 }
1238                 case LDKEvent_PaymentFailed: {
1239                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1240                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
1241                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
1242                 }
1243                 case LDKEvent_PendingHTLCsForwardable: {
1244                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
1245                 }
1246                 case LDKEvent_SpendableOutputs: {
1247                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1248                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
1249                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
1250                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1251                                 long outputs_conv_27_ref = ((long)&outputs_var.data[b]) | 1;
1252                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1253                         }
1254                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
1255                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
1256                 }
1257                 default: abort();
1258         }
1259 }
1260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1261         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
1262         ret->datalen = (*env)->GetArrayLength(env, elems);
1263         if (ret->datalen == 0) {
1264                 ret->data = NULL;
1265         } else {
1266                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
1267                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1268                 for (size_t i = 0; i < ret->datalen; i++) {
1269                         int64_t arr_elem = java_elems[i];
1270                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
1271                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
1272                         ret->data[i] = arr_elem_conv;
1273                 }
1274                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1275         }
1276         return (long)ret;
1277 }
1278 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
1279         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
1280         for (size_t i = 0; i < ret.datalen; i++) {
1281                 ret.data[i] = Event_clone(&orig->data[i]);
1282         }
1283         return ret;
1284 }
1285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1286         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1287         ret->a = a;
1288         LDKTransaction b_ref;
1289         b_ref.datalen = (*env)->GetArrayLength(env, b);
1290         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1291         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1292         b_ref.data_is_owned = false;
1293         ret->b = b_ref;
1294         return (long)ret;
1295 }
1296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1297         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1298         return tuple->a;
1299 }
1300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1301         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1302         LDKTransaction b_var = tuple->b;
1303         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1304         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1305         return b_arr;
1306 }
1307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1308         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1309         ret->datalen = (*env)->GetArrayLength(env, elems);
1310         if (ret->datalen == 0) {
1311                 ret->data = NULL;
1312         } else {
1313                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1314                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1315                 for (size_t i = 0; i < ret->datalen; i++) {
1316                         int64_t arr_elem = java_elems[i];
1317                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1318                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
1319                         ret->data[i] = arr_elem_conv;
1320                 }
1321                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1322         }
1323         return (long)ret;
1324 }
1325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
1326         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
1327         ret->a = a;
1328         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
1329         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
1330         ret->b = b_conv;
1331         return (long)ret;
1332 }
1333 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1334         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
1335         return tuple->a;
1336 }
1337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1338         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
1339         long b_ref = ((long)&tuple->b) | 1;
1340         return (long)b_ref;
1341 }
1342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1343         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
1344         ret->datalen = (*env)->GetArrayLength(env, elems);
1345         if (ret->datalen == 0) {
1346                 ret->data = NULL;
1347         } else {
1348                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
1349                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1350                 for (size_t i = 0; i < ret->datalen; i++) {
1351                         int64_t arr_elem = java_elems[i];
1352                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
1353                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
1354                         ret->data[i] = arr_elem_conv;
1355                 }
1356                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1357         }
1358         return (long)ret;
1359 }
1360 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
1361         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
1362         for (size_t i = 0; i < ret.datalen; i++) {
1363                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
1364         }
1365         return ret;
1366 }
1367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
1368         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
1369         LDKThirtyTwoBytes a_ref;
1370         CHECK((*env)->GetArrayLength(env, a) == 32);
1371         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
1372         ret->a = a_ref;
1373         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
1374         b_constr.datalen = (*env)->GetArrayLength(env, b);
1375         if (b_constr.datalen > 0)
1376                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
1377         else
1378                 b_constr.data = NULL;
1379         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
1380         for (size_t a = 0; a < b_constr.datalen; a++) {
1381                 int64_t b_conv_26 = b_vals[a];
1382                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
1383                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
1384                 b_constr.data[a] = b_conv_26_conv;
1385         }
1386         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
1387         ret->b = b_constr;
1388         return (long)ret;
1389 }
1390 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1391         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
1392         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
1393         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
1394         return a_arr;
1395 }
1396 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1397         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
1398         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
1399         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
1400         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
1401         for (size_t a = 0; a < b_var.datalen; a++) {
1402                 long b_conv_26_ref = (long)(&b_var.data[a]) | 1;
1403                 b_arr_ptr[a] = b_conv_26_ref;
1404         }
1405         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
1406         return b_arr;
1407 }
1408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1409         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
1410         ret->datalen = (*env)->GetArrayLength(env, elems);
1411         if (ret->datalen == 0) {
1412                 ret->data = NULL;
1413         } else {
1414                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
1415                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1416                 for (size_t i = 0; i < ret->datalen; i++) {
1417                         int64_t arr_elem = java_elems[i];
1418                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
1419                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ
1420                         ret->data[i] = arr_elem_conv;
1421                 }
1422                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1423         }
1424         return (long)ret;
1425 }
1426 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1427         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1428         for (size_t i = 0; i < ret.datalen; i++) {
1429                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1430         }
1431         return ret;
1432 }
1433 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1434         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1435 }
1436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1437         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1438         CHECK(val->result_ok);
1439         return *val->contents.result;
1440 }
1441 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1442         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1443         CHECK(!val->result_ok);
1444         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1445         return err_conv;
1446 }
1447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
1448         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1449         LDKSignature a_ref;
1450         CHECK((*env)->GetArrayLength(env, a) == 64);
1451         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
1452         ret->a = a_ref;
1453         LDKCVec_SignatureZ b_constr;
1454         b_constr.datalen = (*env)->GetArrayLength(env, b);
1455         if (b_constr.datalen > 0)
1456                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
1457         else
1458                 b_constr.data = NULL;
1459         for (size_t i = 0; i < b_constr.datalen; i++) {
1460                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
1461                 LDKSignature b_conv_8_ref;
1462                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
1463                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
1464                 b_constr.data[i] = b_conv_8_ref;
1465         }
1466         ret->b = b_constr;
1467         return (long)ret;
1468 }
1469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1470         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1471         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
1472         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
1473         return a_arr;
1474 }
1475 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1476         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1477         LDKCVec_SignatureZ b_var = tuple->b;
1478         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
1479         ;
1480         for (size_t i = 0; i < b_var.datalen; i++) {
1481                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
1482                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
1483                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
1484         }
1485         return b_arr;
1486 }
1487 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1488         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
1489 }
1490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1491         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1492         CHECK(val->result_ok);
1493         long res_ref = (long)(&(*val->contents.result)) | 1;
1494         return res_ref;
1495 }
1496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1497         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1498         CHECK(!val->result_ok);
1499         return *val->contents.err;
1500 }
1501 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1502         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
1503 }
1504 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1505         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1506         CHECK(val->result_ok);
1507         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
1508         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
1509         return res_arr;
1510 }
1511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1512         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1513         CHECK(!val->result_ok);
1514         return *val->contents.err;
1515 }
1516 typedef struct LDKBaseSign_JCalls {
1517         atomic_size_t refcnt;
1518         JavaVM *vm;
1519         jweak o;
1520         jmethodID get_per_commitment_point_meth;
1521         jmethodID release_commitment_secret_meth;
1522         jmethodID channel_keys_id_meth;
1523         jmethodID sign_counterparty_commitment_meth;
1524         jmethodID sign_holder_commitment_and_htlcs_meth;
1525         jmethodID sign_justice_transaction_meth;
1526         jmethodID sign_counterparty_htlc_transaction_meth;
1527         jmethodID sign_closing_transaction_meth;
1528         jmethodID sign_channel_announcement_meth;
1529         jmethodID ready_channel_meth;
1530 } LDKBaseSign_JCalls;
1531 static void LDKBaseSign_JCalls_free(void* this_arg) {
1532         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1533         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1534                 JNIEnv *env;
1535                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1536                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1537                 FREE(j_calls);
1538         }
1539 }
1540 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1541         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1542         JNIEnv *env;
1543         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1544         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1545         CHECK(obj != NULL);
1546         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
1547         LDKPublicKey ret_ref;
1548         CHECK((*env)->GetArrayLength(env, ret) == 33);
1549         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
1550         return ret_ref;
1551 }
1552 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1553         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1554         JNIEnv *env;
1555         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1556         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1557         CHECK(obj != NULL);
1558         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
1559         LDKThirtyTwoBytes ret_ref;
1560         CHECK((*env)->GetArrayLength(env, ret) == 32);
1561         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
1562         return ret_ref;
1563 }
1564 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1565         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1566         JNIEnv *env;
1567         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1568         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1569         CHECK(obj != NULL);
1570         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
1571         LDKThirtyTwoBytes ret_ref;
1572         CHECK((*env)->GetArrayLength(env, ret) == 32);
1573         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
1574         return ret_ref;
1575 }
1576 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1577         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1578         JNIEnv *env;
1579         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1580         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1581         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1582         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1583         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1584         long commitment_tx_ref = (long)commitment_tx_var.inner;
1585         if (commitment_tx_var.is_owned) {
1586                 commitment_tx_ref |= 1;
1587         }
1588         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1589         CHECK(obj != NULL);
1590         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1591         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1592         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1593         return ret_conv;
1594 }
1595 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1596         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1597         JNIEnv *env;
1598         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1599         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1600         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1601         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1602         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1603         long commitment_tx_ref = (long)commitment_tx_var.inner;
1604         if (commitment_tx_var.is_owned) {
1605                 commitment_tx_ref |= 1;
1606         }
1607         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1608         CHECK(obj != NULL);
1609         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1610         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1611         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1612         return ret_conv;
1613 }
1614 LDKCResult_SignatureNoneZ sign_justice_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
1615         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1616         JNIEnv *env;
1617         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1618         LDKTransaction justice_tx_var = justice_tx;
1619         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
1620         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
1621         Transaction_free(justice_tx_var);
1622         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
1623         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
1624         LDKHTLCOutputInCommitment htlc_var = *htlc;
1625         htlc_var = HTLCOutputInCommitment_clone(htlc);
1626         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1627         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1628         long htlc_ref = (long)htlc_var.inner;
1629         if (htlc_var.is_owned) {
1630                 htlc_ref |= 1;
1631         }
1632         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1633         CHECK(obj != NULL);
1634         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);
1635         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1636         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1637         return ret_conv;
1638 }
1639 LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
1640         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1641         JNIEnv *env;
1642         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1643         LDKTransaction htlc_tx_var = htlc_tx;
1644         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
1645         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
1646         Transaction_free(htlc_tx_var);
1647         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
1648         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
1649         LDKHTLCOutputInCommitment htlc_var = *htlc;
1650         htlc_var = HTLCOutputInCommitment_clone(htlc);
1651         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1652         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1653         long htlc_ref = (long)htlc_var.inner;
1654         if (htlc_var.is_owned) {
1655                 htlc_ref |= 1;
1656         }
1657         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1658         CHECK(obj != NULL);
1659         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);
1660         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1661         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1662         return ret_conv;
1663 }
1664 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
1665         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1666         JNIEnv *env;
1667         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1668         LDKTransaction closing_tx_var = closing_tx;
1669         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
1670         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
1671         Transaction_free(closing_tx_var);
1672         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1673         CHECK(obj != NULL);
1674         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
1675         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1676         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1677         return ret_conv;
1678 }
1679 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1680         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1681         JNIEnv *env;
1682         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1683         LDKUnsignedChannelAnnouncement msg_var = *msg;
1684         msg_var = UnsignedChannelAnnouncement_clone(msg);
1685         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1686         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1687         long msg_ref = (long)msg_var.inner;
1688         if (msg_var.is_owned) {
1689                 msg_ref |= 1;
1690         }
1691         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1692         CHECK(obj != NULL);
1693         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
1694         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1695         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1696         return ret_conv;
1697 }
1698 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1699         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1700         JNIEnv *env;
1701         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1702         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1703         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1704         CHECK((((long)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1705         CHECK((((long)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1706         long channel_parameters_ref = (long)channel_parameters_var.inner;
1707         if (channel_parameters_var.is_owned) {
1708                 channel_parameters_ref |= 1;
1709         }
1710         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1711         CHECK(obj != NULL);
1712         return (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
1713 }
1714 static void* LDKBaseSign_JCalls_clone(const void* this_arg) {
1715         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1716         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1717         return (void*) this_arg;
1718 }
1719 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
1720         jclass c = (*env)->GetObjectClass(env, o);
1721         CHECK(c != NULL);
1722         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
1723         atomic_init(&calls->refcnt, 1);
1724         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1725         calls->o = (*env)->NewWeakGlobalRef(env, o);
1726         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
1727         CHECK(calls->get_per_commitment_point_meth != NULL);
1728         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
1729         CHECK(calls->release_commitment_secret_meth != NULL);
1730         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
1731         CHECK(calls->channel_keys_id_meth != NULL);
1732         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
1733         CHECK(calls->sign_counterparty_commitment_meth != NULL);
1734         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
1735         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
1736         calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "([BJJ[BJ)J");
1737         CHECK(calls->sign_justice_transaction_meth != NULL);
1738         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
1739         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
1740         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
1741         CHECK(calls->sign_closing_transaction_meth != NULL);
1742         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
1743         CHECK(calls->sign_channel_announcement_meth != NULL);
1744         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
1745         CHECK(calls->ready_channel_meth != NULL);
1746
1747         LDKChannelPublicKeys pubkeys_conv;
1748         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1749         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1750         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1751
1752         LDKBaseSign ret = {
1753                 .this_arg = (void*) calls,
1754                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
1755                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
1756                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
1757                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
1758                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
1759                 .sign_justice_transaction = sign_justice_transaction_LDKBaseSign_jcall,
1760                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
1761                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
1762                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
1763                 .ready_channel = ready_channel_LDKBaseSign_jcall,
1764                 .free = LDKBaseSign_JCalls_free,
1765                 .pubkeys = pubkeys_conv,
1766                 .set_pubkeys = NULL,
1767         };
1768         return ret;
1769 }
1770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
1771         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
1772         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
1773         return (long)res_ptr;
1774 }
1775 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
1776         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1777         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
1778         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
1779         return ret_arr;
1780 }
1781
1782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
1783         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1784         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1785         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
1786         return ret_arr;
1787 }
1788
1789 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
1790         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1791         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1792         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
1793         return ret_arr;
1794 }
1795
1796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
1797         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1798         LDKCommitmentTransaction commitment_tx_conv;
1799         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1800         commitment_tx_conv.is_owned = false;
1801         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1802         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1803         return (long)ret_conv;
1804 }
1805
1806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1holder_1commitment_1and_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
1807         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1808         LDKHolderCommitmentTransaction commitment_tx_conv;
1809         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1810         commitment_tx_conv.is_owned = false;
1811         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1812         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
1813         return (long)ret_conv;
1814 }
1815
1816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_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) {
1817         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1818         LDKTransaction justice_tx_ref;
1819         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
1820         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1821         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
1822         justice_tx_ref.data_is_owned = true;
1823         unsigned char per_commitment_key_arr[32];
1824         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
1825         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
1826         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1827         LDKHTLCOutputInCommitment htlc_conv;
1828         htlc_conv.inner = (void*)(htlc & (~1));
1829         htlc_conv.is_owned = false;
1830         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1831         *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
1832         return (long)ret_conv;
1833 }
1834
1835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1htlc_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, int64_t htlc) {
1836         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1837         LDKTransaction htlc_tx_ref;
1838         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
1839         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1840         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
1841         htlc_tx_ref.data_is_owned = true;
1842         LDKPublicKey per_commitment_point_ref;
1843         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
1844         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
1845         LDKHTLCOutputInCommitment htlc_conv;
1846         htlc_conv.inner = (void*)(htlc & (~1));
1847         htlc_conv.is_owned = false;
1848         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1849         *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);
1850         return (long)ret_conv;
1851 }
1852
1853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray closing_tx) {
1854         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1855         LDKTransaction closing_tx_ref;
1856         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
1857         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
1858         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
1859         closing_tx_ref.data_is_owned = true;
1860         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1861         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
1862         return (long)ret_conv;
1863 }
1864
1865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
1866         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1867         LDKUnsignedChannelAnnouncement msg_conv;
1868         msg_conv.inner = (void*)(msg & (~1));
1869         msg_conv.is_owned = false;
1870         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1871         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1872         return (long)ret_conv;
1873 }
1874
1875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
1876         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1877         LDKChannelTransactionParameters channel_parameters_conv;
1878         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
1879         channel_parameters_conv.is_owned = false;
1880         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
1881 }
1882
1883 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
1884         if (this_arg->set_pubkeys != NULL)
1885                 this_arg->set_pubkeys(this_arg);
1886         return this_arg->pubkeys;
1887 }
1888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
1889         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1890         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
1891         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1892         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1893         long ret_ref = (long)ret_var.inner;
1894         if (ret_var.is_owned) {
1895                 ret_ref |= 1;
1896         }
1897         return ret_ref;
1898 }
1899
1900 typedef struct LDKSign_JCalls {
1901         atomic_size_t refcnt;
1902         JavaVM *vm;
1903         jweak o;
1904         LDKBaseSign_JCalls* BaseSign;
1905         jmethodID write_meth;
1906 } LDKSign_JCalls;
1907 static void LDKSign_JCalls_free(void* this_arg) {
1908         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1909         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1910                 JNIEnv *env;
1911                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1912                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1913                 FREE(j_calls);
1914         }
1915 }
1916 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
1917         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1918         JNIEnv *env;
1919         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1920         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1921         CHECK(obj != NULL);
1922         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
1923         LDKCVec_u8Z ret_ref;
1924         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
1925         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1926         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
1927         return ret_ref;
1928 }
1929 static void* LDKSign_JCalls_clone(const void* this_arg) {
1930         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1931         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1932         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
1933         return (void*) this_arg;
1934 }
1935 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
1936         jclass c = (*env)->GetObjectClass(env, o);
1937         CHECK(c != NULL);
1938         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
1939         atomic_init(&calls->refcnt, 1);
1940         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1941         calls->o = (*env)->NewWeakGlobalRef(env, o);
1942         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
1943         CHECK(calls->write_meth != NULL);
1944
1945         LDKChannelPublicKeys pubkeys_conv;
1946         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1947         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1948         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1949
1950         LDKSign ret = {
1951                 .this_arg = (void*) calls,
1952                 .write = write_LDKSign_jcall,
1953                 .clone = LDKSign_JCalls_clone,
1954                 .free = LDKSign_JCalls_free,
1955                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
1956         };
1957         calls->BaseSign = ret.BaseSign.this_arg;
1958         return ret;
1959 }
1960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
1961         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
1962         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
1963         return (long)res_ptr;
1964 }
1965 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
1966         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1967         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
1968         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1969         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1970         CVec_u8Z_free(ret_var);
1971         return ret_arr;
1972 }
1973
1974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
1975         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
1976         LDKThirtyTwoBytes a_ref;
1977         CHECK((*env)->GetArrayLength(env, a) == 32);
1978         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
1979         ret->a = a_ref;
1980         LDKChannelMonitor b_conv;
1981         b_conv.inner = (void*)(b & (~1));
1982         b_conv.is_owned = (b & 1) || (b == 0);
1983         b_conv = ChannelMonitor_clone(&b_conv);
1984         ret->b = b_conv;
1985         return (long)ret;
1986 }
1987 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1988         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1989         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
1990         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
1991         return a_arr;
1992 }
1993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1994         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1995         LDKChannelMonitor b_var = tuple->b;
1996         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1997         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1998         long b_ref = (long)b_var.inner & ~1;
1999         return b_ref;
2000 }
2001 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2002         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
2003 }
2004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2005         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2006         CHECK(val->result_ok);
2007         long res_ref = (long)(&(*val->contents.result)) | 1;
2008         return res_ref;
2009 }
2010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2011         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2012         CHECK(!val->result_ok);
2013         LDKDecodeError err_var = (*val->contents.err);
2014         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2015         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2016         long err_ref = (long)err_var.inner & ~1;
2017         return err_ref;
2018 }
2019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2020         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
2021         ret->datalen = (*env)->GetArrayLength(env, elems);
2022         if (ret->datalen == 0) {
2023                 ret->data = NULL;
2024         } else {
2025                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
2026                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2027                 for (size_t i = 0; i < ret->datalen; i++) {
2028                         int64_t arr_elem = java_elems[i];
2029                         LDKRouteHop arr_elem_conv;
2030                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2031                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2032                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
2033                         ret->data[i] = arr_elem_conv;
2034                 }
2035                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2036         }
2037         return (long)ret;
2038 }
2039 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
2040         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
2041         for (size_t i = 0; i < ret.datalen; i++) {
2042                 ret.data[i] = RouteHop_clone(&orig->data[i]);
2043         }
2044         return ret;
2045 }
2046 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2047         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2048         for (size_t i = 0; i < ret.datalen; i++) {
2049                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2050         }
2051         return ret;
2052 }
2053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2054         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
2055 }
2056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2057         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
2058         CHECK(val->result_ok);
2059         LDKRoute res_var = (*val->contents.result);
2060         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2061         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2062         long res_ref = (long)res_var.inner & ~1;
2063         return res_ref;
2064 }
2065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2066         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
2067         CHECK(!val->result_ok);
2068         LDKDecodeError err_var = (*val->contents.err);
2069         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2070         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2071         long err_ref = (long)err_var.inner & ~1;
2072         return err_ref;
2073 }
2074 static jclass LDKCOption_u64Z_Some_class = NULL;
2075 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
2076 static jclass LDKCOption_u64Z_None_class = NULL;
2077 static jmethodID LDKCOption_u64Z_None_meth = NULL;
2078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
2079         LDKCOption_u64Z_Some_class =
2080                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
2081         CHECK(LDKCOption_u64Z_Some_class != NULL);
2082         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
2083         CHECK(LDKCOption_u64Z_Some_meth != NULL);
2084         LDKCOption_u64Z_None_class =
2085                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
2086         CHECK(LDKCOption_u64Z_None_class != NULL);
2087         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
2088         CHECK(LDKCOption_u64Z_None_meth != NULL);
2089 }
2090 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2091         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
2092         switch(obj->tag) {
2093                 case LDKCOption_u64Z_Some: {
2094                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
2095                 }
2096                 case LDKCOption_u64Z_None: {
2097                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
2098                 }
2099                 default: abort();
2100         }
2101 }
2102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2103         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
2104         ret->datalen = (*env)->GetArrayLength(env, elems);
2105         if (ret->datalen == 0) {
2106                 ret->data = NULL;
2107         } else {
2108                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
2109                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2110                 for (size_t i = 0; i < ret->datalen; i++) {
2111                         int64_t arr_elem = java_elems[i];
2112                         LDKChannelDetails arr_elem_conv;
2113                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2114                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2115                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
2116                         ret->data[i] = arr_elem_conv;
2117                 }
2118                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2119         }
2120         return (long)ret;
2121 }
2122 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2123         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2124         for (size_t i = 0; i < ret.datalen; i++) {
2125                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2126         }
2127         return ret;
2128 }
2129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2130         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
2131         ret->datalen = (*env)->GetArrayLength(env, elems);
2132         if (ret->datalen == 0) {
2133                 ret->data = NULL;
2134         } else {
2135                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
2136                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2137                 for (size_t i = 0; i < ret->datalen; i++) {
2138                         int64_t arr_elem = java_elems[i];
2139                         LDKRouteHint arr_elem_conv;
2140                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2141                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2142                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
2143                         ret->data[i] = arr_elem_conv;
2144                 }
2145                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2146         }
2147         return (long)ret;
2148 }
2149 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2150         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2151         for (size_t i = 0; i < ret.datalen; i++) {
2152                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2153         }
2154         return ret;
2155 }
2156 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2157         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
2158 }
2159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2160         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
2161         CHECK(val->result_ok);
2162         LDKRoute res_var = (*val->contents.result);
2163         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2164         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2165         long res_ref = (long)res_var.inner & ~1;
2166         return res_ref;
2167 }
2168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2169         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
2170         CHECK(!val->result_ok);
2171         LDKLightningError err_var = (*val->contents.err);
2172         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2173         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2174         long err_ref = (long)err_var.inner & ~1;
2175         return err_ref;
2176 }
2177 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2178 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2179 static jclass LDKErrorAction_IgnoreError_class = NULL;
2180 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2181 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2182 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2184         LDKErrorAction_DisconnectPeer_class =
2185                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
2186         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2187         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2188         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2189         LDKErrorAction_IgnoreError_class =
2190                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
2191         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2192         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2193         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2194         LDKErrorAction_SendErrorMessage_class =
2195                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
2196         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2197         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2198         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2199 }
2200 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2201         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2202         switch(obj->tag) {
2203                 case LDKErrorAction_DisconnectPeer: {
2204                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2205                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2206                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2207                         long msg_ref = (long)msg_var.inner & ~1;
2208                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2209                 }
2210                 case LDKErrorAction_IgnoreError: {
2211                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2212                 }
2213                 case LDKErrorAction_SendErrorMessage: {
2214                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2215                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2216                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2217                         long msg_ref = (long)msg_var.inner & ~1;
2218                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2219                 }
2220                 default: abort();
2221         }
2222 }
2223 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
2224 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
2225 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
2226 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
2227 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
2228 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
2229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
2230         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
2231                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
2232         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
2233         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2234         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
2235         LDKHTLCFailChannelUpdate_ChannelClosed_class =
2236                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
2237         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
2238         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
2239         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
2240         LDKHTLCFailChannelUpdate_NodeFailure_class =
2241                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
2242         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
2243         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
2244         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
2245 }
2246 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2247         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
2248         switch(obj->tag) {
2249                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
2250                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2251                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2252                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2253                         long msg_ref = (long)msg_var.inner & ~1;
2254                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
2255                 }
2256                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
2257                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
2258                 }
2259                 case LDKHTLCFailChannelUpdate_NodeFailure: {
2260                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2261                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2262                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
2263                 }
2264                 default: abort();
2265         }
2266 }
2267 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2268 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2269 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2270 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2271 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2272 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2273 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2274 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2275 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
2276 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
2277 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2278 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2279 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2280 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2281 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2282 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2283 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2284 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2285 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2286 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2287 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2288 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2289 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2290 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2291 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2292 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2293 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2294 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2295 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2296 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2297 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
2298 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
2299 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2300 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2301 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2302 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2303 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2304 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2306         LDKMessageSendEvent_SendAcceptChannel_class =
2307                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
2308         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2309         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2310         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2311         LDKMessageSendEvent_SendOpenChannel_class =
2312                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
2313         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2314         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2315         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2316         LDKMessageSendEvent_SendFundingCreated_class =
2317                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
2318         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2319         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2320         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2321         LDKMessageSendEvent_SendFundingSigned_class =
2322                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
2323         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2324         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2325         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2326         LDKMessageSendEvent_SendFundingLocked_class =
2327                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
2328         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
2329         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
2330         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
2331         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2332                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
2333         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2334         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2335         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2336         LDKMessageSendEvent_UpdateHTLCs_class =
2337                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
2338         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2339         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2340         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2341         LDKMessageSendEvent_SendRevokeAndACK_class =
2342                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
2343         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2344         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2345         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2346         LDKMessageSendEvent_SendClosingSigned_class =
2347                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
2348         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2349         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2350         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2351         LDKMessageSendEvent_SendShutdown_class =
2352                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
2353         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2354         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2355         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2356         LDKMessageSendEvent_SendChannelReestablish_class =
2357                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
2358         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2359         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2360         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2361         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2362                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
2363         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2364         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2365         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2366         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2367                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
2368         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2369         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2370         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2371         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2372                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
2373         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2374         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2375         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2376         LDKMessageSendEvent_HandleError_class =
2377                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
2378         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2379         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2380         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2381         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
2382                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
2383         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
2384         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
2385         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
2386         LDKMessageSendEvent_SendChannelRangeQuery_class =
2387                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
2388         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2389         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2390         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2391         LDKMessageSendEvent_SendShortIdsQuery_class =
2392                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
2393         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2394         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2395         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2396         LDKMessageSendEvent_SendReplyChannelRange_class =
2397                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
2398         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2399         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2400         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2401 }
2402 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2403         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2404         switch(obj->tag) {
2405                 case LDKMessageSendEvent_SendAcceptChannel: {
2406                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2407                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2408                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2409                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2410                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2411                         long msg_ref = (long)msg_var.inner & ~1;
2412                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2413                 }
2414                 case LDKMessageSendEvent_SendOpenChannel: {
2415                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2416                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2417                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2418                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2419                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2420                         long msg_ref = (long)msg_var.inner & ~1;
2421                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2422                 }
2423                 case LDKMessageSendEvent_SendFundingCreated: {
2424                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2425                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2426                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2427                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2428                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2429                         long msg_ref = (long)msg_var.inner & ~1;
2430                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2431                 }
2432                 case LDKMessageSendEvent_SendFundingSigned: {
2433                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2434                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2435                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2436                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2437                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2438                         long msg_ref = (long)msg_var.inner & ~1;
2439                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2440                 }
2441                 case LDKMessageSendEvent_SendFundingLocked: {
2442                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2443                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
2444                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2445                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2446                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2447                         long msg_ref = (long)msg_var.inner & ~1;
2448                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
2449                 }
2450                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2451                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2452                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2453                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2454                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2455                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2456                         long msg_ref = (long)msg_var.inner & ~1;
2457                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
2458                 }
2459                 case LDKMessageSendEvent_UpdateHTLCs: {
2460                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2461                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
2462                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2463                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2464                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2465                         long updates_ref = (long)updates_var.inner & ~1;
2466                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
2467                 }
2468                 case LDKMessageSendEvent_SendRevokeAndACK: {
2469                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2470                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
2471                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2472                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2473                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2474                         long msg_ref = (long)msg_var.inner & ~1;
2475                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
2476                 }
2477                 case LDKMessageSendEvent_SendClosingSigned: {
2478                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2479                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
2480                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2481                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2482                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2483                         long msg_ref = (long)msg_var.inner & ~1;
2484                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
2485                 }
2486                 case LDKMessageSendEvent_SendShutdown: {
2487                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2488                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
2489                         LDKShutdown msg_var = obj->send_shutdown.msg;
2490                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2491                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2492                         long msg_ref = (long)msg_var.inner & ~1;
2493                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
2494                 }
2495                 case LDKMessageSendEvent_SendChannelReestablish: {
2496                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2497                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
2498                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2499                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2500                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2501                         long msg_ref = (long)msg_var.inner & ~1;
2502                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
2503                 }
2504                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
2505                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2506                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2507                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2508                         long msg_ref = (long)msg_var.inner & ~1;
2509                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2510                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2511                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2512                         long update_msg_ref = (long)update_msg_var.inner & ~1;
2513                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
2514                 }
2515                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
2516                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2517                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2518                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2519                         long msg_ref = (long)msg_var.inner & ~1;
2520                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
2521                 }
2522                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
2523                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2524                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2525                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2526                         long msg_ref = (long)msg_var.inner & ~1;
2527                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
2528                 }
2529                 case LDKMessageSendEvent_HandleError: {
2530                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2531                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
2532                         long action_ref = ((long)&obj->handle_error.action) | 1;
2533                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
2534                 }
2535                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
2536                         long update_ref = ((long)&obj->payment_failure_network_update.update) | 1;
2537                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
2538                 }
2539                 case LDKMessageSendEvent_SendChannelRangeQuery: {
2540                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2541                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
2542                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2543                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2544                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2545                         long msg_ref = (long)msg_var.inner & ~1;
2546                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
2547                 }
2548                 case LDKMessageSendEvent_SendShortIdsQuery: {
2549                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2550                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
2551                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2552                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2553                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2554                         long msg_ref = (long)msg_var.inner & ~1;
2555                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
2556                 }
2557                 case LDKMessageSendEvent_SendReplyChannelRange: {
2558                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2559                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
2560                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2561                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2562                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2563                         long msg_ref = (long)msg_var.inner & ~1;
2564                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
2565                 }
2566                 default: abort();
2567         }
2568 }
2569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2570         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
2571         ret->datalen = (*env)->GetArrayLength(env, elems);
2572         if (ret->datalen == 0) {
2573                 ret->data = NULL;
2574         } else {
2575                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
2576                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2577                 for (size_t i = 0; i < ret->datalen; i++) {
2578                         int64_t arr_elem = java_elems[i];
2579                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
2580                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
2581                         ret->data[i] = arr_elem_conv;
2582                 }
2583                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2584         }
2585         return (long)ret;
2586 }
2587 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2588         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2589         for (size_t i = 0; i < ret.datalen; i++) {
2590                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2591         }
2592         return ret;
2593 }
2594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2595         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
2596 }
2597 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2598         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
2599         CHECK(val->result_ok);
2600         return *val->contents.result;
2601 }
2602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2603         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
2604         CHECK(!val->result_ok);
2605         LDKLightningError err_var = (*val->contents.err);
2606         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2607         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2608         long err_ref = (long)err_var.inner & ~1;
2609         return err_ref;
2610 }
2611 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) {
2612         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
2613         LDKChannelAnnouncement a_conv;
2614         a_conv.inner = (void*)(a & (~1));
2615         a_conv.is_owned = (a & 1) || (a == 0);
2616         a_conv = ChannelAnnouncement_clone(&a_conv);
2617         ret->a = a_conv;
2618         LDKChannelUpdate b_conv;
2619         b_conv.inner = (void*)(b & (~1));
2620         b_conv.is_owned = (b & 1) || (b == 0);
2621         b_conv = ChannelUpdate_clone(&b_conv);
2622         ret->b = b_conv;
2623         LDKChannelUpdate c_conv;
2624         c_conv.inner = (void*)(c & (~1));
2625         c_conv.is_owned = (c & 1) || (c == 0);
2626         c_conv = ChannelUpdate_clone(&c_conv);
2627         ret->c = c_conv;
2628         return (long)ret;
2629 }
2630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2631         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
2632         LDKChannelAnnouncement a_var = tuple->a;
2633         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2634         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2635         long a_ref = (long)a_var.inner & ~1;
2636         return a_ref;
2637 }
2638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2639         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
2640         LDKChannelUpdate b_var = tuple->b;
2641         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2642         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2643         long b_ref = (long)b_var.inner & ~1;
2644         return b_ref;
2645 }
2646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
2647         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
2648         LDKChannelUpdate c_var = tuple->c;
2649         CHECK((((long)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2650         CHECK((((long)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2651         long c_ref = (long)c_var.inner & ~1;
2652         return c_ref;
2653 }
2654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2655         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
2656         ret->datalen = (*env)->GetArrayLength(env, elems);
2657         if (ret->datalen == 0) {
2658                 ret->data = NULL;
2659         } else {
2660                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
2661                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2662                 for (size_t i = 0; i < ret->datalen; i++) {
2663                         int64_t arr_elem = java_elems[i];
2664                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
2665                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
2666                         ret->data[i] = arr_elem_conv;
2667                 }
2668                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2669         }
2670         return (long)ret;
2671 }
2672 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
2673         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
2674         for (size_t i = 0; i < ret.datalen; i++) {
2675                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
2676         }
2677         return ret;
2678 }
2679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2680         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
2681         ret->datalen = (*env)->GetArrayLength(env, elems);
2682         if (ret->datalen == 0) {
2683                 ret->data = NULL;
2684         } else {
2685                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
2686                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2687                 for (size_t i = 0; i < ret->datalen; i++) {
2688                         int64_t arr_elem = java_elems[i];
2689                         LDKNodeAnnouncement arr_elem_conv;
2690                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2691                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2692                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
2693                         ret->data[i] = arr_elem_conv;
2694                 }
2695                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2696         }
2697         return (long)ret;
2698 }
2699 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
2700         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
2701         for (size_t i = 0; i < ret.datalen; i++) {
2702                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
2703         }
2704         return ret;
2705 }
2706 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2707         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
2708 }
2709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2710         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
2711         CHECK(val->result_ok);
2712         return *val->contents.result;
2713 }
2714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2715         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
2716         CHECK(!val->result_ok);
2717         LDKLightningError err_var = (*val->contents.err);
2718         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2719         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2720         long err_ref = (long)err_var.inner & ~1;
2721         return err_ref;
2722 }
2723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2724         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
2725 }
2726 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2727         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
2728         CHECK(val->result_ok);
2729         LDKCVec_u8Z res_var = (*val->contents.result);
2730         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
2731         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
2732         return res_arr;
2733 }
2734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2735         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
2736         CHECK(!val->result_ok);
2737         LDKPeerHandleError err_var = (*val->contents.err);
2738         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2739         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2740         long err_ref = (long)err_var.inner & ~1;
2741         return err_ref;
2742 }
2743 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2744         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
2745 }
2746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2747         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
2748         CHECK(val->result_ok);
2749         return *val->contents.result;
2750 }
2751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2752         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
2753         CHECK(!val->result_ok);
2754         LDKPeerHandleError err_var = (*val->contents.err);
2755         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2756         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2757         long err_ref = (long)err_var.inner & ~1;
2758         return err_ref;
2759 }
2760 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2761         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
2762 }
2763 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2764         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
2765         CHECK(val->result_ok);
2766         return *val->contents.result;
2767 }
2768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2769         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
2770         CHECK(!val->result_ok);
2771         LDKPeerHandleError err_var = (*val->contents.err);
2772         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2773         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2774         long err_ref = (long)err_var.inner & ~1;
2775         return err_ref;
2776 }
2777 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2778         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
2779 }
2780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2781         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2782         CHECK(val->result_ok);
2783         long res_ref = ((long)&(*val->contents.result)) | 1;
2784         return (long)res_ref;
2785 }
2786 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2787         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2788         CHECK(!val->result_ok);
2789         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
2790         return err_conv;
2791 }
2792 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
2793 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
2794 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
2795 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
2796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
2797         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
2798                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
2799         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
2800         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
2801         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
2802         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
2803                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
2804         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
2805         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
2806         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
2807 }
2808 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2809         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2810         switch(obj->tag) {
2811                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
2812                         long some_ref = (long)(&obj->some) | 1;
2813                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, some_ref);
2814                 }
2815                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
2816                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
2817                 }
2818                 default: abort();
2819         }
2820 }
2821 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2822         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
2823 }
2824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2825         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
2826         CHECK(val->result_ok);
2827         LDKDirectionalChannelInfo res_var = (*val->contents.result);
2828         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2829         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2830         long res_ref = (long)res_var.inner & ~1;
2831         return res_ref;
2832 }
2833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2834         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
2835         CHECK(!val->result_ok);
2836         LDKDecodeError err_var = (*val->contents.err);
2837         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2838         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2839         long err_ref = (long)err_var.inner & ~1;
2840         return err_ref;
2841 }
2842 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2843         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
2844 }
2845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2846         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
2847         CHECK(val->result_ok);
2848         LDKChannelInfo res_var = (*val->contents.result);
2849         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2850         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2851         long res_ref = (long)res_var.inner & ~1;
2852         return res_ref;
2853 }
2854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2855         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
2856         CHECK(!val->result_ok);
2857         LDKDecodeError err_var = (*val->contents.err);
2858         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2859         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2860         long err_ref = (long)err_var.inner & ~1;
2861         return err_ref;
2862 }
2863 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2864         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
2865 }
2866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2867         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
2868         CHECK(val->result_ok);
2869         LDKRoutingFees res_var = (*val->contents.result);
2870         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2871         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2872         long res_ref = (long)res_var.inner & ~1;
2873         return res_ref;
2874 }
2875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2876         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
2877         CHECK(!val->result_ok);
2878         LDKDecodeError err_var = (*val->contents.err);
2879         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2880         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2881         long err_ref = (long)err_var.inner & ~1;
2882         return err_ref;
2883 }
2884 static jclass LDKNetAddress_IPv4_class = NULL;
2885 static jmethodID LDKNetAddress_IPv4_meth = NULL;
2886 static jclass LDKNetAddress_IPv6_class = NULL;
2887 static jmethodID LDKNetAddress_IPv6_meth = NULL;
2888 static jclass LDKNetAddress_OnionV2_class = NULL;
2889 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
2890 static jclass LDKNetAddress_OnionV3_class = NULL;
2891 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
2892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
2893         LDKNetAddress_IPv4_class =
2894                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
2895         CHECK(LDKNetAddress_IPv4_class != NULL);
2896         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
2897         CHECK(LDKNetAddress_IPv4_meth != NULL);
2898         LDKNetAddress_IPv6_class =
2899                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
2900         CHECK(LDKNetAddress_IPv6_class != NULL);
2901         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
2902         CHECK(LDKNetAddress_IPv6_meth != NULL);
2903         LDKNetAddress_OnionV2_class =
2904                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
2905         CHECK(LDKNetAddress_OnionV2_class != NULL);
2906         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
2907         CHECK(LDKNetAddress_OnionV2_meth != NULL);
2908         LDKNetAddress_OnionV3_class =
2909                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
2910         CHECK(LDKNetAddress_OnionV3_class != NULL);
2911         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
2912         CHECK(LDKNetAddress_OnionV3_meth != NULL);
2913 }
2914 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2915         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
2916         switch(obj->tag) {
2917                 case LDKNetAddress_IPv4: {
2918                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
2919                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
2920                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
2921                 }
2922                 case LDKNetAddress_IPv6: {
2923                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
2924                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
2925                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
2926                 }
2927                 case LDKNetAddress_OnionV2: {
2928                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
2929                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
2930                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
2931                 }
2932                 case LDKNetAddress_OnionV3: {
2933                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
2934                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
2935                         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);
2936                 }
2937                 default: abort();
2938         }
2939 }
2940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2941         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
2942         ret->datalen = (*env)->GetArrayLength(env, elems);
2943         if (ret->datalen == 0) {
2944                 ret->data = NULL;
2945         } else {
2946                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
2947                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2948                 for (size_t i = 0; i < ret->datalen; i++) {
2949                         int64_t arr_elem = java_elems[i];
2950                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
2951                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
2952                         ret->data[i] = arr_elem_conv;
2953                 }
2954                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2955         }
2956         return (long)ret;
2957 }
2958 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
2959         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
2960         for (size_t i = 0; i < ret.datalen; i++) {
2961                 ret.data[i] = NetAddress_clone(&orig->data[i]);
2962         }
2963         return ret;
2964 }
2965 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2966         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
2967 }
2968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2969         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
2970         CHECK(val->result_ok);
2971         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
2972         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2973         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2974         long res_ref = (long)res_var.inner & ~1;
2975         return res_ref;
2976 }
2977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2978         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
2979         CHECK(!val->result_ok);
2980         LDKDecodeError err_var = (*val->contents.err);
2981         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2982         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2983         long err_ref = (long)err_var.inner & ~1;
2984         return err_ref;
2985 }
2986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2987         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
2988         ret->datalen = (*env)->GetArrayLength(env, elems);
2989         if (ret->datalen == 0) {
2990                 ret->data = NULL;
2991         } else {
2992                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
2993                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2994                 for (size_t i = 0; i < ret->datalen; i++) {
2995                         ret->data[i] = java_elems[i];
2996                 }
2997                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2998         }
2999         return (long)ret;
3000 }
3001 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
3002         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
3003         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
3004         return ret;
3005 }
3006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3007         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
3008 }
3009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3010         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
3011         CHECK(val->result_ok);
3012         LDKNodeInfo res_var = (*val->contents.result);
3013         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3014         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3015         long res_ref = (long)res_var.inner & ~1;
3016         return res_ref;
3017 }
3018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3019         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
3020         CHECK(!val->result_ok);
3021         LDKDecodeError err_var = (*val->contents.err);
3022         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3023         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3024         long err_ref = (long)err_var.inner & ~1;
3025         return err_ref;
3026 }
3027 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3028         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
3029 }
3030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3031         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
3032         CHECK(val->result_ok);
3033         LDKNetworkGraph res_var = (*val->contents.result);
3034         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3035         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3036         long res_ref = (long)res_var.inner & ~1;
3037         return res_ref;
3038 }
3039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3040         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
3041         CHECK(!val->result_ok);
3042         LDKDecodeError err_var = (*val->contents.err);
3043         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3044         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3045         long err_ref = (long)err_var.inner & ~1;
3046         return err_ref;
3047 }
3048 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3049         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
3050 }
3051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3052         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
3053         CHECK(val->result_ok);
3054         LDKInitFeatures res_var = (*val->contents.result);
3055         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3056         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3057         long res_ref = (long)res_var.inner & ~1;
3058         return res_ref;
3059 }
3060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3061         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
3062         CHECK(!val->result_ok);
3063         LDKDecodeError err_var = (*val->contents.err);
3064         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3065         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3066         long err_ref = (long)err_var.inner & ~1;
3067         return err_ref;
3068 }
3069 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3070         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
3071 }
3072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3073         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
3074         CHECK(val->result_ok);
3075         LDKNodeFeatures res_var = (*val->contents.result);
3076         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3077         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3078         long res_ref = (long)res_var.inner & ~1;
3079         return res_ref;
3080 }
3081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3082         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
3083         CHECK(!val->result_ok);
3084         LDKDecodeError err_var = (*val->contents.err);
3085         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3086         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3087         long err_ref = (long)err_var.inner & ~1;
3088         return err_ref;
3089 }
3090 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3091         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
3092 }
3093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3094         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
3095         CHECK(val->result_ok);
3096         LDKChannelFeatures res_var = (*val->contents.result);
3097         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3098         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3099         long res_ref = (long)res_var.inner & ~1;
3100         return res_ref;
3101 }
3102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3103         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
3104         CHECK(!val->result_ok);
3105         LDKDecodeError err_var = (*val->contents.err);
3106         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3107         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3108         long err_ref = (long)err_var.inner & ~1;
3109         return err_ref;
3110 }
3111 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3112         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
3113 }
3114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3115         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
3116         CHECK(val->result_ok);
3117         LDKInvoiceFeatures res_var = (*val->contents.result);
3118         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3119         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3120         long res_ref = (long)res_var.inner & ~1;
3121         return res_ref;
3122 }
3123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3124         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
3125         CHECK(!val->result_ok);
3126         LDKDecodeError err_var = (*val->contents.err);
3127         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3128         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3129         long err_ref = (long)err_var.inner & ~1;
3130         return err_ref;
3131 }
3132 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3133         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
3134 }
3135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3136         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3137         CHECK(val->result_ok);
3138         long res_ref = ((long)&(*val->contents.result)) | 1;
3139         return res_ref;
3140 }
3141 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3142         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3143         CHECK(!val->result_ok);
3144         return *val->contents.err;
3145 }
3146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3147         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
3148 }
3149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3150         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3151         CHECK(val->result_ok);
3152         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3153         *res_conv = (*val->contents.result);
3154         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
3155         return (long)res_conv;
3156 }
3157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3158         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3159         CHECK(!val->result_ok);
3160         LDKDecodeError err_var = (*val->contents.err);
3161         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3162         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3163         long err_ref = (long)err_var.inner & ~1;
3164         return err_ref;
3165 }
3166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3167         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
3168         ret->datalen = (*env)->GetArrayLength(env, elems);
3169         if (ret->datalen == 0) {
3170                 ret->data = NULL;
3171         } else {
3172                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
3173                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3174                 for (size_t i = 0; i < ret->datalen; i++) {
3175                         int64_t arr_elem = java_elems[i];
3176                         LDKUpdateAddHTLC arr_elem_conv;
3177                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3178                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3179                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3180                         ret->data[i] = arr_elem_conv;
3181                 }
3182                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3183         }
3184         return (long)ret;
3185 }
3186 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
3187         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
3188         for (size_t i = 0; i < ret.datalen; i++) {
3189                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
3190         }
3191         return ret;
3192 }
3193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3194         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
3195         ret->datalen = (*env)->GetArrayLength(env, elems);
3196         if (ret->datalen == 0) {
3197                 ret->data = NULL;
3198         } else {
3199                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
3200                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3201                 for (size_t i = 0; i < ret->datalen; i++) {
3202                         int64_t arr_elem = java_elems[i];
3203                         LDKUpdateFulfillHTLC arr_elem_conv;
3204                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3205                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3206                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3207                         ret->data[i] = arr_elem_conv;
3208                 }
3209                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3210         }
3211         return (long)ret;
3212 }
3213 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
3214         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
3215         for (size_t i = 0; i < ret.datalen; i++) {
3216                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
3217         }
3218         return ret;
3219 }
3220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3221         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
3222         ret->datalen = (*env)->GetArrayLength(env, elems);
3223         if (ret->datalen == 0) {
3224                 ret->data = NULL;
3225         } else {
3226                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
3227                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3228                 for (size_t i = 0; i < ret->datalen; i++) {
3229                         int64_t arr_elem = java_elems[i];
3230                         LDKUpdateFailHTLC arr_elem_conv;
3231                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3232                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3233                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
3234                         ret->data[i] = arr_elem_conv;
3235                 }
3236                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3237         }
3238         return (long)ret;
3239 }
3240 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
3241         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
3242         for (size_t i = 0; i < ret.datalen; i++) {
3243                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
3244         }
3245         return ret;
3246 }
3247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3248         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
3249         ret->datalen = (*env)->GetArrayLength(env, elems);
3250         if (ret->datalen == 0) {
3251                 ret->data = NULL;
3252         } else {
3253                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
3254                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3255                 for (size_t i = 0; i < ret->datalen; i++) {
3256                         int64_t arr_elem = java_elems[i];
3257                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3258                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3259                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3260                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3261                         ret->data[i] = arr_elem_conv;
3262                 }
3263                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3264         }
3265         return (long)ret;
3266 }
3267 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
3268         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
3269         for (size_t i = 0; i < ret.datalen; i++) {
3270                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
3271         }
3272         return ret;
3273 }
3274 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3275         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
3276 }
3277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3278         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3279         CHECK(val->result_ok);
3280         LDKAcceptChannel res_var = (*val->contents.result);
3281         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3282         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3283         long res_ref = (long)res_var.inner & ~1;
3284         return res_ref;
3285 }
3286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3287         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3288         CHECK(!val->result_ok);
3289         LDKDecodeError err_var = (*val->contents.err);
3290         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3291         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3292         long err_ref = (long)err_var.inner & ~1;
3293         return err_ref;
3294 }
3295 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3296         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
3297 }
3298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3299         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3300         CHECK(val->result_ok);
3301         LDKAnnouncementSignatures res_var = (*val->contents.result);
3302         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3303         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3304         long res_ref = (long)res_var.inner & ~1;
3305         return res_ref;
3306 }
3307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3308         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3309         CHECK(!val->result_ok);
3310         LDKDecodeError err_var = (*val->contents.err);
3311         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3312         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3313         long err_ref = (long)err_var.inner & ~1;
3314         return err_ref;
3315 }
3316 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3317         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
3318 }
3319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3320         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3321         CHECK(val->result_ok);
3322         LDKChannelReestablish res_var = (*val->contents.result);
3323         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3324         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3325         long res_ref = (long)res_var.inner & ~1;
3326         return res_ref;
3327 }
3328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3329         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3330         CHECK(!val->result_ok);
3331         LDKDecodeError err_var = (*val->contents.err);
3332         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3333         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3334         long err_ref = (long)err_var.inner & ~1;
3335         return err_ref;
3336 }
3337 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3338         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
3339 }
3340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3341         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
3342         CHECK(val->result_ok);
3343         LDKClosingSigned res_var = (*val->contents.result);
3344         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3345         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3346         long res_ref = (long)res_var.inner & ~1;
3347         return res_ref;
3348 }
3349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3350         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
3351         CHECK(!val->result_ok);
3352         LDKDecodeError err_var = (*val->contents.err);
3353         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3354         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3355         long err_ref = (long)err_var.inner & ~1;
3356         return err_ref;
3357 }
3358 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3359         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
3360 }
3361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3362         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
3363         CHECK(val->result_ok);
3364         LDKCommitmentSigned res_var = (*val->contents.result);
3365         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3366         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3367         long res_ref = (long)res_var.inner & ~1;
3368         return res_ref;
3369 }
3370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3371         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
3372         CHECK(!val->result_ok);
3373         LDKDecodeError err_var = (*val->contents.err);
3374         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3375         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3376         long err_ref = (long)err_var.inner & ~1;
3377         return err_ref;
3378 }
3379 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3380         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
3381 }
3382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3383         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
3384         CHECK(val->result_ok);
3385         LDKFundingCreated res_var = (*val->contents.result);
3386         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3387         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3388         long res_ref = (long)res_var.inner & ~1;
3389         return res_ref;
3390 }
3391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3392         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
3393         CHECK(!val->result_ok);
3394         LDKDecodeError err_var = (*val->contents.err);
3395         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3396         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3397         long err_ref = (long)err_var.inner & ~1;
3398         return err_ref;
3399 }
3400 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3401         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
3402 }
3403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3404         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
3405         CHECK(val->result_ok);
3406         LDKFundingSigned res_var = (*val->contents.result);
3407         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3408         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3409         long res_ref = (long)res_var.inner & ~1;
3410         return res_ref;
3411 }
3412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3413         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
3414         CHECK(!val->result_ok);
3415         LDKDecodeError err_var = (*val->contents.err);
3416         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3417         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3418         long err_ref = (long)err_var.inner & ~1;
3419         return err_ref;
3420 }
3421 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3422         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
3423 }
3424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3425         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
3426         CHECK(val->result_ok);
3427         LDKFundingLocked res_var = (*val->contents.result);
3428         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3429         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3430         long res_ref = (long)res_var.inner & ~1;
3431         return res_ref;
3432 }
3433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3434         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
3435         CHECK(!val->result_ok);
3436         LDKDecodeError err_var = (*val->contents.err);
3437         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3438         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3439         long err_ref = (long)err_var.inner & ~1;
3440         return err_ref;
3441 }
3442 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3443         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
3444 }
3445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3446         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
3447         CHECK(val->result_ok);
3448         LDKInit res_var = (*val->contents.result);
3449         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3450         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3451         long res_ref = (long)res_var.inner & ~1;
3452         return res_ref;
3453 }
3454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3455         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
3456         CHECK(!val->result_ok);
3457         LDKDecodeError err_var = (*val->contents.err);
3458         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3459         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3460         long err_ref = (long)err_var.inner & ~1;
3461         return err_ref;
3462 }
3463 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3464         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
3465 }
3466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3467         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
3468         CHECK(val->result_ok);
3469         LDKOpenChannel res_var = (*val->contents.result);
3470         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3471         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3472         long res_ref = (long)res_var.inner & ~1;
3473         return res_ref;
3474 }
3475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3476         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
3477         CHECK(!val->result_ok);
3478         LDKDecodeError err_var = (*val->contents.err);
3479         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3480         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3481         long err_ref = (long)err_var.inner & ~1;
3482         return err_ref;
3483 }
3484 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3485         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
3486 }
3487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3488         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
3489         CHECK(val->result_ok);
3490         LDKRevokeAndACK res_var = (*val->contents.result);
3491         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3492         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3493         long res_ref = (long)res_var.inner & ~1;
3494         return res_ref;
3495 }
3496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3497         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
3498         CHECK(!val->result_ok);
3499         LDKDecodeError err_var = (*val->contents.err);
3500         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3501         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3502         long err_ref = (long)err_var.inner & ~1;
3503         return err_ref;
3504 }
3505 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3506         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
3507 }
3508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3509         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
3510         CHECK(val->result_ok);
3511         LDKShutdown res_var = (*val->contents.result);
3512         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3513         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3514         long res_ref = (long)res_var.inner & ~1;
3515         return res_ref;
3516 }
3517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3518         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
3519         CHECK(!val->result_ok);
3520         LDKDecodeError err_var = (*val->contents.err);
3521         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3522         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3523         long err_ref = (long)err_var.inner & ~1;
3524         return err_ref;
3525 }
3526 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3527         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
3528 }
3529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3530         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
3531         CHECK(val->result_ok);
3532         LDKUpdateFailHTLC res_var = (*val->contents.result);
3533         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3534         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3535         long res_ref = (long)res_var.inner & ~1;
3536         return res_ref;
3537 }
3538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3539         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
3540         CHECK(!val->result_ok);
3541         LDKDecodeError err_var = (*val->contents.err);
3542         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3543         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3544         long err_ref = (long)err_var.inner & ~1;
3545         return err_ref;
3546 }
3547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3548         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
3549 }
3550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3551         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
3552         CHECK(val->result_ok);
3553         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
3554         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3555         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3556         long res_ref = (long)res_var.inner & ~1;
3557         return res_ref;
3558 }
3559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3560         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
3561         CHECK(!val->result_ok);
3562         LDKDecodeError err_var = (*val->contents.err);
3563         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3564         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3565         long err_ref = (long)err_var.inner & ~1;
3566         return err_ref;
3567 }
3568 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3569         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
3570 }
3571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3572         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
3573         CHECK(val->result_ok);
3574         LDKUpdateFee res_var = (*val->contents.result);
3575         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3576         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3577         long res_ref = (long)res_var.inner & ~1;
3578         return res_ref;
3579 }
3580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3581         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
3582         CHECK(!val->result_ok);
3583         LDKDecodeError err_var = (*val->contents.err);
3584         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3585         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3586         long err_ref = (long)err_var.inner & ~1;
3587         return err_ref;
3588 }
3589 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3590         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
3591 }
3592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3593         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
3594         CHECK(val->result_ok);
3595         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
3596         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3597         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3598         long res_ref = (long)res_var.inner & ~1;
3599         return res_ref;
3600 }
3601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3602         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
3603         CHECK(!val->result_ok);
3604         LDKDecodeError err_var = (*val->contents.err);
3605         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3606         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3607         long err_ref = (long)err_var.inner & ~1;
3608         return err_ref;
3609 }
3610 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3611         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
3612 }
3613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3614         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
3615         CHECK(val->result_ok);
3616         LDKUpdateAddHTLC res_var = (*val->contents.result);
3617         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3618         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3619         long res_ref = (long)res_var.inner & ~1;
3620         return res_ref;
3621 }
3622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3623         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
3624         CHECK(!val->result_ok);
3625         LDKDecodeError err_var = (*val->contents.err);
3626         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3627         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3628         long err_ref = (long)err_var.inner & ~1;
3629         return err_ref;
3630 }
3631 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3632         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
3633 }
3634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3635         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
3636         CHECK(val->result_ok);
3637         LDKPing res_var = (*val->contents.result);
3638         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3639         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3640         long res_ref = (long)res_var.inner & ~1;
3641         return res_ref;
3642 }
3643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3644         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
3645         CHECK(!val->result_ok);
3646         LDKDecodeError err_var = (*val->contents.err);
3647         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3648         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3649         long err_ref = (long)err_var.inner & ~1;
3650         return err_ref;
3651 }
3652 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3653         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
3654 }
3655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3656         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
3657         CHECK(val->result_ok);
3658         LDKPong res_var = (*val->contents.result);
3659         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3660         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3661         long res_ref = (long)res_var.inner & ~1;
3662         return res_ref;
3663 }
3664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3665         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
3666         CHECK(!val->result_ok);
3667         LDKDecodeError err_var = (*val->contents.err);
3668         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3669         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3670         long err_ref = (long)err_var.inner & ~1;
3671         return err_ref;
3672 }
3673 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3674         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
3675 }
3676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3677         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3678         CHECK(val->result_ok);
3679         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
3680         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3681         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3682         long res_ref = (long)res_var.inner & ~1;
3683         return res_ref;
3684 }
3685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3686         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3687         CHECK(!val->result_ok);
3688         LDKDecodeError err_var = (*val->contents.err);
3689         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3690         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3691         long err_ref = (long)err_var.inner & ~1;
3692         return err_ref;
3693 }
3694 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3695         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
3696 }
3697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3698         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3699         CHECK(val->result_ok);
3700         LDKChannelAnnouncement res_var = (*val->contents.result);
3701         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3702         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3703         long res_ref = (long)res_var.inner & ~1;
3704         return res_ref;
3705 }
3706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3707         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3708         CHECK(!val->result_ok);
3709         LDKDecodeError err_var = (*val->contents.err);
3710         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3711         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3712         long err_ref = (long)err_var.inner & ~1;
3713         return err_ref;
3714 }
3715 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3716         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
3717 }
3718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3719         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
3720         CHECK(val->result_ok);
3721         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
3722         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3723         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3724         long res_ref = (long)res_var.inner & ~1;
3725         return res_ref;
3726 }
3727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3728         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
3729         CHECK(!val->result_ok);
3730         LDKDecodeError err_var = (*val->contents.err);
3731         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3732         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3733         long err_ref = (long)err_var.inner & ~1;
3734         return err_ref;
3735 }
3736 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3737         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
3738 }
3739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3740         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
3741         CHECK(val->result_ok);
3742         LDKChannelUpdate res_var = (*val->contents.result);
3743         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3744         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3745         long res_ref = (long)res_var.inner & ~1;
3746         return res_ref;
3747 }
3748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3749         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
3750         CHECK(!val->result_ok);
3751         LDKDecodeError err_var = (*val->contents.err);
3752         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3753         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3754         long err_ref = (long)err_var.inner & ~1;
3755         return err_ref;
3756 }
3757 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3758         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
3759 }
3760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3761         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
3762         CHECK(val->result_ok);
3763         LDKErrorMessage res_var = (*val->contents.result);
3764         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3765         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3766         long res_ref = (long)res_var.inner & ~1;
3767         return res_ref;
3768 }
3769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3770         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
3771         CHECK(!val->result_ok);
3772         LDKDecodeError err_var = (*val->contents.err);
3773         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3774         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3775         long err_ref = (long)err_var.inner & ~1;
3776         return err_ref;
3777 }
3778 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3779         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
3780 }
3781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3782         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
3783         CHECK(val->result_ok);
3784         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
3785         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3786         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3787         long res_ref = (long)res_var.inner & ~1;
3788         return res_ref;
3789 }
3790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3791         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
3792         CHECK(!val->result_ok);
3793         LDKDecodeError err_var = (*val->contents.err);
3794         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3795         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3796         long err_ref = (long)err_var.inner & ~1;
3797         return err_ref;
3798 }
3799 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3800         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
3801 }
3802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3803         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
3804         CHECK(val->result_ok);
3805         LDKNodeAnnouncement res_var = (*val->contents.result);
3806         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3807         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3808         long res_ref = (long)res_var.inner & ~1;
3809         return res_ref;
3810 }
3811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3812         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
3813         CHECK(!val->result_ok);
3814         LDKDecodeError err_var = (*val->contents.err);
3815         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3816         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3817         long err_ref = (long)err_var.inner & ~1;
3818         return err_ref;
3819 }
3820 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3821         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
3822 }
3823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3824         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
3825         CHECK(val->result_ok);
3826         LDKQueryShortChannelIds res_var = (*val->contents.result);
3827         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3828         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3829         long res_ref = (long)res_var.inner & ~1;
3830         return res_ref;
3831 }
3832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3833         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
3834         CHECK(!val->result_ok);
3835         LDKDecodeError err_var = (*val->contents.err);
3836         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3837         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3838         long err_ref = (long)err_var.inner & ~1;
3839         return err_ref;
3840 }
3841 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3842         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
3843 }
3844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3845         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
3846         CHECK(val->result_ok);
3847         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
3848         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3849         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3850         long res_ref = (long)res_var.inner & ~1;
3851         return res_ref;
3852 }
3853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3854         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
3855         CHECK(!val->result_ok);
3856         LDKDecodeError err_var = (*val->contents.err);
3857         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3858         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3859         long err_ref = (long)err_var.inner & ~1;
3860         return err_ref;
3861 }
3862 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3863         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
3864 }
3865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3866         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
3867         CHECK(val->result_ok);
3868         LDKQueryChannelRange res_var = (*val->contents.result);
3869         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3870         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3871         long res_ref = (long)res_var.inner & ~1;
3872         return res_ref;
3873 }
3874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3875         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
3876         CHECK(!val->result_ok);
3877         LDKDecodeError err_var = (*val->contents.err);
3878         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3879         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3880         long err_ref = (long)err_var.inner & ~1;
3881         return err_ref;
3882 }
3883 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3884         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
3885 }
3886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3887         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
3888         CHECK(val->result_ok);
3889         LDKReplyChannelRange res_var = (*val->contents.result);
3890         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3891         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3892         long res_ref = (long)res_var.inner & ~1;
3893         return res_ref;
3894 }
3895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3896         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
3897         CHECK(!val->result_ok);
3898         LDKDecodeError err_var = (*val->contents.err);
3899         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3900         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3901         long err_ref = (long)err_var.inner & ~1;
3902         return err_ref;
3903 }
3904 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3905         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
3906 }
3907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3908         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
3909         CHECK(val->result_ok);
3910         LDKGossipTimestampFilter res_var = (*val->contents.result);
3911         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3912         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3913         long res_ref = (long)res_var.inner & ~1;
3914         return res_ref;
3915 }
3916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3917         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
3918         CHECK(!val->result_ok);
3919         LDKDecodeError err_var = (*val->contents.err);
3920         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3921         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3922         long err_ref = (long)err_var.inner & ~1;
3923         return err_ref;
3924 }
3925 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3926         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
3927 }
3928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3929         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
3930         CHECK(val->result_ok);
3931         long res_ref = ((long)&(*val->contents.result)) | 1;
3932         return res_ref;
3933 }
3934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3935         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
3936         CHECK(!val->result_ok);
3937         LDKDecodeError err_var = (*val->contents.err);
3938         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3939         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3940         long err_ref = (long)err_var.inner & ~1;
3941         return err_ref;
3942 }
3943 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3944         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
3945 }
3946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3947         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3948         CHECK(val->result_ok);
3949         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3950         *ret = Sign_clone(&(*val->contents.result));
3951         return (long)ret;
3952 }
3953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3954         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3955         CHECK(!val->result_ok);
3956         LDKDecodeError err_var = (*val->contents.err);
3957         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3958         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3959         long err_ref = (long)err_var.inner & ~1;
3960         return err_ref;
3961 }
3962 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3963         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3964         for (size_t i = 0; i < ret.datalen; i++) {
3965                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3966         }
3967         return ret;
3968 }
3969 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3970         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
3971 }
3972 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3973         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3974         CHECK(val->result_ok);
3975         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
3976         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
3977         ;
3978         for (size_t i = 0; i < res_var.datalen; i++) {
3979                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
3980                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
3981                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
3982                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
3983         }
3984         return res_arr;
3985 }
3986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3987         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3988         CHECK(!val->result_ok);
3989         return *val->contents.err;
3990 }
3991 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3992         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
3993 }
3994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3995         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3996         CHECK(val->result_ok);
3997         LDKInMemorySigner res_var = (*val->contents.result);
3998         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3999         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4000         long res_ref = (long)res_var.inner & ~1;
4001         return res_ref;
4002 }
4003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4004         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
4005         CHECK(!val->result_ok);
4006         LDKDecodeError err_var = (*val->contents.err);
4007         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4008         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4009         long err_ref = (long)err_var.inner & ~1;
4010         return err_ref;
4011 }
4012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4013         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
4014         ret->datalen = (*env)->GetArrayLength(env, elems);
4015         if (ret->datalen == 0) {
4016                 ret->data = NULL;
4017         } else {
4018                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
4019                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4020                 for (size_t i = 0; i < ret->datalen; i++) {
4021                         int64_t arr_elem = java_elems[i];
4022                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
4023                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
4024                         ret->data[i] = arr_elem_conv;
4025                 }
4026                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4027         }
4028         return (long)ret;
4029 }
4030 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
4031         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
4032         for (size_t i = 0; i < ret.datalen; i++) {
4033                 ret.data[i] = TxOut_clone(&orig->data[i]);
4034         }
4035         return ret;
4036 }
4037 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4038         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
4039 }
4040 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4041         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
4042         CHECK(val->result_ok);
4043         LDKTransaction res_var = (*val->contents.result);
4044         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
4045         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
4046         return res_arr;
4047 }
4048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4049         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
4050         CHECK(!val->result_ok);
4051         return *val->contents.err;
4052 }
4053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4054         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
4055 }
4056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4057         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
4058         CHECK(val->result_ok);
4059         return *val->contents.result;
4060 }
4061 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4062         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
4063         CHECK(!val->result_ok);
4064         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
4065         return err_conv;
4066 }
4067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4068         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
4069         ret->datalen = (*env)->GetArrayLength(env, elems);
4070         if (ret->datalen == 0) {
4071                 ret->data = NULL;
4072         } else {
4073                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
4074                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4075                 for (size_t i = 0; i < ret->datalen; i++) {
4076                         int64_t arr_elem = java_elems[i];
4077                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
4078                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
4079                         ret->data[i] = arr_elem_conv;
4080                 }
4081                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4082         }
4083         return (long)ret;
4084 }
4085 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4086         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
4087 }
4088 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4089         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
4090         CHECK(val->result_ok);
4091         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
4092         int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
4093         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
4094         for (size_t i = 0; i < res_var.datalen; i++) {
4095                 long res_conv_34_ref = (long)(&res_var.data[i]) | 1;
4096                 res_arr_ptr[i] = res_conv_34_ref;
4097         }
4098         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
4099         return res_arr;
4100 }
4101 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4102         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
4103         CHECK(!val->result_ok);
4104         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
4105         return err_conv;
4106 }
4107 static jclass LDKAPIError_APIMisuseError_class = NULL;
4108 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
4109 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
4110 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
4111 static jclass LDKAPIError_RouteError_class = NULL;
4112 static jmethodID LDKAPIError_RouteError_meth = NULL;
4113 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
4114 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
4115 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
4116 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
4117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
4118         LDKAPIError_APIMisuseError_class =
4119                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
4120         CHECK(LDKAPIError_APIMisuseError_class != NULL);
4121         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "([B)V");
4122         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
4123         LDKAPIError_FeeRateTooHigh_class =
4124                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
4125         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
4126         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "([BI)V");
4127         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
4128         LDKAPIError_RouteError_class =
4129                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
4130         CHECK(LDKAPIError_RouteError_class != NULL);
4131         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
4132         CHECK(LDKAPIError_RouteError_meth != NULL);
4133         LDKAPIError_ChannelUnavailable_class =
4134                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
4135         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
4136         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "([B)V");
4137         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
4138         LDKAPIError_MonitorUpdateFailed_class =
4139                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
4140         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
4141         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
4142         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
4143 }
4144 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4145         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4146         switch(obj->tag) {
4147                 case LDKAPIError_APIMisuseError: {
4148                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
4149                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
4150                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
4151                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_arr);
4152                 }
4153                 case LDKAPIError_FeeRateTooHigh: {
4154                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
4155                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
4156                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
4157                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_arr, obj->fee_rate_too_high.feerate);
4158                 }
4159                 case LDKAPIError_RouteError: {
4160                         LDKStr err_str = obj->route_error.err;
4161                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4162                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
4163                 }
4164                 case LDKAPIError_ChannelUnavailable: {
4165                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
4166                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
4167                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
4168                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_arr);
4169                 }
4170                 case LDKAPIError_MonitorUpdateFailed: {
4171                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
4172                 }
4173                 default: abort();
4174         }
4175 }
4176 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4177         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
4178 }
4179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4180         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
4181         CHECK(val->result_ok);
4182         return *val->contents.result;
4183 }
4184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4185         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
4186         CHECK(!val->result_ok);
4187         long err_ref = ((long)&(*val->contents.err)) | 1;
4188         return err_ref;
4189 }
4190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4191         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
4192         ret->datalen = (*env)->GetArrayLength(env, elems);
4193         if (ret->datalen == 0) {
4194                 ret->data = NULL;
4195         } else {
4196                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
4197                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4198                 for (size_t i = 0; i < ret->datalen; i++) {
4199                         int64_t arr_elem = java_elems[i];
4200                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
4201                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
4202                         ret->data[i] = arr_elem_conv;
4203                 }
4204                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4205         }
4206         return (long)ret;
4207 }
4208 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
4209         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
4210         for (size_t i = 0; i < ret.datalen; i++) {
4211                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
4212         }
4213         return ret;
4214 }
4215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4216         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
4217         ret->datalen = (*env)->GetArrayLength(env, elems);
4218         if (ret->datalen == 0) {
4219                 ret->data = NULL;
4220         } else {
4221                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
4222                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4223                 for (size_t i = 0; i < ret->datalen; i++) {
4224                         int64_t arr_elem = java_elems[i];
4225                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
4226                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
4227                         ret->data[i] = arr_elem_conv;
4228                 }
4229                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4230         }
4231         return (long)ret;
4232 }
4233 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
4234         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
4235         for (size_t i = 0; i < ret.datalen; i++) {
4236                 ret.data[i] = APIError_clone(&orig->data[i]);
4237         }
4238         return ret;
4239 }
4240 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
4241 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
4242 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
4243 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
4244 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
4245 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
4246 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
4247 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
4248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
4249         LDKPaymentSendFailure_ParameterError_class =
4250                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
4251         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
4252         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
4253         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
4254         LDKPaymentSendFailure_PathParameterError_class =
4255                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
4256         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
4257         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
4258         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
4259         LDKPaymentSendFailure_AllFailedRetrySafe_class =
4260                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
4261         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
4262         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
4263         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
4264         LDKPaymentSendFailure_PartialFailure_class =
4265                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
4266         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
4267         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
4268         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
4269 }
4270 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4271         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4272         switch(obj->tag) {
4273                 case LDKPaymentSendFailure_ParameterError: {
4274                         long parameter_error_ref = ((long)&obj->parameter_error) | 1;
4275                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
4276                 }
4277                 case LDKPaymentSendFailure_PathParameterError: {
4278                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
4279                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
4280                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
4281                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
4282                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4283                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
4284                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
4285                                 path_parameter_error_arr_ptr[w] = (long)path_parameter_error_conv_22_conv;
4286                         }
4287                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
4288                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
4289                 }
4290                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
4291                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
4292                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
4293                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
4294                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
4295                                 long all_failed_retry_safe_conv_10_ref = ((long)&all_failed_retry_safe_var.data[k]) | 1;
4296                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
4297                         }
4298                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
4299                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
4300                 }
4301                 case LDKPaymentSendFailure_PartialFailure: {
4302                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
4303                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
4304                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
4305                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
4306                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4307                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
4308                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
4309                                 partial_failure_arr_ptr[w] = (long)partial_failure_conv_22_conv;
4310                         }
4311                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
4312                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
4313                 }
4314                 default: abort();
4315         }
4316 }
4317 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4318         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
4319 }
4320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4321         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
4322         CHECK(val->result_ok);
4323         return *val->contents.result;
4324 }
4325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4326         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
4327         CHECK(!val->result_ok);
4328         long err_ref = ((long)&(*val->contents.err)) | 1;
4329         return err_ref;
4330 }
4331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4332         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
4333         ret->datalen = (*env)->GetArrayLength(env, elems);
4334         if (ret->datalen == 0) {
4335                 ret->data = NULL;
4336         } else {
4337                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
4338                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4339                 for (size_t i = 0; i < ret->datalen; i++) {
4340                         int64_t arr_elem = java_elems[i];
4341                         LDKChannelMonitor arr_elem_conv;
4342                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4343                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4344                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
4345                         ret->data[i] = arr_elem_conv;
4346                 }
4347                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4348         }
4349         return (long)ret;
4350 }
4351 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
4352         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
4353         for (size_t i = 0; i < ret.datalen; i++) {
4354                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4355         }
4356         return ret;
4357 }
4358 typedef struct LDKWatch_JCalls {
4359         atomic_size_t refcnt;
4360         JavaVM *vm;
4361         jweak o;
4362         jmethodID watch_channel_meth;
4363         jmethodID update_channel_meth;
4364         jmethodID release_pending_monitor_events_meth;
4365 } LDKWatch_JCalls;
4366 static void LDKWatch_JCalls_free(void* this_arg) {
4367         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4368         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4369                 JNIEnv *env;
4370                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4371                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4372                 FREE(j_calls);
4373         }
4374 }
4375 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4376         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4377         JNIEnv *env;
4378         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4379         LDKOutPoint funding_txo_var = funding_txo;
4380         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4381         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4382         long funding_txo_ref = (long)funding_txo_var.inner;
4383         if (funding_txo_var.is_owned) {
4384                 funding_txo_ref |= 1;
4385         }
4386         LDKChannelMonitor monitor_var = monitor;
4387         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4388         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4389         long monitor_ref = (long)monitor_var.inner;
4390         if (monitor_var.is_owned) {
4391                 monitor_ref |= 1;
4392         }
4393         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4394         CHECK(obj != NULL);
4395         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
4396         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
4397         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
4398         return ret_conv;
4399 }
4400 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
4401         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4402         JNIEnv *env;
4403         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4404         LDKOutPoint funding_txo_var = funding_txo;
4405         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4406         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4407         long funding_txo_ref = (long)funding_txo_var.inner;
4408         if (funding_txo_var.is_owned) {
4409                 funding_txo_ref |= 1;
4410         }
4411         LDKChannelMonitorUpdate update_var = update;
4412         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4413         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4414         long update_ref = (long)update_var.inner;
4415         if (update_var.is_owned) {
4416                 update_ref |= 1;
4417         }
4418         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4419         CHECK(obj != NULL);
4420         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
4421         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
4422         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
4423         return ret_conv;
4424 }
4425 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
4426         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4427         JNIEnv *env;
4428         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4429         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4430         CHECK(obj != NULL);
4431         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
4432         LDKCVec_MonitorEventZ ret_constr;
4433         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
4434         if (ret_constr.datalen > 0)
4435                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4436         else
4437                 ret_constr.data = NULL;
4438         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
4439         for (size_t o = 0; o < ret_constr.datalen; o++) {
4440                 int64_t ret_conv_14 = ret_vals[o];
4441                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
4442                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
4443                 ret_constr.data[o] = ret_conv_14_conv;
4444         }
4445         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
4446         return ret_constr;
4447 }
4448 static void* LDKWatch_JCalls_clone(const void* this_arg) {
4449         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4450         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4451         return (void*) this_arg;
4452 }
4453 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
4454         jclass c = (*env)->GetObjectClass(env, o);
4455         CHECK(c != NULL);
4456         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
4457         atomic_init(&calls->refcnt, 1);
4458         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4459         calls->o = (*env)->NewWeakGlobalRef(env, o);
4460         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
4461         CHECK(calls->watch_channel_meth != NULL);
4462         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
4463         CHECK(calls->update_channel_meth != NULL);
4464         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
4465         CHECK(calls->release_pending_monitor_events_meth != NULL);
4466
4467         LDKWatch ret = {
4468                 .this_arg = (void*) calls,
4469                 .watch_channel = watch_channel_LDKWatch_jcall,
4470                 .update_channel = update_channel_LDKWatch_jcall,
4471                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
4472                 .free = LDKWatch_JCalls_free,
4473         };
4474         return ret;
4475 }
4476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
4477         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
4478         *res_ptr = LDKWatch_init(env, clz, o);
4479         return (long)res_ptr;
4480 }
4481 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) {
4482         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
4483         LDKOutPoint funding_txo_conv;
4484         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4485         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4486         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4487         LDKChannelMonitor monitor_conv;
4488         monitor_conv.inner = (void*)(monitor & (~1));
4489         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
4490         monitor_conv = ChannelMonitor_clone(&monitor_conv);
4491         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4492         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
4493         return (long)ret_conv;
4494 }
4495
4496 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) {
4497         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
4498         LDKOutPoint funding_txo_conv;
4499         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4500         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4501         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4502         LDKChannelMonitorUpdate update_conv;
4503         update_conv.inner = (void*)(update & (~1));
4504         update_conv.is_owned = (update & 1) || (update == 0);
4505         update_conv = ChannelMonitorUpdate_clone(&update_conv);
4506         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4507         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
4508         return (long)ret_conv;
4509 }
4510
4511 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4512         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
4513         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
4514         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4515         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4516         for (size_t o = 0; o < ret_var.datalen; o++) {
4517                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4518                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
4519                 long ret_conv_14_ref = (long)ret_conv_14_copy;
4520                 ret_arr_ptr[o] = ret_conv_14_ref;
4521         }
4522         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4523         FREE(ret_var.data);
4524         return ret_arr;
4525 }
4526
4527 typedef struct LDKBroadcasterInterface_JCalls {
4528         atomic_size_t refcnt;
4529         JavaVM *vm;
4530         jweak o;
4531         jmethodID broadcast_transaction_meth;
4532 } LDKBroadcasterInterface_JCalls;
4533 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
4534         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4535         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4536                 JNIEnv *env;
4537                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4538                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4539                 FREE(j_calls);
4540         }
4541 }
4542 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
4543         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4544         JNIEnv *env;
4545         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4546         LDKTransaction tx_var = tx;
4547         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
4548         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
4549         Transaction_free(tx_var);
4550         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4551         CHECK(obj != NULL);
4552         return (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
4553 }
4554 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
4555         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4556         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4557         return (void*) this_arg;
4558 }
4559 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
4560         jclass c = (*env)->GetObjectClass(env, o);
4561         CHECK(c != NULL);
4562         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
4563         atomic_init(&calls->refcnt, 1);
4564         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4565         calls->o = (*env)->NewWeakGlobalRef(env, o);
4566         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
4567         CHECK(calls->broadcast_transaction_meth != NULL);
4568
4569         LDKBroadcasterInterface ret = {
4570                 .this_arg = (void*) calls,
4571                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
4572                 .free = LDKBroadcasterInterface_JCalls_free,
4573         };
4574         return ret;
4575 }
4576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4577         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
4578         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
4579         return (long)res_ptr;
4580 }
4581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
4582         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
4583         LDKTransaction tx_ref;
4584         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
4585         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
4586         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
4587         tx_ref.data_is_owned = true;
4588         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
4589 }
4590
4591 typedef struct LDKKeysInterface_JCalls {
4592         atomic_size_t refcnt;
4593         JavaVM *vm;
4594         jweak o;
4595         jmethodID get_node_secret_meth;
4596         jmethodID get_destination_script_meth;
4597         jmethodID get_shutdown_pubkey_meth;
4598         jmethodID get_channel_signer_meth;
4599         jmethodID get_secure_random_bytes_meth;
4600         jmethodID read_chan_signer_meth;
4601 } LDKKeysInterface_JCalls;
4602 static void LDKKeysInterface_JCalls_free(void* this_arg) {
4603         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4604         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4605                 JNIEnv *env;
4606                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4607                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4608                 FREE(j_calls);
4609         }
4610 }
4611 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
4612         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4613         JNIEnv *env;
4614         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4615         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4616         CHECK(obj != NULL);
4617         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
4618         LDKSecretKey ret_ref;
4619         CHECK((*env)->GetArrayLength(env, ret) == 32);
4620         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
4621         return ret_ref;
4622 }
4623 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
4624         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4625         JNIEnv *env;
4626         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4627         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4628         CHECK(obj != NULL);
4629         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
4630         LDKCVec_u8Z ret_ref;
4631         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4632         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4633         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4634         return ret_ref;
4635 }
4636 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
4637         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4638         JNIEnv *env;
4639         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4640         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4641         CHECK(obj != NULL);
4642         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
4643         LDKPublicKey ret_ref;
4644         CHECK((*env)->GetArrayLength(env, ret) == 33);
4645         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
4646         return ret_ref;
4647 }
4648 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4649         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4650         JNIEnv *env;
4651         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4652         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4653         CHECK(obj != NULL);
4654         LDKSign* ret = (LDKSign*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
4655         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
4656         ret_conv = Sign_clone(ret);
4657         return ret_conv;
4658 }
4659 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4660         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4661         JNIEnv *env;
4662         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4663         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4664         CHECK(obj != NULL);
4665         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
4666         LDKThirtyTwoBytes ret_ref;
4667         CHECK((*env)->GetArrayLength(env, ret) == 32);
4668         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4669         return ret_ref;
4670 }
4671 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4672         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4673         JNIEnv *env;
4674         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4675         LDKu8slice reader_var = reader;
4676         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
4677         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
4678         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4679         CHECK(obj != NULL);
4680         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
4681         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
4682         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
4683         return ret_conv;
4684 }
4685 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
4686         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4687         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4688         return (void*) this_arg;
4689 }
4690 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
4691         jclass c = (*env)->GetObjectClass(env, o);
4692         CHECK(c != NULL);
4693         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4694         atomic_init(&calls->refcnt, 1);
4695         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4696         calls->o = (*env)->NewWeakGlobalRef(env, o);
4697         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
4698         CHECK(calls->get_node_secret_meth != NULL);
4699         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
4700         CHECK(calls->get_destination_script_meth != NULL);
4701         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
4702         CHECK(calls->get_shutdown_pubkey_meth != NULL);
4703         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
4704         CHECK(calls->get_channel_signer_meth != NULL);
4705         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
4706         CHECK(calls->get_secure_random_bytes_meth != NULL);
4707         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
4708         CHECK(calls->read_chan_signer_meth != NULL);
4709
4710         LDKKeysInterface ret = {
4711                 .this_arg = (void*) calls,
4712                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4713                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4714                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
4715                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4716                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4717                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4718                 .free = LDKKeysInterface_JCalls_free,
4719         };
4720         return ret;
4721 }
4722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4723         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4724         *res_ptr = LDKKeysInterface_init(env, clz, o);
4725         return (long)res_ptr;
4726 }
4727 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
4728         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4729         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4730         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
4731         return ret_arr;
4732 }
4733
4734 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
4735         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4736         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4737         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4738         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4739         CVec_u8Z_free(ret_var);
4740         return ret_arr;
4741 }
4742
4743 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
4744         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4745         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
4746         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
4747         return ret_arr;
4748 }
4749
4750 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) {
4751         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4752         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
4753         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4754         return (long)ret;
4755 }
4756
4757 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
4758         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4759         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4760         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
4761         return ret_arr;
4762 }
4763
4764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
4765         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4766         LDKu8slice reader_ref;
4767         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
4768         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
4769         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4770         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4771         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
4772         return (long)ret_conv;
4773 }
4774
4775 typedef struct LDKFeeEstimator_JCalls {
4776         atomic_size_t refcnt;
4777         JavaVM *vm;
4778         jweak o;
4779         jmethodID get_est_sat_per_1000_weight_meth;
4780 } LDKFeeEstimator_JCalls;
4781 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4782         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4783         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4784                 JNIEnv *env;
4785                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4786                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4787                 FREE(j_calls);
4788         }
4789 }
4790 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4791         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4792         JNIEnv *env;
4793         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4794         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
4795         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4796         CHECK(obj != NULL);
4797         return (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
4798 }
4799 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
4800         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4801         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4802         return (void*) this_arg;
4803 }
4804 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4805         jclass c = (*env)->GetObjectClass(env, o);
4806         CHECK(c != NULL);
4807         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4808         atomic_init(&calls->refcnt, 1);
4809         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4810         calls->o = (*env)->NewWeakGlobalRef(env, o);
4811         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I");
4812         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4813
4814         LDKFeeEstimator ret = {
4815                 .this_arg = (void*) calls,
4816                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4817                 .free = LDKFeeEstimator_JCalls_free,
4818         };
4819         return ret;
4820 }
4821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4822         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4823         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4824         return (long)res_ptr;
4825 }
4826 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) {
4827         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
4828         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4829         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4830         return ret_val;
4831 }
4832
4833 typedef struct LDKLogger_JCalls {
4834         atomic_size_t refcnt;
4835         JavaVM *vm;
4836         jweak o;
4837         jmethodID log_meth;
4838 } LDKLogger_JCalls;
4839 static void LDKLogger_JCalls_free(void* this_arg) {
4840         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4841         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4842                 JNIEnv *env;
4843                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4844                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4845                 FREE(j_calls);
4846         }
4847 }
4848 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
4849         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4850         JNIEnv *env;
4851         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4852         const char* record_str = record;
4853         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
4854         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4855         CHECK(obj != NULL);
4856         return (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
4857 }
4858 static void* LDKLogger_JCalls_clone(const void* this_arg) {
4859         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4860         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4861         return (void*) this_arg;
4862 }
4863 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4864         jclass c = (*env)->GetObjectClass(env, o);
4865         CHECK(c != NULL);
4866         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4867         atomic_init(&calls->refcnt, 1);
4868         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4869         calls->o = (*env)->NewWeakGlobalRef(env, o);
4870         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
4871         CHECK(calls->log_meth != NULL);
4872
4873         LDKLogger ret = {
4874                 .this_arg = (void*) calls,
4875                 .log = log_LDKLogger_jcall,
4876                 .free = LDKLogger_JCalls_free,
4877         };
4878         return ret;
4879 }
4880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4881         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4882         *res_ptr = LDKLogger_init(env, clz, o);
4883         return (long)res_ptr;
4884 }
4885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
4886         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
4887         LDKThirtyTwoBytes a_ref;
4888         CHECK((*env)->GetArrayLength(env, a) == 32);
4889         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4890         ret->a = a_ref;
4891         LDKChannelManager b_conv;
4892         b_conv.inner = (void*)(b & (~1));
4893         b_conv.is_owned = (b & 1) || (b == 0);
4894         // Warning: we need a move here but no clone is available for LDKChannelManager
4895         ret->b = b_conv;
4896         return (long)ret;
4897 }
4898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4899         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4900         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4901         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4902         return a_arr;
4903 }
4904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4905         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4906         LDKChannelManager b_var = tuple->b;
4907         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4908         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4909         long b_ref = (long)b_var.inner & ~1;
4910         return b_ref;
4911 }
4912 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4913         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
4914 }
4915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4916         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4917         CHECK(val->result_ok);
4918         long res_ref = (long)(&(*val->contents.result)) | 1;
4919         return res_ref;
4920 }
4921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4922         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4923         CHECK(!val->result_ok);
4924         LDKDecodeError err_var = (*val->contents.err);
4925         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4926         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4927         long err_ref = (long)err_var.inner & ~1;
4928         return err_ref;
4929 }
4930 typedef struct LDKMessageSendEventsProvider_JCalls {
4931         atomic_size_t refcnt;
4932         JavaVM *vm;
4933         jweak o;
4934         jmethodID get_and_clear_pending_msg_events_meth;
4935 } LDKMessageSendEventsProvider_JCalls;
4936 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
4937         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4938         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4939                 JNIEnv *env;
4940                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4941                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4942                 FREE(j_calls);
4943         }
4944 }
4945 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
4946         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4947         JNIEnv *env;
4948         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4949         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4950         CHECK(obj != NULL);
4951         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
4952         LDKCVec_MessageSendEventZ ret_constr;
4953         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
4954         if (ret_constr.datalen > 0)
4955                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4956         else
4957                 ret_constr.data = NULL;
4958         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
4959         for (size_t s = 0; s < ret_constr.datalen; s++) {
4960                 int64_t ret_conv_18 = ret_vals[s];
4961                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
4962                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
4963                 ret_constr.data[s] = ret_conv_18_conv;
4964         }
4965         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
4966         return ret_constr;
4967 }
4968 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
4969         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4970         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4971         return (void*) this_arg;
4972 }
4973 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
4974         jclass c = (*env)->GetObjectClass(env, o);
4975         CHECK(c != NULL);
4976         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
4977         atomic_init(&calls->refcnt, 1);
4978         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4979         calls->o = (*env)->NewWeakGlobalRef(env, o);
4980         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
4981         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
4982
4983         LDKMessageSendEventsProvider ret = {
4984                 .this_arg = (void*) calls,
4985                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
4986                 .free = LDKMessageSendEventsProvider_JCalls_free,
4987         };
4988         return ret;
4989 }
4990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
4991         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
4992         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
4993         return (long)res_ptr;
4994 }
4995 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4996         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
4997         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
4998         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4999         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5000         for (size_t s = 0; s < ret_var.datalen; s++) {
5001                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
5002                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
5003                 long ret_conv_18_ref = (long)ret_conv_18_copy;
5004                 ret_arr_ptr[s] = ret_conv_18_ref;
5005         }
5006         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5007         FREE(ret_var.data);
5008         return ret_arr;
5009 }
5010
5011 typedef struct LDKEventsProvider_JCalls {
5012         atomic_size_t refcnt;
5013         JavaVM *vm;
5014         jweak o;
5015         jmethodID get_and_clear_pending_events_meth;
5016 } LDKEventsProvider_JCalls;
5017 static void LDKEventsProvider_JCalls_free(void* this_arg) {
5018         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5019         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5020                 JNIEnv *env;
5021                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5022                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5023                 FREE(j_calls);
5024         }
5025 }
5026 LDKCVec_EventZ get_and_clear_pending_events_LDKEventsProvider_jcall(const void* this_arg) {
5027         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5028         JNIEnv *env;
5029         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5030         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5031         CHECK(obj != NULL);
5032         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_events_meth);
5033         LDKCVec_EventZ ret_constr;
5034         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
5035         if (ret_constr.datalen > 0)
5036                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
5037         else
5038                 ret_constr.data = NULL;
5039         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
5040         for (size_t h = 0; h < ret_constr.datalen; h++) {
5041                 int64_t ret_conv_7 = ret_vals[h];
5042                 LDKEvent ret_conv_7_conv = *(LDKEvent*)(((uint64_t)ret_conv_7) & ~1);
5043                 ret_conv_7_conv = Event_clone((LDKEvent*)(((uint64_t)ret_conv_7) & ~1));
5044                 ret_constr.data[h] = ret_conv_7_conv;
5045         }
5046         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
5047         return ret_constr;
5048 }
5049 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
5050         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5051         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5052         return (void*) this_arg;
5053 }
5054 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
5055         jclass c = (*env)->GetObjectClass(env, o);
5056         CHECK(c != NULL);
5057         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
5058         atomic_init(&calls->refcnt, 1);
5059         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5060         calls->o = (*env)->NewWeakGlobalRef(env, o);
5061         calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()[J");
5062         CHECK(calls->get_and_clear_pending_events_meth != NULL);
5063
5064         LDKEventsProvider ret = {
5065                 .this_arg = (void*) calls,
5066                 .get_and_clear_pending_events = get_and_clear_pending_events_LDKEventsProvider_jcall,
5067                 .free = LDKEventsProvider_JCalls_free,
5068         };
5069         return ret;
5070 }
5071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
5072         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
5073         *res_ptr = LDKEventsProvider_init(env, clz, o);
5074         return (long)res_ptr;
5075 }
5076 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_EventsProvider_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
5077         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
5078         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
5079         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5080         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5081         for (size_t h = 0; h < ret_var.datalen; h++) {
5082                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
5083                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
5084                 long ret_conv_7_ref = (long)ret_conv_7_copy;
5085                 ret_arr_ptr[h] = ret_conv_7_ref;
5086         }
5087         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5088         FREE(ret_var.data);
5089         return ret_arr;
5090 }
5091
5092 typedef struct LDKAccess_JCalls {
5093         atomic_size_t refcnt;
5094         JavaVM *vm;
5095         jweak o;
5096         jmethodID get_utxo_meth;
5097 } LDKAccess_JCalls;
5098 static void LDKAccess_JCalls_free(void* this_arg) {
5099         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
5100         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5101                 JNIEnv *env;
5102                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5103                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5104                 FREE(j_calls);
5105         }
5106 }
5107 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
5108         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
5109         JNIEnv *env;
5110         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5111         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
5112         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
5113         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5114         CHECK(obj != NULL);
5115         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
5116         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
5117         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
5118         return ret_conv;
5119 }
5120 static void* LDKAccess_JCalls_clone(const void* this_arg) {
5121         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
5122         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5123         return (void*) this_arg;
5124 }
5125 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
5126         jclass c = (*env)->GetObjectClass(env, o);
5127         CHECK(c != NULL);
5128         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
5129         atomic_init(&calls->refcnt, 1);
5130         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5131         calls->o = (*env)->NewWeakGlobalRef(env, o);
5132         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
5133         CHECK(calls->get_utxo_meth != NULL);
5134
5135         LDKAccess ret = {
5136                 .this_arg = (void*) calls,
5137                 .get_utxo = get_utxo_LDKAccess_jcall,
5138                 .free = LDKAccess_JCalls_free,
5139         };
5140         return ret;
5141 }
5142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
5143         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
5144         *res_ptr = LDKAccess_init(env, clz, o);
5145         return (long)res_ptr;
5146 }
5147 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) {
5148         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
5149         unsigned char genesis_hash_arr[32];
5150         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
5151         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
5152         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
5153         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
5154         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
5155         return (long)ret_conv;
5156 }
5157
5158 typedef struct LDKListen_JCalls {
5159         atomic_size_t refcnt;
5160         JavaVM *vm;
5161         jweak o;
5162         jmethodID block_connected_meth;
5163         jmethodID block_disconnected_meth;
5164 } LDKListen_JCalls;
5165 static void LDKListen_JCalls_free(void* this_arg) {
5166         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5167         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5168                 JNIEnv *env;
5169                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5170                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5171                 FREE(j_calls);
5172         }
5173 }
5174 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
5175         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5176         JNIEnv *env;
5177         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5178         LDKu8slice block_var = block;
5179         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
5180         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
5181         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5182         CHECK(obj != NULL);
5183         return (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
5184 }
5185 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
5186         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5187         JNIEnv *env;
5188         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5189         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
5190         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
5191         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5192         CHECK(obj != NULL);
5193         return (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
5194 }
5195 static void* LDKListen_JCalls_clone(const void* this_arg) {
5196         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5197         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5198         return (void*) this_arg;
5199 }
5200 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
5201         jclass c = (*env)->GetObjectClass(env, o);
5202         CHECK(c != NULL);
5203         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
5204         atomic_init(&calls->refcnt, 1);
5205         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5206         calls->o = (*env)->NewWeakGlobalRef(env, o);
5207         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
5208         CHECK(calls->block_connected_meth != NULL);
5209         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
5210         CHECK(calls->block_disconnected_meth != NULL);
5211
5212         LDKListen ret = {
5213                 .this_arg = (void*) calls,
5214                 .block_connected = block_connected_LDKListen_jcall,
5215                 .block_disconnected = block_disconnected_LDKListen_jcall,
5216                 .free = LDKListen_JCalls_free,
5217         };
5218         return ret;
5219 }
5220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
5221         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
5222         *res_ptr = LDKListen_init(env, clz, o);
5223         return (long)res_ptr;
5224 }
5225 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) {
5226         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
5227         LDKu8slice block_ref;
5228         block_ref.datalen = (*env)->GetArrayLength(env, block);
5229         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
5230         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
5231         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
5232 }
5233
5234 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) {
5235         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
5236         unsigned char header_arr[80];
5237         CHECK((*env)->GetArrayLength(env, header) == 80);
5238         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
5239         unsigned char (*header_ref)[80] = &header_arr;
5240         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
5241 }
5242
5243 typedef struct LDKFilter_JCalls {
5244         atomic_size_t refcnt;
5245         JavaVM *vm;
5246         jweak o;
5247         jmethodID register_tx_meth;
5248         jmethodID register_output_meth;
5249 } LDKFilter_JCalls;
5250 static void LDKFilter_JCalls_free(void* this_arg) {
5251         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5252         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5253                 JNIEnv *env;
5254                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5255                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5256                 FREE(j_calls);
5257         }
5258 }
5259 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5260         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5261         JNIEnv *env;
5262         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5263         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
5264         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
5265         LDKu8slice script_pubkey_var = script_pubkey;
5266         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
5267         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
5268         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5269         CHECK(obj != NULL);
5270         return (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
5271 }
5272 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5273         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5274         JNIEnv *env;
5275         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5276         LDKWatchedOutput output_var = output;
5277         CHECK((((long)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5278         CHECK((((long)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5279         long output_ref = (long)output_var.inner;
5280         if (output_var.is_owned) {
5281                 output_ref |= 1;
5282         }
5283         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5284         CHECK(obj != NULL);
5285         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)(*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
5286         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
5287         // Warning: we may need a move here but no clone is available for LDKCOption_C2Tuple_usizeTransactionZZ
5288         return ret_conv;
5289 }
5290 static void* LDKFilter_JCalls_clone(const void* this_arg) {
5291         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5292         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5293         return (void*) this_arg;
5294 }
5295 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
5296         jclass c = (*env)->GetObjectClass(env, o);
5297         CHECK(c != NULL);
5298         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5299         atomic_init(&calls->refcnt, 1);
5300         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5301         calls->o = (*env)->NewWeakGlobalRef(env, o);
5302         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
5303         CHECK(calls->register_tx_meth != NULL);
5304         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
5305         CHECK(calls->register_output_meth != NULL);
5306
5307         LDKFilter ret = {
5308                 .this_arg = (void*) calls,
5309                 .register_tx = register_tx_LDKFilter_jcall,
5310                 .register_output = register_output_LDKFilter_jcall,
5311                 .free = LDKFilter_JCalls_free,
5312         };
5313         return ret;
5314 }
5315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
5316         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5317         *res_ptr = LDKFilter_init(env, clz, o);
5318         return (long)res_ptr;
5319 }
5320 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) {
5321         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5322         unsigned char txid_arr[32];
5323         CHECK((*env)->GetArrayLength(env, txid) == 32);
5324         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
5325         unsigned char (*txid_ref)[32] = &txid_arr;
5326         LDKu8slice script_pubkey_ref;
5327         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
5328         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
5329         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5330         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
5331 }
5332
5333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
5334         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5335         LDKWatchedOutput output_conv;
5336         output_conv.inner = (void*)(output & (~1));
5337         output_conv.is_owned = (output & 1) || (output == 0);
5338         // Warning: we need a move here but no clone is available for LDKWatchedOutput
5339         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5340         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5341         long ret_ref = (long)ret_copy;
5342         return ret_ref;
5343 }
5344
5345 typedef struct LDKPersist_JCalls {
5346         atomic_size_t refcnt;
5347         JavaVM *vm;
5348         jweak o;
5349         jmethodID persist_new_channel_meth;
5350         jmethodID update_persisted_channel_meth;
5351 } LDKPersist_JCalls;
5352 static void LDKPersist_JCalls_free(void* this_arg) {
5353         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5354         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5355                 JNIEnv *env;
5356                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5357                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5358                 FREE(j_calls);
5359         }
5360 }
5361 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
5362         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5363         JNIEnv *env;
5364         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5365         LDKOutPoint id_var = id;
5366         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5367         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5368         long id_ref = (long)id_var.inner;
5369         if (id_var.is_owned) {
5370                 id_ref |= 1;
5371         }
5372         LDKChannelMonitor data_var = *data;
5373         data_var = ChannelMonitor_clone(data);
5374         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5375         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5376         long data_ref = (long)data_var.inner;
5377         if (data_var.is_owned) {
5378                 data_ref |= 1;
5379         }
5380         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5381         CHECK(obj != NULL);
5382         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
5383         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5384         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5385         return ret_conv;
5386 }
5387 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
5388         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5389         JNIEnv *env;
5390         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5391         LDKOutPoint id_var = id;
5392         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5393         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5394         long id_ref = (long)id_var.inner;
5395         if (id_var.is_owned) {
5396                 id_ref |= 1;
5397         }
5398         LDKChannelMonitorUpdate update_var = *update;
5399         update_var = ChannelMonitorUpdate_clone(update);
5400         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5401         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5402         long update_ref = (long)update_var.inner;
5403         if (update_var.is_owned) {
5404                 update_ref |= 1;
5405         }
5406         LDKChannelMonitor data_var = *data;
5407         data_var = ChannelMonitor_clone(data);
5408         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5409         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5410         long data_ref = (long)data_var.inner;
5411         if (data_var.is_owned) {
5412                 data_ref |= 1;
5413         }
5414         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5415         CHECK(obj != NULL);
5416         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
5417         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5418         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5419         return ret_conv;
5420 }
5421 static void* LDKPersist_JCalls_clone(const void* this_arg) {
5422         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5423         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5424         return (void*) this_arg;
5425 }
5426 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
5427         jclass c = (*env)->GetObjectClass(env, o);
5428         CHECK(c != NULL);
5429         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
5430         atomic_init(&calls->refcnt, 1);
5431         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5432         calls->o = (*env)->NewWeakGlobalRef(env, o);
5433         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
5434         CHECK(calls->persist_new_channel_meth != NULL);
5435         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
5436         CHECK(calls->update_persisted_channel_meth != NULL);
5437
5438         LDKPersist ret = {
5439                 .this_arg = (void*) calls,
5440                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
5441                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
5442                 .free = LDKPersist_JCalls_free,
5443         };
5444         return ret;
5445 }
5446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
5447         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
5448         *res_ptr = LDKPersist_init(env, clz, o);
5449         return (long)res_ptr;
5450 }
5451 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) {
5452         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5453         LDKOutPoint id_conv;
5454         id_conv.inner = (void*)(id & (~1));
5455         id_conv.is_owned = (id & 1) || (id == 0);
5456         id_conv = OutPoint_clone(&id_conv);
5457         LDKChannelMonitor data_conv;
5458         data_conv.inner = (void*)(data & (~1));
5459         data_conv.is_owned = false;
5460         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5461         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
5462         return (long)ret_conv;
5463 }
5464
5465 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) {
5466         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5467         LDKOutPoint id_conv;
5468         id_conv.inner = (void*)(id & (~1));
5469         id_conv.is_owned = (id & 1) || (id == 0);
5470         id_conv = OutPoint_clone(&id_conv);
5471         LDKChannelMonitorUpdate update_conv;
5472         update_conv.inner = (void*)(update & (~1));
5473         update_conv.is_owned = false;
5474         LDKChannelMonitor data_conv;
5475         data_conv.inner = (void*)(data & (~1));
5476         data_conv.is_owned = false;
5477         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5478         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
5479         return (long)ret_conv;
5480 }
5481
5482 typedef struct LDKChannelMessageHandler_JCalls {
5483         atomic_size_t refcnt;
5484         JavaVM *vm;
5485         jweak o;
5486         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5487         jmethodID handle_open_channel_meth;
5488         jmethodID handle_accept_channel_meth;
5489         jmethodID handle_funding_created_meth;
5490         jmethodID handle_funding_signed_meth;
5491         jmethodID handle_funding_locked_meth;
5492         jmethodID handle_shutdown_meth;
5493         jmethodID handle_closing_signed_meth;
5494         jmethodID handle_update_add_htlc_meth;
5495         jmethodID handle_update_fulfill_htlc_meth;
5496         jmethodID handle_update_fail_htlc_meth;
5497         jmethodID handle_update_fail_malformed_htlc_meth;
5498         jmethodID handle_commitment_signed_meth;
5499         jmethodID handle_revoke_and_ack_meth;
5500         jmethodID handle_update_fee_meth;
5501         jmethodID handle_announcement_signatures_meth;
5502         jmethodID peer_disconnected_meth;
5503         jmethodID peer_connected_meth;
5504         jmethodID handle_channel_reestablish_meth;
5505         jmethodID handle_channel_update_meth;
5506         jmethodID handle_error_meth;
5507 } LDKChannelMessageHandler_JCalls;
5508 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
5509         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5510         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5511                 JNIEnv *env;
5512                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5513                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5514                 FREE(j_calls);
5515         }
5516 }
5517 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
5518         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5519         JNIEnv *env;
5520         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5521         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5522         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5523         LDKInitFeatures their_features_var = their_features;
5524         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5525         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5526         long their_features_ref = (long)their_features_var.inner;
5527         if (their_features_var.is_owned) {
5528                 their_features_ref |= 1;
5529         }
5530         LDKOpenChannel msg_var = *msg;
5531         msg_var = OpenChannel_clone(msg);
5532         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5533         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5534         long msg_ref = (long)msg_var.inner;
5535         if (msg_var.is_owned) {
5536                 msg_ref |= 1;
5537         }
5538         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5539         CHECK(obj != NULL);
5540         return (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5541 }
5542 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
5543         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5544         JNIEnv *env;
5545         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5546         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5547         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5548         LDKInitFeatures their_features_var = their_features;
5549         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5550         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5551         long their_features_ref = (long)their_features_var.inner;
5552         if (their_features_var.is_owned) {
5553                 their_features_ref |= 1;
5554         }
5555         LDKAcceptChannel msg_var = *msg;
5556         msg_var = AcceptChannel_clone(msg);
5557         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5558         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5559         long msg_ref = (long)msg_var.inner;
5560         if (msg_var.is_owned) {
5561                 msg_ref |= 1;
5562         }
5563         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5564         CHECK(obj != NULL);
5565         return (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5566 }
5567 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
5568         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5569         JNIEnv *env;
5570         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5571         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5572         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5573         LDKFundingCreated msg_var = *msg;
5574         msg_var = FundingCreated_clone(msg);
5575         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5576         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5577         long msg_ref = (long)msg_var.inner;
5578         if (msg_var.is_owned) {
5579                 msg_ref |= 1;
5580         }
5581         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5582         CHECK(obj != NULL);
5583         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
5584 }
5585 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
5586         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5587         JNIEnv *env;
5588         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5589         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5590         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5591         LDKFundingSigned msg_var = *msg;
5592         msg_var = FundingSigned_clone(msg);
5593         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5594         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5595         long msg_ref = (long)msg_var.inner;
5596         if (msg_var.is_owned) {
5597                 msg_ref |= 1;
5598         }
5599         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5600         CHECK(obj != NULL);
5601         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
5602 }
5603 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
5604         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5605         JNIEnv *env;
5606         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5607         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5608         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5609         LDKFundingLocked msg_var = *msg;
5610         msg_var = FundingLocked_clone(msg);
5611         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5612         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5613         long msg_ref = (long)msg_var.inner;
5614         if (msg_var.is_owned) {
5615                 msg_ref |= 1;
5616         }
5617         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5618         CHECK(obj != NULL);
5619         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
5620 }
5621 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
5622         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5623         JNIEnv *env;
5624         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5625         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5626         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5627         LDKInitFeatures their_features_var = *their_features;
5628         their_features_var = InitFeatures_clone(their_features);
5629         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5630         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5631         long their_features_ref = (long)their_features_var.inner;
5632         if (their_features_var.is_owned) {
5633                 their_features_ref |= 1;
5634         }
5635         LDKShutdown msg_var = *msg;
5636         msg_var = Shutdown_clone(msg);
5637         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5638         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5639         long msg_ref = (long)msg_var.inner;
5640         if (msg_var.is_owned) {
5641                 msg_ref |= 1;
5642         }
5643         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5644         CHECK(obj != NULL);
5645         return (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
5646 }
5647 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
5648         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5649         JNIEnv *env;
5650         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5651         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5652         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5653         LDKClosingSigned msg_var = *msg;
5654         msg_var = ClosingSigned_clone(msg);
5655         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5656         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5657         long msg_ref = (long)msg_var.inner;
5658         if (msg_var.is_owned) {
5659                 msg_ref |= 1;
5660         }
5661         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5662         CHECK(obj != NULL);
5663         return (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
5664 }
5665 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
5666         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5667         JNIEnv *env;
5668         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5669         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5670         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5671         LDKUpdateAddHTLC msg_var = *msg;
5672         msg_var = UpdateAddHTLC_clone(msg);
5673         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5674         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5675         long msg_ref = (long)msg_var.inner;
5676         if (msg_var.is_owned) {
5677                 msg_ref |= 1;
5678         }
5679         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5680         CHECK(obj != NULL);
5681         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
5682 }
5683 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
5684         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5685         JNIEnv *env;
5686         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5687         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5688         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5689         LDKUpdateFulfillHTLC msg_var = *msg;
5690         msg_var = UpdateFulfillHTLC_clone(msg);
5691         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5692         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5693         long msg_ref = (long)msg_var.inner;
5694         if (msg_var.is_owned) {
5695                 msg_ref |= 1;
5696         }
5697         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5698         CHECK(obj != NULL);
5699         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
5700 }
5701 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
5702         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5703         JNIEnv *env;
5704         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5705         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5706         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5707         LDKUpdateFailHTLC msg_var = *msg;
5708         msg_var = UpdateFailHTLC_clone(msg);
5709         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5710         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5711         long msg_ref = (long)msg_var.inner;
5712         if (msg_var.is_owned) {
5713                 msg_ref |= 1;
5714         }
5715         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5716         CHECK(obj != NULL);
5717         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
5718 }
5719 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
5720         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5721         JNIEnv *env;
5722         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5723         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5724         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5725         LDKUpdateFailMalformedHTLC msg_var = *msg;
5726         msg_var = UpdateFailMalformedHTLC_clone(msg);
5727         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5728         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5729         long msg_ref = (long)msg_var.inner;
5730         if (msg_var.is_owned) {
5731                 msg_ref |= 1;
5732         }
5733         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5734         CHECK(obj != NULL);
5735         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
5736 }
5737 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
5738         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5739         JNIEnv *env;
5740         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5741         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5742         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5743         LDKCommitmentSigned msg_var = *msg;
5744         msg_var = CommitmentSigned_clone(msg);
5745         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5746         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5747         long msg_ref = (long)msg_var.inner;
5748         if (msg_var.is_owned) {
5749                 msg_ref |= 1;
5750         }
5751         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5752         CHECK(obj != NULL);
5753         return (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
5754 }
5755 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
5756         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5757         JNIEnv *env;
5758         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5759         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5760         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5761         LDKRevokeAndACK msg_var = *msg;
5762         msg_var = RevokeAndACK_clone(msg);
5763         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5764         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5765         long msg_ref = (long)msg_var.inner;
5766         if (msg_var.is_owned) {
5767                 msg_ref |= 1;
5768         }
5769         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5770         CHECK(obj != NULL);
5771         return (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
5772 }
5773 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
5774         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5775         JNIEnv *env;
5776         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5777         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5778         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5779         LDKUpdateFee msg_var = *msg;
5780         msg_var = UpdateFee_clone(msg);
5781         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5782         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5783         long msg_ref = (long)msg_var.inner;
5784         if (msg_var.is_owned) {
5785                 msg_ref |= 1;
5786         }
5787         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5788         CHECK(obj != NULL);
5789         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
5790 }
5791 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
5792         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5793         JNIEnv *env;
5794         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5795         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5796         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5797         LDKAnnouncementSignatures msg_var = *msg;
5798         msg_var = AnnouncementSignatures_clone(msg);
5799         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5800         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5801         long msg_ref = (long)msg_var.inner;
5802         if (msg_var.is_owned) {
5803                 msg_ref |= 1;
5804         }
5805         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5806         CHECK(obj != NULL);
5807         return (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
5808 }
5809 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
5810         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5811         JNIEnv *env;
5812         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5813         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5814         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5815         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5816         CHECK(obj != NULL);
5817         return (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
5818 }
5819 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
5820         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5821         JNIEnv *env;
5822         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5823         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5824         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5825         LDKInit msg_var = *msg;
5826         msg_var = Init_clone(msg);
5827         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5828         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5829         long msg_ref = (long)msg_var.inner;
5830         if (msg_var.is_owned) {
5831                 msg_ref |= 1;
5832         }
5833         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5834         CHECK(obj != NULL);
5835         return (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
5836 }
5837 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
5838         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5839         JNIEnv *env;
5840         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5841         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5842         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5843         LDKChannelReestablish msg_var = *msg;
5844         msg_var = ChannelReestablish_clone(msg);
5845         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5846         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5847         long msg_ref = (long)msg_var.inner;
5848         if (msg_var.is_owned) {
5849                 msg_ref |= 1;
5850         }
5851         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5852         CHECK(obj != NULL);
5853         return (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
5854 }
5855 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
5856         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5857         JNIEnv *env;
5858         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5859         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5860         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5861         LDKChannelUpdate msg_var = *msg;
5862         msg_var = ChannelUpdate_clone(msg);
5863         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5864         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5865         long msg_ref = (long)msg_var.inner;
5866         if (msg_var.is_owned) {
5867                 msg_ref |= 1;
5868         }
5869         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5870         CHECK(obj != NULL);
5871         return (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
5872 }
5873 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
5874         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5875         JNIEnv *env;
5876         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5877         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5878         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5879         LDKErrorMessage msg_var = *msg;
5880         msg_var = ErrorMessage_clone(msg);
5881         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5882         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5883         long msg_ref = (long)msg_var.inner;
5884         if (msg_var.is_owned) {
5885                 msg_ref |= 1;
5886         }
5887         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5888         CHECK(obj != NULL);
5889         return (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
5890 }
5891 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
5892         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5893         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5894         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5895         return (void*) this_arg;
5896 }
5897 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
5898         jclass c = (*env)->GetObjectClass(env, o);
5899         CHECK(c != NULL);
5900         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
5901         atomic_init(&calls->refcnt, 1);
5902         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5903         calls->o = (*env)->NewWeakGlobalRef(env, o);
5904         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
5905         CHECK(calls->handle_open_channel_meth != NULL);
5906         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
5907         CHECK(calls->handle_accept_channel_meth != NULL);
5908         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
5909         CHECK(calls->handle_funding_created_meth != NULL);
5910         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
5911         CHECK(calls->handle_funding_signed_meth != NULL);
5912         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
5913         CHECK(calls->handle_funding_locked_meth != NULL);
5914         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
5915         CHECK(calls->handle_shutdown_meth != NULL);
5916         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
5917         CHECK(calls->handle_closing_signed_meth != NULL);
5918         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
5919         CHECK(calls->handle_update_add_htlc_meth != NULL);
5920         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
5921         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
5922         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
5923         CHECK(calls->handle_update_fail_htlc_meth != NULL);
5924         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
5925         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
5926         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
5927         CHECK(calls->handle_commitment_signed_meth != NULL);
5928         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
5929         CHECK(calls->handle_revoke_and_ack_meth != NULL);
5930         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
5931         CHECK(calls->handle_update_fee_meth != NULL);
5932         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
5933         CHECK(calls->handle_announcement_signatures_meth != NULL);
5934         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
5935         CHECK(calls->peer_disconnected_meth != NULL);
5936         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
5937         CHECK(calls->peer_connected_meth != NULL);
5938         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
5939         CHECK(calls->handle_channel_reestablish_meth != NULL);
5940         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
5941         CHECK(calls->handle_channel_update_meth != NULL);
5942         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
5943         CHECK(calls->handle_error_meth != NULL);
5944
5945         LDKChannelMessageHandler ret = {
5946                 .this_arg = (void*) calls,
5947                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
5948                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
5949                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
5950                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
5951                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
5952                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
5953                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
5954                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
5955                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
5956                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
5957                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
5958                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
5959                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
5960                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
5961                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
5962                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
5963                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
5964                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
5965                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
5966                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
5967                 .free = LDKChannelMessageHandler_JCalls_free,
5968                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
5969         };
5970         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5971         return ret;
5972 }
5973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
5974         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
5975         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
5976         return (long)res_ptr;
5977 }
5978 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) {
5979         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5980         LDKPublicKey their_node_id_ref;
5981         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5982         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5983         LDKInitFeatures their_features_conv;
5984         their_features_conv.inner = (void*)(their_features & (~1));
5985         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5986         their_features_conv = InitFeatures_clone(&their_features_conv);
5987         LDKOpenChannel msg_conv;
5988         msg_conv.inner = (void*)(msg & (~1));
5989         msg_conv.is_owned = false;
5990         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5991 }
5992
5993 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) {
5994         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5995         LDKPublicKey their_node_id_ref;
5996         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5997         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5998         LDKInitFeatures their_features_conv;
5999         their_features_conv.inner = (void*)(their_features & (~1));
6000         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
6001         their_features_conv = InitFeatures_clone(&their_features_conv);
6002         LDKAcceptChannel msg_conv;
6003         msg_conv.inner = (void*)(msg & (~1));
6004         msg_conv.is_owned = false;
6005         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
6006 }
6007
6008 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) {
6009         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6010         LDKPublicKey their_node_id_ref;
6011         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6012         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6013         LDKFundingCreated msg_conv;
6014         msg_conv.inner = (void*)(msg & (~1));
6015         msg_conv.is_owned = false;
6016         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6017 }
6018
6019 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) {
6020         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6021         LDKPublicKey their_node_id_ref;
6022         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6023         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6024         LDKFundingSigned msg_conv;
6025         msg_conv.inner = (void*)(msg & (~1));
6026         msg_conv.is_owned = false;
6027         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6028 }
6029
6030 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) {
6031         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6032         LDKPublicKey their_node_id_ref;
6033         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6034         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6035         LDKFundingLocked msg_conv;
6036         msg_conv.inner = (void*)(msg & (~1));
6037         msg_conv.is_owned = false;
6038         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6039 }
6040
6041 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) {
6042         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6043         LDKPublicKey their_node_id_ref;
6044         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6045         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6046         LDKInitFeatures their_features_conv;
6047         their_features_conv.inner = (void*)(their_features & (~1));
6048         their_features_conv.is_owned = false;
6049         LDKShutdown msg_conv;
6050         msg_conv.inner = (void*)(msg & (~1));
6051         msg_conv.is_owned = false;
6052         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
6053 }
6054
6055 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) {
6056         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6057         LDKPublicKey their_node_id_ref;
6058         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6059         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6060         LDKClosingSigned msg_conv;
6061         msg_conv.inner = (void*)(msg & (~1));
6062         msg_conv.is_owned = false;
6063         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6064 }
6065
6066 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) {
6067         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6068         LDKPublicKey their_node_id_ref;
6069         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6070         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6071         LDKUpdateAddHTLC msg_conv;
6072         msg_conv.inner = (void*)(msg & (~1));
6073         msg_conv.is_owned = false;
6074         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6075 }
6076
6077 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) {
6078         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6079         LDKPublicKey their_node_id_ref;
6080         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6081         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6082         LDKUpdateFulfillHTLC msg_conv;
6083         msg_conv.inner = (void*)(msg & (~1));
6084         msg_conv.is_owned = false;
6085         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6086 }
6087
6088 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) {
6089         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6090         LDKPublicKey their_node_id_ref;
6091         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6092         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6093         LDKUpdateFailHTLC msg_conv;
6094         msg_conv.inner = (void*)(msg & (~1));
6095         msg_conv.is_owned = false;
6096         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6097 }
6098
6099 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) {
6100         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6101         LDKPublicKey their_node_id_ref;
6102         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6103         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6104         LDKUpdateFailMalformedHTLC msg_conv;
6105         msg_conv.inner = (void*)(msg & (~1));
6106         msg_conv.is_owned = false;
6107         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6108 }
6109
6110 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) {
6111         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6112         LDKPublicKey their_node_id_ref;
6113         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6114         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6115         LDKCommitmentSigned msg_conv;
6116         msg_conv.inner = (void*)(msg & (~1));
6117         msg_conv.is_owned = false;
6118         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6119 }
6120
6121 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) {
6122         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6123         LDKPublicKey their_node_id_ref;
6124         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6125         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6126         LDKRevokeAndACK msg_conv;
6127         msg_conv.inner = (void*)(msg & (~1));
6128         msg_conv.is_owned = false;
6129         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6130 }
6131
6132 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) {
6133         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6134         LDKPublicKey their_node_id_ref;
6135         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6136         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6137         LDKUpdateFee msg_conv;
6138         msg_conv.inner = (void*)(msg & (~1));
6139         msg_conv.is_owned = false;
6140         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6141 }
6142
6143 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) {
6144         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6145         LDKPublicKey their_node_id_ref;
6146         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6147         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6148         LDKAnnouncementSignatures msg_conv;
6149         msg_conv.inner = (void*)(msg & (~1));
6150         msg_conv.is_owned = false;
6151         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6152 }
6153
6154 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) {
6155         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6156         LDKPublicKey their_node_id_ref;
6157         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6158         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6159         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
6160 }
6161
6162 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) {
6163         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6164         LDKPublicKey their_node_id_ref;
6165         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6166         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6167         LDKInit msg_conv;
6168         msg_conv.inner = (void*)(msg & (~1));
6169         msg_conv.is_owned = false;
6170         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6171 }
6172
6173 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) {
6174         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6175         LDKPublicKey their_node_id_ref;
6176         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6177         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6178         LDKChannelReestablish msg_conv;
6179         msg_conv.inner = (void*)(msg & (~1));
6180         msg_conv.is_owned = false;
6181         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6182 }
6183
6184 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) {
6185         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6186         LDKPublicKey their_node_id_ref;
6187         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6188         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6189         LDKChannelUpdate msg_conv;
6190         msg_conv.inner = (void*)(msg & (~1));
6191         msg_conv.is_owned = false;
6192         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6193 }
6194
6195 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) {
6196         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6197         LDKPublicKey their_node_id_ref;
6198         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6199         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6200         LDKErrorMessage msg_conv;
6201         msg_conv.inner = (void*)(msg & (~1));
6202         msg_conv.is_owned = false;
6203         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6204 }
6205
6206 typedef struct LDKRoutingMessageHandler_JCalls {
6207         atomic_size_t refcnt;
6208         JavaVM *vm;
6209         jweak o;
6210         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
6211         jmethodID handle_node_announcement_meth;
6212         jmethodID handle_channel_announcement_meth;
6213         jmethodID handle_channel_update_meth;
6214         jmethodID handle_htlc_fail_channel_update_meth;
6215         jmethodID get_next_channel_announcements_meth;
6216         jmethodID get_next_node_announcements_meth;
6217         jmethodID sync_routing_table_meth;
6218         jmethodID handle_reply_channel_range_meth;
6219         jmethodID handle_reply_short_channel_ids_end_meth;
6220         jmethodID handle_query_channel_range_meth;
6221         jmethodID handle_query_short_channel_ids_meth;
6222 } LDKRoutingMessageHandler_JCalls;
6223 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
6224         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6225         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6226                 JNIEnv *env;
6227                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6228                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6229                 FREE(j_calls);
6230         }
6231 }
6232 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
6233         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6234         JNIEnv *env;
6235         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6236         LDKNodeAnnouncement msg_var = *msg;
6237         msg_var = NodeAnnouncement_clone(msg);
6238         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6239         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6240         long msg_ref = (long)msg_var.inner;
6241         if (msg_var.is_owned) {
6242                 msg_ref |= 1;
6243         }
6244         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6245         CHECK(obj != NULL);
6246         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
6247         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6248         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6249         return ret_conv;
6250 }
6251 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
6252         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6253         JNIEnv *env;
6254         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6255         LDKChannelAnnouncement msg_var = *msg;
6256         msg_var = ChannelAnnouncement_clone(msg);
6257         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6258         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6259         long msg_ref = (long)msg_var.inner;
6260         if (msg_var.is_owned) {
6261                 msg_ref |= 1;
6262         }
6263         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6264         CHECK(obj != NULL);
6265         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
6266         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6267         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6268         return ret_conv;
6269 }
6270 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
6271         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6272         JNIEnv *env;
6273         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6274         LDKChannelUpdate msg_var = *msg;
6275         msg_var = ChannelUpdate_clone(msg);
6276         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6277         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6278         long msg_ref = (long)msg_var.inner;
6279         if (msg_var.is_owned) {
6280                 msg_ref |= 1;
6281         }
6282         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6283         CHECK(obj != NULL);
6284         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
6285         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6286         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6287         return ret_conv;
6288 }
6289 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
6290         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6291         JNIEnv *env;
6292         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6293         long ret_update = (long)update;
6294         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6295         CHECK(obj != NULL);
6296         return (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
6297 }
6298 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
6299         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6300         JNIEnv *env;
6301         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6302         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6303         CHECK(obj != NULL);
6304         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
6305         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
6306         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6307         if (ret_constr.datalen > 0)
6308                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
6309         else
6310                 ret_constr.data = NULL;
6311         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6312         for (size_t l = 0; l < ret_constr.datalen; l++) {
6313                 int64_t ret_conv_63 = ret_vals[l];
6314                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
6315                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
6316                 ret_constr.data[l] = ret_conv_63_conv;
6317         }
6318         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6319         return ret_constr;
6320 }
6321 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
6322         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6323         JNIEnv *env;
6324         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6325         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
6326         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
6327         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6328         CHECK(obj != NULL);
6329         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
6330         LDKCVec_NodeAnnouncementZ ret_constr;
6331         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6332         if (ret_constr.datalen > 0)
6333                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
6334         else
6335                 ret_constr.data = NULL;
6336         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6337         for (size_t s = 0; s < ret_constr.datalen; s++) {
6338                 int64_t ret_conv_18 = ret_vals[s];
6339                 LDKNodeAnnouncement ret_conv_18_conv;
6340                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
6341                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
6342                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
6343                 ret_constr.data[s] = ret_conv_18_conv;
6344         }
6345         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6346         return ret_constr;
6347 }
6348 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
6349         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6350         JNIEnv *env;
6351         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6352         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6353         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6354         LDKInit init_var = *init;
6355         init_var = Init_clone(init);
6356         CHECK((((long)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6357         CHECK((((long)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6358         long init_ref = (long)init_var.inner;
6359         if (init_var.is_owned) {
6360                 init_ref |= 1;
6361         }
6362         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6363         CHECK(obj != NULL);
6364         return (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
6365 }
6366 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
6367         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6368         JNIEnv *env;
6369         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6370         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6371         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6372         LDKReplyChannelRange msg_var = msg;
6373         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6374         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6375         long msg_ref = (long)msg_var.inner;
6376         if (msg_var.is_owned) {
6377                 msg_ref |= 1;
6378         }
6379         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6380         CHECK(obj != NULL);
6381         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
6382         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6383         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6384         return ret_conv;
6385 }
6386 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
6387         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6388         JNIEnv *env;
6389         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6390         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6391         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6392         LDKReplyShortChannelIdsEnd msg_var = msg;
6393         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6394         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6395         long msg_ref = (long)msg_var.inner;
6396         if (msg_var.is_owned) {
6397                 msg_ref |= 1;
6398         }
6399         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6400         CHECK(obj != NULL);
6401         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
6402         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6403         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6404         return ret_conv;
6405 }
6406 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
6407         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6408         JNIEnv *env;
6409         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6410         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6411         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6412         LDKQueryChannelRange msg_var = msg;
6413         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6414         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6415         long msg_ref = (long)msg_var.inner;
6416         if (msg_var.is_owned) {
6417                 msg_ref |= 1;
6418         }
6419         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6420         CHECK(obj != NULL);
6421         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
6422         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6423         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6424         return ret_conv;
6425 }
6426 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
6427         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6428         JNIEnv *env;
6429         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6430         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6431         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6432         LDKQueryShortChannelIds msg_var = msg;
6433         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6434         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6435         long msg_ref = (long)msg_var.inner;
6436         if (msg_var.is_owned) {
6437                 msg_ref |= 1;
6438         }
6439         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6440         CHECK(obj != NULL);
6441         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
6442         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6443         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6444         return ret_conv;
6445 }
6446 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
6447         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6448         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6449         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6450         return (void*) this_arg;
6451 }
6452 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
6453         jclass c = (*env)->GetObjectClass(env, o);
6454         CHECK(c != NULL);
6455         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
6456         atomic_init(&calls->refcnt, 1);
6457         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6458         calls->o = (*env)->NewWeakGlobalRef(env, o);
6459         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
6460         CHECK(calls->handle_node_announcement_meth != NULL);
6461         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
6462         CHECK(calls->handle_channel_announcement_meth != NULL);
6463         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
6464         CHECK(calls->handle_channel_update_meth != NULL);
6465         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
6466         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
6467         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
6468         CHECK(calls->get_next_channel_announcements_meth != NULL);
6469         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
6470         CHECK(calls->get_next_node_announcements_meth != NULL);
6471         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
6472         CHECK(calls->sync_routing_table_meth != NULL);
6473         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
6474         CHECK(calls->handle_reply_channel_range_meth != NULL);
6475         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
6476         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
6477         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
6478         CHECK(calls->handle_query_channel_range_meth != NULL);
6479         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
6480         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
6481
6482         LDKRoutingMessageHandler ret = {
6483                 .this_arg = (void*) calls,
6484                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
6485                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
6486                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
6487                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
6488                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
6489                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
6490                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
6491                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
6492                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
6493                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
6494                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
6495                 .free = LDKRoutingMessageHandler_JCalls_free,
6496                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
6497         };
6498         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6499         return ret;
6500 }
6501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
6502         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
6503         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
6504         return (long)res_ptr;
6505 }
6506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6507         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6508         LDKNodeAnnouncement msg_conv;
6509         msg_conv.inner = (void*)(msg & (~1));
6510         msg_conv.is_owned = false;
6511         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6512         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
6513         return (long)ret_conv;
6514 }
6515
6516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6517         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6518         LDKChannelAnnouncement msg_conv;
6519         msg_conv.inner = (void*)(msg & (~1));
6520         msg_conv.is_owned = false;
6521         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6522         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6523         return (long)ret_conv;
6524 }
6525
6526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6527         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6528         LDKChannelUpdate msg_conv;
6529         msg_conv.inner = (void*)(msg & (~1));
6530         msg_conv.is_owned = false;
6531         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6532         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
6533         return (long)ret_conv;
6534 }
6535
6536 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) {
6537         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6538         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
6539         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
6540 }
6541
6542 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) {
6543         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6544         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
6545         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6546         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6547         for (size_t l = 0; l < ret_var.datalen; l++) {
6548                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6549                 *ret_conv_63_ref = ret_var.data[l];
6550                 ret_arr_ptr[l] = (long)ret_conv_63_ref;
6551         }
6552         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6553         FREE(ret_var.data);
6554         return ret_arr;
6555 }
6556
6557 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) {
6558         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6559         LDKPublicKey starting_point_ref;
6560         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
6561         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
6562         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
6563         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6564         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6565         for (size_t s = 0; s < ret_var.datalen; s++) {
6566                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
6567                 CHECK((((long)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6568                 CHECK((((long)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6569                 long ret_conv_18_ref = (long)ret_conv_18_var.inner;
6570                 if (ret_conv_18_var.is_owned) {
6571                         ret_conv_18_ref |= 1;
6572                 }
6573                 ret_arr_ptr[s] = ret_conv_18_ref;
6574         }
6575         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6576         FREE(ret_var.data);
6577         return ret_arr;
6578 }
6579
6580 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) {
6581         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6582         LDKPublicKey their_node_id_ref;
6583         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6584         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6585         LDKInit init_conv;
6586         init_conv.inner = (void*)(init & (~1));
6587         init_conv.is_owned = false;
6588         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
6589 }
6590
6591 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) {
6592         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6593         LDKPublicKey their_node_id_ref;
6594         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6595         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6596         LDKReplyChannelRange msg_conv;
6597         msg_conv.inner = (void*)(msg & (~1));
6598         msg_conv.is_owned = (msg & 1) || (msg == 0);
6599         msg_conv = ReplyChannelRange_clone(&msg_conv);
6600         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6601         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6602         return (long)ret_conv;
6603 }
6604
6605 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) {
6606         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6607         LDKPublicKey their_node_id_ref;
6608         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6609         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6610         LDKReplyShortChannelIdsEnd msg_conv;
6611         msg_conv.inner = (void*)(msg & (~1));
6612         msg_conv.is_owned = (msg & 1) || (msg == 0);
6613         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
6614         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6615         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6616         return (long)ret_conv;
6617 }
6618
6619 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) {
6620         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6621         LDKPublicKey their_node_id_ref;
6622         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6623         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6624         LDKQueryChannelRange msg_conv;
6625         msg_conv.inner = (void*)(msg & (~1));
6626         msg_conv.is_owned = (msg & 1) || (msg == 0);
6627         msg_conv = QueryChannelRange_clone(&msg_conv);
6628         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6629         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6630         return (long)ret_conv;
6631 }
6632
6633 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) {
6634         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6635         LDKPublicKey their_node_id_ref;
6636         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6637         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6638         LDKQueryShortChannelIds msg_conv;
6639         msg_conv.inner = (void*)(msg & (~1));
6640         msg_conv.is_owned = (msg & 1) || (msg == 0);
6641         msg_conv = QueryShortChannelIds_clone(&msg_conv);
6642         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6643         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6644         return (long)ret_conv;
6645 }
6646
6647 typedef struct LDKSocketDescriptor_JCalls {
6648         atomic_size_t refcnt;
6649         JavaVM *vm;
6650         jweak o;
6651         jmethodID send_data_meth;
6652         jmethodID disconnect_socket_meth;
6653         jmethodID eq_meth;
6654         jmethodID hash_meth;
6655 } LDKSocketDescriptor_JCalls;
6656 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
6657         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6658         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6659                 JNIEnv *env;
6660                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6661                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6662                 FREE(j_calls);
6663         }
6664 }
6665 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
6666         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6667         JNIEnv *env;
6668         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6669         LDKu8slice data_var = data;
6670         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
6671         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
6672         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6673         CHECK(obj != NULL);
6674         return (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
6675 }
6676 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
6677         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6678         JNIEnv *env;
6679         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6680         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6681         CHECK(obj != NULL);
6682         return (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
6683 }
6684 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
6685         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6686         JNIEnv *env;
6687         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6688         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6689         *other_arg_clone = SocketDescriptor_clone(other_arg);
6690         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6691         CHECK(obj != NULL);
6692         return (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (long)other_arg_clone);
6693 }
6694 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
6695         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6696         JNIEnv *env;
6697         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6698         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6699         CHECK(obj != NULL);
6700         return (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
6701 }
6702 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
6703         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6704         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6705         return (void*) this_arg;
6706 }
6707 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
6708         jclass c = (*env)->GetObjectClass(env, o);
6709         CHECK(c != NULL);
6710         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
6711         atomic_init(&calls->refcnt, 1);
6712         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6713         calls->o = (*env)->NewWeakGlobalRef(env, o);
6714         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
6715         CHECK(calls->send_data_meth != NULL);
6716         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
6717         CHECK(calls->disconnect_socket_meth != NULL);
6718         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
6719         CHECK(calls->eq_meth != NULL);
6720         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
6721         CHECK(calls->hash_meth != NULL);
6722
6723         LDKSocketDescriptor ret = {
6724                 .this_arg = (void*) calls,
6725                 .send_data = send_data_LDKSocketDescriptor_jcall,
6726                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
6727                 .eq = eq_LDKSocketDescriptor_jcall,
6728                 .hash = hash_LDKSocketDescriptor_jcall,
6729                 .clone = LDKSocketDescriptor_JCalls_clone,
6730                 .free = LDKSocketDescriptor_JCalls_free,
6731         };
6732         return ret;
6733 }
6734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
6735         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6736         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
6737         return (long)res_ptr;
6738 }
6739 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) {
6740         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6741         LDKu8slice data_ref;
6742         data_ref.datalen = (*env)->GetArrayLength(env, data);
6743         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
6744         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
6745         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
6746         return ret_val;
6747 }
6748
6749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
6750         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6751         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
6752 }
6753
6754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
6755         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6756         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
6757         return ret_val;
6758 }
6759
6760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
6761         LDKTransaction _res_ref;
6762         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
6763         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
6764         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
6765         _res_ref.data_is_owned = true;
6766         Transaction_free(_res_ref);
6767 }
6768
6769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
6770         if ((_res & 1) != 0) return;
6771         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
6772         FREE((void*)_res);
6773         TxOut_free(_res_conv);
6774 }
6775
6776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6777         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
6778         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6779         *ret_ref = TxOut_clone(orig_conv);
6780         return (long)ret_ref;
6781 }
6782
6783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6784         LDKChannelConfig o_conv;
6785         o_conv.inner = (void*)(o & (~1));
6786         o_conv.is_owned = (o & 1) || (o == 0);
6787         o_conv = ChannelConfig_clone(&o_conv);
6788         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6789         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
6790         return (long)ret_conv;
6791 }
6792
6793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6794         LDKDecodeError e_conv;
6795         e_conv.inner = (void*)(e & (~1));
6796         e_conv.is_owned = (e & 1) || (e == 0);
6797         e_conv = DecodeError_clone(&e_conv);
6798         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6799         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
6800         return (long)ret_conv;
6801 }
6802
6803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6804         if ((_res & 1) != 0) return;
6805         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
6806         FREE((void*)_res);
6807         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
6808 }
6809
6810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6811         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
6812         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6813         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
6814         return (long)ret_conv;
6815 }
6816
6817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6818         LDKOutPoint o_conv;
6819         o_conv.inner = (void*)(o & (~1));
6820         o_conv.is_owned = (o & 1) || (o == 0);
6821         o_conv = OutPoint_clone(&o_conv);
6822         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
6823         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
6824         return (long)ret_conv;
6825 }
6826
6827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6828         LDKDecodeError e_conv;
6829         e_conv.inner = (void*)(e & (~1));
6830         e_conv.is_owned = (e & 1) || (e == 0);
6831         e_conv = DecodeError_clone(&e_conv);
6832         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
6833         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
6834         return (long)ret_conv;
6835 }
6836
6837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6838         if ((_res & 1) != 0) return;
6839         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
6840         FREE((void*)_res);
6841         CResult_OutPointDecodeErrorZ_free(_res_conv);
6842 }
6843
6844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6845         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
6846         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
6847         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
6848         return (long)ret_conv;
6849 }
6850
6851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
6852         LDKSecretKey o_ref;
6853         CHECK((*env)->GetArrayLength(env, o) == 32);
6854         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
6855         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6856         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
6857         return (long)ret_conv;
6858 }
6859
6860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6861         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6862         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6863         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
6864         return (long)ret_conv;
6865 }
6866
6867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6868         if ((_res & 1) != 0) return;
6869         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
6870         FREE((void*)_res);
6871         CResult_SecretKeyErrorZ_free(_res_conv);
6872 }
6873
6874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
6875         LDKPublicKey o_ref;
6876         CHECK((*env)->GetArrayLength(env, o) == 33);
6877         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
6878         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6879         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
6880         return (long)ret_conv;
6881 }
6882
6883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6884         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6885         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6886         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
6887         return (long)ret_conv;
6888 }
6889
6890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6891         if ((_res & 1) != 0) return;
6892         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
6893         FREE((void*)_res);
6894         CResult_PublicKeyErrorZ_free(_res_conv);
6895 }
6896
6897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6898         LDKTxCreationKeys o_conv;
6899         o_conv.inner = (void*)(o & (~1));
6900         o_conv.is_owned = (o & 1) || (o == 0);
6901         o_conv = TxCreationKeys_clone(&o_conv);
6902         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6903         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
6904         return (long)ret_conv;
6905 }
6906
6907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6908         LDKDecodeError e_conv;
6909         e_conv.inner = (void*)(e & (~1));
6910         e_conv.is_owned = (e & 1) || (e == 0);
6911         e_conv = DecodeError_clone(&e_conv);
6912         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6913         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
6914         return (long)ret_conv;
6915 }
6916
6917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6918         if ((_res & 1) != 0) return;
6919         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6920         FREE((void*)_res);
6921         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
6922 }
6923
6924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6925         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
6926         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6927         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
6928         return (long)ret_conv;
6929 }
6930
6931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6932         LDKChannelPublicKeys o_conv;
6933         o_conv.inner = (void*)(o & (~1));
6934         o_conv.is_owned = (o & 1) || (o == 0);
6935         o_conv = ChannelPublicKeys_clone(&o_conv);
6936         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6937         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
6938         return (long)ret_conv;
6939 }
6940
6941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6942         LDKDecodeError e_conv;
6943         e_conv.inner = (void*)(e & (~1));
6944         e_conv.is_owned = (e & 1) || (e == 0);
6945         e_conv = DecodeError_clone(&e_conv);
6946         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6947         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
6948         return (long)ret_conv;
6949 }
6950
6951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6952         if ((_res & 1) != 0) return;
6953         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6954         FREE((void*)_res);
6955         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
6956 }
6957
6958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6959         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
6960         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6961         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
6962         return (long)ret_conv;
6963 }
6964
6965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6966         LDKTxCreationKeys o_conv;
6967         o_conv.inner = (void*)(o & (~1));
6968         o_conv.is_owned = (o & 1) || (o == 0);
6969         o_conv = TxCreationKeys_clone(&o_conv);
6970         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6971         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
6972         return (long)ret_conv;
6973 }
6974
6975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6976         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6977         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6978         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
6979         return (long)ret_conv;
6980 }
6981
6982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6983         if ((_res & 1) != 0) return;
6984         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
6985         FREE((void*)_res);
6986         CResult_TxCreationKeysErrorZ_free(_res_conv);
6987 }
6988
6989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
6990         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6991         *ret_copy = COption_u32Z_some(o);
6992         long ret_ref = (long)ret_copy;
6993         return ret_ref;
6994 }
6995
6996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
6997         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6998         *ret_copy = COption_u32Z_none();
6999         long ret_ref = (long)ret_copy;
7000         return ret_ref;
7001 }
7002
7003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
7004         if ((_res & 1) != 0) return;
7005         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
7006         FREE((void*)_res);
7007         COption_u32Z_free(_res_conv);
7008 }
7009
7010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7011         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
7012         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
7013         *ret_copy = COption_u32Z_clone(orig_conv);
7014         long ret_ref = (long)ret_copy;
7015         return ret_ref;
7016 }
7017
7018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7019         LDKHTLCOutputInCommitment o_conv;
7020         o_conv.inner = (void*)(o & (~1));
7021         o_conv.is_owned = (o & 1) || (o == 0);
7022         o_conv = HTLCOutputInCommitment_clone(&o_conv);
7023         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
7024         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
7025         return (long)ret_conv;
7026 }
7027
7028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7029         LDKDecodeError e_conv;
7030         e_conv.inner = (void*)(e & (~1));
7031         e_conv.is_owned = (e & 1) || (e == 0);
7032         e_conv = DecodeError_clone(&e_conv);
7033         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
7034         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
7035         return (long)ret_conv;
7036 }
7037
7038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7039         if ((_res & 1) != 0) return;
7040         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
7041         FREE((void*)_res);
7042         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
7043 }
7044
7045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7046         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
7047         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
7048         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
7049         return (long)ret_conv;
7050 }
7051
7052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7053         LDKCounterpartyChannelTransactionParameters o_conv;
7054         o_conv.inner = (void*)(o & (~1));
7055         o_conv.is_owned = (o & 1) || (o == 0);
7056         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
7057         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
7058         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
7059         return (long)ret_conv;
7060 }
7061
7062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7063         LDKDecodeError e_conv;
7064         e_conv.inner = (void*)(e & (~1));
7065         e_conv.is_owned = (e & 1) || (e == 0);
7066         e_conv = DecodeError_clone(&e_conv);
7067         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
7068         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
7069         return (long)ret_conv;
7070 }
7071
7072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7073         if ((_res & 1) != 0) return;
7074         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
7075         FREE((void*)_res);
7076         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
7077 }
7078
7079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7080         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
7081         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
7082         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
7083         return (long)ret_conv;
7084 }
7085
7086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7087         LDKChannelTransactionParameters o_conv;
7088         o_conv.inner = (void*)(o & (~1));
7089         o_conv.is_owned = (o & 1) || (o == 0);
7090         o_conv = ChannelTransactionParameters_clone(&o_conv);
7091         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
7092         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
7093         return (long)ret_conv;
7094 }
7095
7096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7097         LDKDecodeError e_conv;
7098         e_conv.inner = (void*)(e & (~1));
7099         e_conv.is_owned = (e & 1) || (e == 0);
7100         e_conv = DecodeError_clone(&e_conv);
7101         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
7102         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
7103         return (long)ret_conv;
7104 }
7105
7106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7107         if ((_res & 1) != 0) return;
7108         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
7109         FREE((void*)_res);
7110         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
7111 }
7112
7113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7114         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
7115         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
7116         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
7117         return (long)ret_conv;
7118 }
7119
7120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
7121         LDKCVec_SignatureZ _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(LDKSignature), "LDKCVec_SignatureZ Elements");
7125         else
7126                 _res_constr.data = NULL;
7127         for (size_t i = 0; i < _res_constr.datalen; i++) {
7128                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
7129                 LDKSignature _res_conv_8_ref;
7130                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
7131                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
7132                 _res_constr.data[i] = _res_conv_8_ref;
7133         }
7134         CVec_SignatureZ_free(_res_constr);
7135 }
7136
7137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7138         LDKHolderCommitmentTransaction o_conv;
7139         o_conv.inner = (void*)(o & (~1));
7140         o_conv.is_owned = (o & 1) || (o == 0);
7141         o_conv = HolderCommitmentTransaction_clone(&o_conv);
7142         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
7143         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
7144         return (long)ret_conv;
7145 }
7146
7147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7148         LDKDecodeError e_conv;
7149         e_conv.inner = (void*)(e & (~1));
7150         e_conv.is_owned = (e & 1) || (e == 0);
7151         e_conv = DecodeError_clone(&e_conv);
7152         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
7153         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
7154         return (long)ret_conv;
7155 }
7156
7157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7158         if ((_res & 1) != 0) return;
7159         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
7160         FREE((void*)_res);
7161         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
7162 }
7163
7164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7165         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
7166         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
7167         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
7168         return (long)ret_conv;
7169 }
7170
7171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7172         LDKBuiltCommitmentTransaction o_conv;
7173         o_conv.inner = (void*)(o & (~1));
7174         o_conv.is_owned = (o & 1) || (o == 0);
7175         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
7176         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
7177         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
7178         return (long)ret_conv;
7179 }
7180
7181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7182         LDKDecodeError e_conv;
7183         e_conv.inner = (void*)(e & (~1));
7184         e_conv.is_owned = (e & 1) || (e == 0);
7185         e_conv = DecodeError_clone(&e_conv);
7186         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
7187         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
7188         return (long)ret_conv;
7189 }
7190
7191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7192         if ((_res & 1) != 0) return;
7193         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
7194         FREE((void*)_res);
7195         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
7196 }
7197
7198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7199         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
7200         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
7201         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
7202         return (long)ret_conv;
7203 }
7204
7205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7206         LDKCommitmentTransaction o_conv;
7207         o_conv.inner = (void*)(o & (~1));
7208         o_conv.is_owned = (o & 1) || (o == 0);
7209         o_conv = CommitmentTransaction_clone(&o_conv);
7210         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
7211         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
7212         return (long)ret_conv;
7213 }
7214
7215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7216         LDKDecodeError e_conv;
7217         e_conv.inner = (void*)(e & (~1));
7218         e_conv.is_owned = (e & 1) || (e == 0);
7219         e_conv = DecodeError_clone(&e_conv);
7220         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
7221         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
7222         return (long)ret_conv;
7223 }
7224
7225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7226         if ((_res & 1) != 0) return;
7227         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
7228         FREE((void*)_res);
7229         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
7230 }
7231
7232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7233         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
7234         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
7235         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
7236         return (long)ret_conv;
7237 }
7238
7239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7240         LDKTrustedCommitmentTransaction o_conv;
7241         o_conv.inner = (void*)(o & (~1));
7242         o_conv.is_owned = (o & 1) || (o == 0);
7243         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
7244         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
7245         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
7246         return (long)ret_conv;
7247 }
7248
7249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
7250         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
7251         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
7252         return (long)ret_conv;
7253 }
7254
7255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7256         if ((_res & 1) != 0) return;
7257         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
7258         FREE((void*)_res);
7259         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
7260 }
7261
7262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
7263         LDKCVec_SignatureZ o_constr;
7264         o_constr.datalen = (*env)->GetArrayLength(env, o);
7265         if (o_constr.datalen > 0)
7266                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7267         else
7268                 o_constr.data = NULL;
7269         for (size_t i = 0; i < o_constr.datalen; i++) {
7270                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
7271                 LDKSignature o_conv_8_ref;
7272                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
7273                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
7274                 o_constr.data[i] = o_conv_8_ref;
7275         }
7276         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7277         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
7278         return (long)ret_conv;
7279 }
7280
7281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
7282         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7283         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
7284         return (long)ret_conv;
7285 }
7286
7287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7288         if ((_res & 1) != 0) return;
7289         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
7290         FREE((void*)_res);
7291         CResult_CVec_SignatureZNoneZ_free(_res_conv);
7292 }
7293
7294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7295         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
7296         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7297         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
7298         return (long)ret_conv;
7299 }
7300
7301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7302         LDKChannelMonitorUpdate o_conv;
7303         o_conv.inner = (void*)(o & (~1));
7304         o_conv.is_owned = (o & 1) || (o == 0);
7305         o_conv = ChannelMonitorUpdate_clone(&o_conv);
7306         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7307         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
7308         return (long)ret_conv;
7309 }
7310
7311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7312         LDKDecodeError e_conv;
7313         e_conv.inner = (void*)(e & (~1));
7314         e_conv.is_owned = (e & 1) || (e == 0);
7315         e_conv = DecodeError_clone(&e_conv);
7316         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7317         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
7318         return (long)ret_conv;
7319 }
7320
7321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7322         if ((_res & 1) != 0) return;
7323         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
7324         FREE((void*)_res);
7325         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
7326 }
7327
7328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7329         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
7330         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7331         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
7332         return (long)ret_conv;
7333 }
7334
7335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7336         LDKHTLCUpdate o_conv;
7337         o_conv.inner = (void*)(o & (~1));
7338         o_conv.is_owned = (o & 1) || (o == 0);
7339         o_conv = HTLCUpdate_clone(&o_conv);
7340         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7341         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
7342         return (long)ret_conv;
7343 }
7344
7345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7346         LDKDecodeError e_conv;
7347         e_conv.inner = (void*)(e & (~1));
7348         e_conv.is_owned = (e & 1) || (e == 0);
7349         e_conv = DecodeError_clone(&e_conv);
7350         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7351         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
7352         return (long)ret_conv;
7353 }
7354
7355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7356         if ((_res & 1) != 0) return;
7357         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
7358         FREE((void*)_res);
7359         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
7360 }
7361
7362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7363         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
7364         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7365         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
7366         return (long)ret_conv;
7367 }
7368
7369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
7370         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7371         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
7372         return (long)ret_conv;
7373 }
7374
7375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7376         LDKMonitorUpdateError e_conv;
7377         e_conv.inner = (void*)(e & (~1));
7378         e_conv.is_owned = (e & 1) || (e == 0);
7379         e_conv = MonitorUpdateError_clone(&e_conv);
7380         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7381         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
7382         return (long)ret_conv;
7383 }
7384
7385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7386         if ((_res & 1) != 0) return;
7387         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
7388         FREE((void*)_res);
7389         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
7390 }
7391
7392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7393         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
7394         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7395         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
7396         return (long)ret_conv;
7397 }
7398
7399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
7400         LDKOutPoint a_conv;
7401         a_conv.inner = (void*)(a & (~1));
7402         a_conv.is_owned = (a & 1) || (a == 0);
7403         a_conv = OutPoint_clone(&a_conv);
7404         LDKCVec_u8Z b_ref;
7405         b_ref.datalen = (*env)->GetArrayLength(env, b);
7406         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
7407         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7408         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
7409         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
7410         return (long)ret_ref;
7411 }
7412
7413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7414         if ((_res & 1) != 0) return;
7415         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
7416         FREE((void*)_res);
7417         C2Tuple_OutPointScriptZ_free(_res_conv);
7418 }
7419
7420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
7421         LDKCVec_u8Z b_ref;
7422         b_ref.datalen = (*env)->GetArrayLength(env, b);
7423         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
7424         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7425         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
7426         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
7427         return (long)ret_ref;
7428 }
7429
7430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7431         if ((_res & 1) != 0) return;
7432         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
7433         FREE((void*)_res);
7434         C2Tuple_u32ScriptZ_free(_res_conv);
7435 }
7436
7437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7438         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
7439         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7440         if (_res_constr.datalen > 0)
7441                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
7442         else
7443                 _res_constr.data = NULL;
7444         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7445         for (size_t b = 0; b < _res_constr.datalen; b++) {
7446                 int64_t _res_conv_27 = _res_vals[b];
7447                 LDKC2Tuple_u32ScriptZ _res_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_27) & ~1);
7448                 FREE((void*)_res_conv_27);
7449                 _res_constr.data[b] = _res_conv_27_conv;
7450         }
7451         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7452         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
7453 }
7454
7455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
7456         LDKThirtyTwoBytes a_ref;
7457         CHECK((*env)->GetArrayLength(env, a) == 32);
7458         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
7459         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
7460         b_constr.datalen = (*env)->GetArrayLength(env, b);
7461         if (b_constr.datalen > 0)
7462                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
7463         else
7464                 b_constr.data = NULL;
7465         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
7466         for (size_t b = 0; b < b_constr.datalen; b++) {
7467                 int64_t b_conv_27 = b_vals[b];
7468                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
7469                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_u32ScriptZ
7470                 b_constr.data[b] = b_conv_27_conv;
7471         }
7472         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
7473         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
7474         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
7475         return (long)ret_ref;
7476 }
7477
7478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7479         if ((_res & 1) != 0) return;
7480         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
7481         FREE((void*)_res);
7482         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
7483 }
7484
7485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7486         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
7487         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7488         if (_res_constr.datalen > 0)
7489                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
7490         else
7491                 _res_constr.data = NULL;
7492         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7493         for (size_t v = 0; v < _res_constr.datalen; v++) {
7494                 int64_t _res_conv_47 = _res_vals[v];
7495                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_47_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_47) & ~1);
7496                 FREE((void*)_res_conv_47);
7497                 _res_constr.data[v] = _res_conv_47_conv;
7498         }
7499         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7500         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
7501 }
7502
7503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7504         LDKCVec_MonitorEventZ _res_constr;
7505         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7506         if (_res_constr.datalen > 0)
7507                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
7508         else
7509                 _res_constr.data = NULL;
7510         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7511         for (size_t o = 0; o < _res_constr.datalen; o++) {
7512                 int64_t _res_conv_14 = _res_vals[o];
7513                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
7514                 FREE((void*)_res_conv_14);
7515                 _res_constr.data[o] = _res_conv_14_conv;
7516         }
7517         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7518         CVec_MonitorEventZ_free(_res_constr);
7519 }
7520
7521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7522         LDKCVec_EventZ _res_constr;
7523         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7524         if (_res_constr.datalen > 0)
7525                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
7526         else
7527                 _res_constr.data = NULL;
7528         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7529         for (size_t h = 0; h < _res_constr.datalen; h++) {
7530                 int64_t _res_conv_7 = _res_vals[h];
7531                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
7532                 FREE((void*)_res_conv_7);
7533                 _res_constr.data[h] = _res_conv_7_conv;
7534         }
7535         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7536         CVec_EventZ_free(_res_constr);
7537 }
7538
7539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
7540         LDKCVec_TransactionZ _res_constr;
7541         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7542         if (_res_constr.datalen > 0)
7543                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
7544         else
7545                 _res_constr.data = NULL;
7546         for (size_t i = 0; i < _res_constr.datalen; i++) {
7547                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
7548                 LDKTransaction _res_conv_8_ref;
7549                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
7550                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
7551                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
7552                 _res_conv_8_ref.data_is_owned = true;
7553                 _res_constr.data[i] = _res_conv_8_ref;
7554         }
7555         CVec_TransactionZ_free(_res_constr);
7556 }
7557
7558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
7559         LDKTransaction b_ref;
7560         b_ref.datalen = (*env)->GetArrayLength(env, b);
7561         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
7562         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7563         b_ref.data_is_owned = true;
7564         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7565         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
7566         return (long)ret_ref;
7567 }
7568
7569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7570         if ((_res & 1) != 0) return;
7571         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
7572         FREE((void*)_res);
7573         C2Tuple_usizeTransactionZ_free(_res_conv);
7574 }
7575
7576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7577         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
7578         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7579         if (_res_constr.datalen > 0)
7580                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7581         else
7582                 _res_constr.data = NULL;
7583         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7584         for (size_t y = 0; y < _res_constr.datalen; y++) {
7585                 int64_t _res_conv_24 = _res_vals[y];
7586                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
7587                 FREE((void*)_res_conv_24);
7588                 _res_constr.data[y] = _res_conv_24_conv;
7589         }
7590         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7591         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
7592 }
7593
7594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7595         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
7596         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7597         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
7598         return (long)ret_ref;
7599 }
7600
7601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
7602         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
7603         FREE((void*)b);
7604         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7605         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
7606         return (long)ret_ref;
7607 }
7608
7609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7610         if ((_res & 1) != 0) return;
7611         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
7612         FREE((void*)_res);
7613         C2Tuple_u32TxOutZ_free(_res_conv);
7614 }
7615
7616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7617         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
7618         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7619         if (_res_constr.datalen > 0)
7620                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
7621         else
7622                 _res_constr.data = NULL;
7623         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7624         for (size_t a = 0; a < _res_constr.datalen; a++) {
7625                 int64_t _res_conv_26 = _res_vals[a];
7626                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
7627                 FREE((void*)_res_conv_26);
7628                 _res_constr.data[a] = _res_conv_26_conv;
7629         }
7630         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7631         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
7632 }
7633
7634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
7635         LDKThirtyTwoBytes a_ref;
7636         CHECK((*env)->GetArrayLength(env, a) == 32);
7637         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
7638         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
7639         b_constr.datalen = (*env)->GetArrayLength(env, b);
7640         if (b_constr.datalen > 0)
7641                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
7642         else
7643                 b_constr.data = NULL;
7644         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
7645         for (size_t a = 0; a < b_constr.datalen; a++) {
7646                 int64_t b_conv_26 = b_vals[a];
7647                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
7648                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
7649                 b_constr.data[a] = b_conv_26_conv;
7650         }
7651         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
7652         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
7653         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
7654         return (long)ret_ref;
7655 }
7656
7657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7658         if ((_res & 1) != 0) return;
7659         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
7660         FREE((void*)_res);
7661         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
7662 }
7663
7664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7665         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
7666         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7667         if (_res_constr.datalen > 0)
7668                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
7669         else
7670                 _res_constr.data = NULL;
7671         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7672         for (size_t u = 0; u < _res_constr.datalen; u++) {
7673                 int64_t _res_conv_46 = _res_vals[u];
7674                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
7675                 FREE((void*)_res_conv_46);
7676                 _res_constr.data[u] = _res_conv_46_conv;
7677         }
7678         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7679         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
7680 }
7681
7682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
7683         LDKCVec_TxidZ _res_constr;
7684         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7685         if (_res_constr.datalen > 0)
7686                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7687         else
7688                 _res_constr.data = NULL;
7689         for (size_t i = 0; i < _res_constr.datalen; i++) {
7690                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
7691                 LDKThirtyTwoBytes _res_conv_8_ref;
7692                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
7693                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
7694                 _res_constr.data[i] = _res_conv_8_ref;
7695         }
7696         CVec_TxidZ_free(_res_constr);
7697 }
7698
7699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
7700         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7701         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
7702         return (long)ret_conv;
7703 }
7704
7705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
7706         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
7707         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7708         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
7709         return (long)ret_conv;
7710 }
7711
7712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7713         if ((_res & 1) != 0) return;
7714         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
7715         FREE((void*)_res);
7716         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
7717 }
7718
7719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7720         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
7721         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7722         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
7723         return (long)ret_conv;
7724 }
7725
7726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
7727         LDKThirtyTwoBytes a_ref;
7728         CHECK((*env)->GetArrayLength(env, a) == 32);
7729         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
7730         LDKChannelMonitor b_conv;
7731         b_conv.inner = (void*)(b & (~1));
7732         b_conv.is_owned = (b & 1) || (b == 0);
7733         b_conv = ChannelMonitor_clone(&b_conv);
7734         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7735         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
7736         return (long)ret_ref;
7737 }
7738
7739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7740         if ((_res & 1) != 0) return;
7741         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
7742         FREE((void*)_res);
7743         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
7744 }
7745
7746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7747         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
7748         FREE((void*)o);
7749         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
7750         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
7751         return (long)ret_conv;
7752 }
7753
7754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7755         LDKDecodeError e_conv;
7756         e_conv.inner = (void*)(e & (~1));
7757         e_conv.is_owned = (e & 1) || (e == 0);
7758         e_conv = DecodeError_clone(&e_conv);
7759         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
7760         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
7761         return (long)ret_conv;
7762 }
7763
7764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7765         if ((_res & 1) != 0) return;
7766         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
7767         FREE((void*)_res);
7768         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
7769 }
7770
7771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7772         LDKCVec_RouteHopZ _res_constr;
7773         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7774         if (_res_constr.datalen > 0)
7775                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7776         else
7777                 _res_constr.data = NULL;
7778         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7779         for (size_t k = 0; k < _res_constr.datalen; k++) {
7780                 int64_t _res_conv_10 = _res_vals[k];
7781                 LDKRouteHop _res_conv_10_conv;
7782                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
7783                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
7784                 _res_constr.data[k] = _res_conv_10_conv;
7785         }
7786         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7787         CVec_RouteHopZ_free(_res_constr);
7788 }
7789
7790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
7791         LDKCVec_CVec_RouteHopZZ _res_constr;
7792         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7793         if (_res_constr.datalen > 0)
7794                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
7795         else
7796                 _res_constr.data = NULL;
7797         for (size_t m = 0; m < _res_constr.datalen; m++) {
7798                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
7799                 LDKCVec_RouteHopZ _res_conv_12_constr;
7800                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
7801                 if (_res_conv_12_constr.datalen > 0)
7802                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7803                 else
7804                         _res_conv_12_constr.data = NULL;
7805                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
7806                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
7807                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
7808                         LDKRouteHop _res_conv_12_conv_10_conv;
7809                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
7810                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
7811                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
7812                 }
7813                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
7814                 _res_constr.data[m] = _res_conv_12_constr;
7815         }
7816         CVec_CVec_RouteHopZZ_free(_res_constr);
7817 }
7818
7819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7820         LDKRoute o_conv;
7821         o_conv.inner = (void*)(o & (~1));
7822         o_conv.is_owned = (o & 1) || (o == 0);
7823         o_conv = Route_clone(&o_conv);
7824         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7825         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
7826         return (long)ret_conv;
7827 }
7828
7829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7830         LDKDecodeError e_conv;
7831         e_conv.inner = (void*)(e & (~1));
7832         e_conv.is_owned = (e & 1) || (e == 0);
7833         e_conv = DecodeError_clone(&e_conv);
7834         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7835         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
7836         return (long)ret_conv;
7837 }
7838
7839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7840         if ((_res & 1) != 0) return;
7841         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
7842         FREE((void*)_res);
7843         CResult_RouteDecodeErrorZ_free(_res_conv);
7844 }
7845
7846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7847         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
7848         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7849         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
7850         return (long)ret_conv;
7851 }
7852
7853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
7854         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7855         *ret_copy = COption_u64Z_some(o);
7856         long ret_ref = (long)ret_copy;
7857         return ret_ref;
7858 }
7859
7860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
7861         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7862         *ret_copy = COption_u64Z_none();
7863         long ret_ref = (long)ret_copy;
7864         return ret_ref;
7865 }
7866
7867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
7868         if ((_res & 1) != 0) return;
7869         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
7870         FREE((void*)_res);
7871         COption_u64Z_free(_res_conv);
7872 }
7873
7874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7875         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
7876         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7877         *ret_copy = COption_u64Z_clone(orig_conv);
7878         long ret_ref = (long)ret_copy;
7879         return ret_ref;
7880 }
7881
7882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7883         LDKCVec_ChannelDetailsZ _res_constr;
7884         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7885         if (_res_constr.datalen > 0)
7886                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7887         else
7888                 _res_constr.data = NULL;
7889         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7890         for (size_t q = 0; q < _res_constr.datalen; q++) {
7891                 int64_t _res_conv_16 = _res_vals[q];
7892                 LDKChannelDetails _res_conv_16_conv;
7893                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7894                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7895                 _res_constr.data[q] = _res_conv_16_conv;
7896         }
7897         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7898         CVec_ChannelDetailsZ_free(_res_constr);
7899 }
7900
7901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7902         LDKCVec_RouteHintZ _res_constr;
7903         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7904         if (_res_constr.datalen > 0)
7905                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
7906         else
7907                 _res_constr.data = NULL;
7908         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7909         for (size_t l = 0; l < _res_constr.datalen; l++) {
7910                 int64_t _res_conv_11 = _res_vals[l];
7911                 LDKRouteHint _res_conv_11_conv;
7912                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
7913                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
7914                 _res_constr.data[l] = _res_conv_11_conv;
7915         }
7916         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7917         CVec_RouteHintZ_free(_res_constr);
7918 }
7919
7920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7921         LDKRoute o_conv;
7922         o_conv.inner = (void*)(o & (~1));
7923         o_conv.is_owned = (o & 1) || (o == 0);
7924         o_conv = Route_clone(&o_conv);
7925         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7926         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
7927         return (long)ret_conv;
7928 }
7929
7930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7931         LDKLightningError e_conv;
7932         e_conv.inner = (void*)(e & (~1));
7933         e_conv.is_owned = (e & 1) || (e == 0);
7934         e_conv = LightningError_clone(&e_conv);
7935         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7936         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
7937         return (long)ret_conv;
7938 }
7939
7940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7941         if ((_res & 1) != 0) return;
7942         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
7943         FREE((void*)_res);
7944         CResult_RouteLightningErrorZ_free(_res_conv);
7945 }
7946
7947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7948         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
7949         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7950         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
7951         return (long)ret_conv;
7952 }
7953
7954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7955         LDKCVec_MessageSendEventZ _res_constr;
7956         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7957         if (_res_constr.datalen > 0)
7958                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7959         else
7960                 _res_constr.data = NULL;
7961         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7962         for (size_t s = 0; s < _res_constr.datalen; s++) {
7963                 int64_t _res_conv_18 = _res_vals[s];
7964                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
7965                 FREE((void*)_res_conv_18);
7966                 _res_constr.data[s] = _res_conv_18_conv;
7967         }
7968         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7969         CVec_MessageSendEventZ_free(_res_constr);
7970 }
7971
7972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
7973         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7974         *ret_conv = CResult_boolLightningErrorZ_ok(o);
7975         return (long)ret_conv;
7976 }
7977
7978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7979         LDKLightningError e_conv;
7980         e_conv.inner = (void*)(e & (~1));
7981         e_conv.is_owned = (e & 1) || (e == 0);
7982         e_conv = LightningError_clone(&e_conv);
7983         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7984         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
7985         return (long)ret_conv;
7986 }
7987
7988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7989         if ((_res & 1) != 0) return;
7990         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
7991         FREE((void*)_res);
7992         CResult_boolLightningErrorZ_free(_res_conv);
7993 }
7994
7995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7996         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
7997         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7998         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
7999         return (long)ret_conv;
8000 }
8001
8002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8003         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
8004         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8005         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
8006         return (long)ret_ref;
8007 }
8008
8009 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) {
8010         LDKChannelAnnouncement a_conv;
8011         a_conv.inner = (void*)(a & (~1));
8012         a_conv.is_owned = (a & 1) || (a == 0);
8013         a_conv = ChannelAnnouncement_clone(&a_conv);
8014         LDKChannelUpdate b_conv;
8015         b_conv.inner = (void*)(b & (~1));
8016         b_conv.is_owned = (b & 1) || (b == 0);
8017         b_conv = ChannelUpdate_clone(&b_conv);
8018         LDKChannelUpdate c_conv;
8019         c_conv.inner = (void*)(c & (~1));
8020         c_conv.is_owned = (c & 1) || (c == 0);
8021         c_conv = ChannelUpdate_clone(&c_conv);
8022         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8023         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
8024         return (long)ret_ref;
8025 }
8026
8027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8028         if ((_res & 1) != 0) return;
8029         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
8030         FREE((void*)_res);
8031         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
8032 }
8033
8034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8035         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
8036         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8037         if (_res_constr.datalen > 0)
8038                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
8039         else
8040                 _res_constr.data = NULL;
8041         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8042         for (size_t l = 0; l < _res_constr.datalen; l++) {
8043                 int64_t _res_conv_63 = _res_vals[l];
8044                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
8045                 FREE((void*)_res_conv_63);
8046                 _res_constr.data[l] = _res_conv_63_conv;
8047         }
8048         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8049         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
8050 }
8051
8052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8053         LDKCVec_NodeAnnouncementZ _res_constr;
8054         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8055         if (_res_constr.datalen > 0)
8056                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
8057         else
8058                 _res_constr.data = NULL;
8059         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8060         for (size_t s = 0; s < _res_constr.datalen; s++) {
8061                 int64_t _res_conv_18 = _res_vals[s];
8062                 LDKNodeAnnouncement _res_conv_18_conv;
8063                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
8064                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
8065                 _res_constr.data[s] = _res_conv_18_conv;
8066         }
8067         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8068         CVec_NodeAnnouncementZ_free(_res_constr);
8069 }
8070
8071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
8072         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8073         *ret_conv = CResult_NoneLightningErrorZ_ok();
8074         return (long)ret_conv;
8075 }
8076
8077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8078         LDKLightningError e_conv;
8079         e_conv.inner = (void*)(e & (~1));
8080         e_conv.is_owned = (e & 1) || (e == 0);
8081         e_conv = LightningError_clone(&e_conv);
8082         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8083         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
8084         return (long)ret_conv;
8085 }
8086
8087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8088         if ((_res & 1) != 0) return;
8089         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
8090         FREE((void*)_res);
8091         CResult_NoneLightningErrorZ_free(_res_conv);
8092 }
8093
8094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8095         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
8096         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8097         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
8098         return (long)ret_conv;
8099 }
8100
8101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
8102         LDKCVec_PublicKeyZ _res_constr;
8103         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8104         if (_res_constr.datalen > 0)
8105                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
8106         else
8107                 _res_constr.data = NULL;
8108         for (size_t i = 0; i < _res_constr.datalen; i++) {
8109                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
8110                 LDKPublicKey _res_conv_8_ref;
8111                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
8112                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
8113                 _res_constr.data[i] = _res_conv_8_ref;
8114         }
8115         CVec_PublicKeyZ_free(_res_constr);
8116 }
8117
8118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
8119         LDKCVec_u8Z _res_ref;
8120         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
8121         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
8122         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
8123         CVec_u8Z_free(_res_ref);
8124 }
8125
8126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8127         LDKCVec_u8Z o_ref;
8128         o_ref.datalen = (*env)->GetArrayLength(env, o);
8129         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
8130         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
8131         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
8132         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
8133         return (long)ret_conv;
8134 }
8135
8136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8137         LDKPeerHandleError e_conv;
8138         e_conv.inner = (void*)(e & (~1));
8139         e_conv.is_owned = (e & 1) || (e == 0);
8140         e_conv = PeerHandleError_clone(&e_conv);
8141         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
8142         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
8143         return (long)ret_conv;
8144 }
8145
8146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8147         if ((_res & 1) != 0) return;
8148         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
8149         FREE((void*)_res);
8150         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
8151 }
8152
8153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8154         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
8155         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
8156         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
8157         return (long)ret_conv;
8158 }
8159
8160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
8161         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
8162         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
8163         return (long)ret_conv;
8164 }
8165
8166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8167         LDKPeerHandleError e_conv;
8168         e_conv.inner = (void*)(e & (~1));
8169         e_conv.is_owned = (e & 1) || (e == 0);
8170         e_conv = PeerHandleError_clone(&e_conv);
8171         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
8172         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
8173         return (long)ret_conv;
8174 }
8175
8176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8177         if ((_res & 1) != 0) return;
8178         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
8179         FREE((void*)_res);
8180         CResult_NonePeerHandleErrorZ_free(_res_conv);
8181 }
8182
8183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8184         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
8185         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
8186         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
8187         return (long)ret_conv;
8188 }
8189
8190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
8191         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
8192         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
8193         return (long)ret_conv;
8194 }
8195
8196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8197         LDKPeerHandleError e_conv;
8198         e_conv.inner = (void*)(e & (~1));
8199         e_conv.is_owned = (e & 1) || (e == 0);
8200         e_conv = PeerHandleError_clone(&e_conv);
8201         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
8202         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
8203         return (long)ret_conv;
8204 }
8205
8206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8207         if ((_res & 1) != 0) return;
8208         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
8209         FREE((void*)_res);
8210         CResult_boolPeerHandleErrorZ_free(_res_conv);
8211 }
8212
8213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8214         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
8215         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
8216         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
8217         return (long)ret_conv;
8218 }
8219
8220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8221         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
8222         FREE((void*)o);
8223         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8224         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
8225         return (long)ret_conv;
8226 }
8227
8228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
8229         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
8230         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8231         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
8232         return (long)ret_conv;
8233 }
8234
8235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8236         if ((_res & 1) != 0) return;
8237         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
8238         FREE((void*)_res);
8239         CResult_TxOutAccessErrorZ_free(_res_conv);
8240 }
8241
8242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8243         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
8244         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8245         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
8246         return (long)ret_conv;
8247 }
8248
8249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
8250         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
8251         FREE((void*)o);
8252         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8253         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
8254         long ret_ref = (long)ret_copy;
8255         return ret_ref;
8256 }
8257
8258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
8259         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8260         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
8261         long ret_ref = (long)ret_copy;
8262         return ret_ref;
8263 }
8264
8265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8266         if ((_res & 1) != 0) return;
8267         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
8268         FREE((void*)_res);
8269         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
8270 }
8271
8272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8273         LDKCVec_SpendableOutputDescriptorZ _res_constr;
8274         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8275         if (_res_constr.datalen > 0)
8276                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
8277         else
8278                 _res_constr.data = NULL;
8279         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8280         for (size_t b = 0; b < _res_constr.datalen; b++) {
8281                 int64_t _res_conv_27 = _res_vals[b];
8282                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
8283                 FREE((void*)_res_conv_27);
8284                 _res_constr.data[b] = _res_conv_27_conv;
8285         }
8286         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8287         CVec_SpendableOutputDescriptorZ_free(_res_constr);
8288 }
8289
8290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8291         LDKDirectionalChannelInfo o_conv;
8292         o_conv.inner = (void*)(o & (~1));
8293         o_conv.is_owned = (o & 1) || (o == 0);
8294         o_conv = DirectionalChannelInfo_clone(&o_conv);
8295         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
8296         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
8297         return (long)ret_conv;
8298 }
8299
8300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8301         LDKDecodeError e_conv;
8302         e_conv.inner = (void*)(e & (~1));
8303         e_conv.is_owned = (e & 1) || (e == 0);
8304         e_conv = DecodeError_clone(&e_conv);
8305         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
8306         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
8307         return (long)ret_conv;
8308 }
8309
8310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8311         if ((_res & 1) != 0) return;
8312         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
8313         FREE((void*)_res);
8314         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
8315 }
8316
8317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8318         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
8319         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
8320         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
8321         return (long)ret_conv;
8322 }
8323
8324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8325         LDKChannelInfo o_conv;
8326         o_conv.inner = (void*)(o & (~1));
8327         o_conv.is_owned = (o & 1) || (o == 0);
8328         o_conv = ChannelInfo_clone(&o_conv);
8329         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
8330         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
8331         return (long)ret_conv;
8332 }
8333
8334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8335         LDKDecodeError e_conv;
8336         e_conv.inner = (void*)(e & (~1));
8337         e_conv.is_owned = (e & 1) || (e == 0);
8338         e_conv = DecodeError_clone(&e_conv);
8339         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
8340         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
8341         return (long)ret_conv;
8342 }
8343
8344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8345         if ((_res & 1) != 0) return;
8346         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
8347         FREE((void*)_res);
8348         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
8349 }
8350
8351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8352         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
8353         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
8354         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
8355         return (long)ret_conv;
8356 }
8357
8358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8359         LDKRoutingFees o_conv;
8360         o_conv.inner = (void*)(o & (~1));
8361         o_conv.is_owned = (o & 1) || (o == 0);
8362         o_conv = RoutingFees_clone(&o_conv);
8363         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
8364         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
8365         return (long)ret_conv;
8366 }
8367
8368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8369         LDKDecodeError e_conv;
8370         e_conv.inner = (void*)(e & (~1));
8371         e_conv.is_owned = (e & 1) || (e == 0);
8372         e_conv = DecodeError_clone(&e_conv);
8373         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
8374         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
8375         return (long)ret_conv;
8376 }
8377
8378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8379         if ((_res & 1) != 0) return;
8380         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8381         FREE((void*)_res);
8382         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
8383 }
8384
8385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8386         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
8387         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
8388         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
8389         return (long)ret_conv;
8390 }
8391
8392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8393         LDKCVec_NetAddressZ _res_constr;
8394         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8395         if (_res_constr.datalen > 0)
8396                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
8397         else
8398                 _res_constr.data = NULL;
8399         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8400         for (size_t m = 0; m < _res_constr.datalen; m++) {
8401                 int64_t _res_conv_12 = _res_vals[m];
8402                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
8403                 FREE((void*)_res_conv_12);
8404                 _res_constr.data[m] = _res_conv_12_conv;
8405         }
8406         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8407         CVec_NetAddressZ_free(_res_constr);
8408 }
8409
8410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8411         LDKNodeAnnouncementInfo o_conv;
8412         o_conv.inner = (void*)(o & (~1));
8413         o_conv.is_owned = (o & 1) || (o == 0);
8414         o_conv = NodeAnnouncementInfo_clone(&o_conv);
8415         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
8416         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
8417         return (long)ret_conv;
8418 }
8419
8420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8421         LDKDecodeError e_conv;
8422         e_conv.inner = (void*)(e & (~1));
8423         e_conv.is_owned = (e & 1) || (e == 0);
8424         e_conv = DecodeError_clone(&e_conv);
8425         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
8426         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
8427         return (long)ret_conv;
8428 }
8429
8430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8431         if ((_res & 1) != 0) return;
8432         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
8433         FREE((void*)_res);
8434         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
8435 }
8436
8437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8438         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
8439         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
8440         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
8441         return (long)ret_conv;
8442 }
8443
8444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8445         LDKCVec_u64Z _res_constr;
8446         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8447         if (_res_constr.datalen > 0)
8448                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
8449         else
8450                 _res_constr.data = NULL;
8451         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8452         for (size_t g = 0; g < _res_constr.datalen; g++) {
8453                 int64_t _res_conv_6 = _res_vals[g];
8454                 _res_constr.data[g] = _res_conv_6;
8455         }
8456         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8457         CVec_u64Z_free(_res_constr);
8458 }
8459
8460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8461         LDKNodeInfo o_conv;
8462         o_conv.inner = (void*)(o & (~1));
8463         o_conv.is_owned = (o & 1) || (o == 0);
8464         o_conv = NodeInfo_clone(&o_conv);
8465         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
8466         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
8467         return (long)ret_conv;
8468 }
8469
8470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8471         LDKDecodeError e_conv;
8472         e_conv.inner = (void*)(e & (~1));
8473         e_conv.is_owned = (e & 1) || (e == 0);
8474         e_conv = DecodeError_clone(&e_conv);
8475         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
8476         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
8477         return (long)ret_conv;
8478 }
8479
8480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8481         if ((_res & 1) != 0) return;
8482         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
8483         FREE((void*)_res);
8484         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
8485 }
8486
8487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8488         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
8489         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
8490         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
8491         return (long)ret_conv;
8492 }
8493
8494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8495         LDKNetworkGraph o_conv;
8496         o_conv.inner = (void*)(o & (~1));
8497         o_conv.is_owned = (o & 1) || (o == 0);
8498         o_conv = NetworkGraph_clone(&o_conv);
8499         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
8500         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
8501         return (long)ret_conv;
8502 }
8503
8504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8505         LDKDecodeError e_conv;
8506         e_conv.inner = (void*)(e & (~1));
8507         e_conv.is_owned = (e & 1) || (e == 0);
8508         e_conv = DecodeError_clone(&e_conv);
8509         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
8510         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
8511         return (long)ret_conv;
8512 }
8513
8514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8515         if ((_res & 1) != 0) return;
8516         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
8517         FREE((void*)_res);
8518         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
8519 }
8520
8521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8522         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
8523         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
8524         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
8525         return (long)ret_conv;
8526 }
8527
8528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8529         LDKInitFeatures o_conv;
8530         o_conv.inner = (void*)(o & (~1));
8531         o_conv.is_owned = (o & 1) || (o == 0);
8532         o_conv = InitFeatures_clone(&o_conv);
8533         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
8534         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
8535         return (long)ret_conv;
8536 }
8537
8538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8539         LDKDecodeError e_conv;
8540         e_conv.inner = (void*)(e & (~1));
8541         e_conv.is_owned = (e & 1) || (e == 0);
8542         e_conv = DecodeError_clone(&e_conv);
8543         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
8544         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
8545         return (long)ret_conv;
8546 }
8547
8548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8549         if ((_res & 1) != 0) return;
8550         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8551         FREE((void*)_res);
8552         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
8553 }
8554
8555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8556         LDKNodeFeatures o_conv;
8557         o_conv.inner = (void*)(o & (~1));
8558         o_conv.is_owned = (o & 1) || (o == 0);
8559         o_conv = NodeFeatures_clone(&o_conv);
8560         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
8561         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
8562         return (long)ret_conv;
8563 }
8564
8565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8566         LDKDecodeError e_conv;
8567         e_conv.inner = (void*)(e & (~1));
8568         e_conv.is_owned = (e & 1) || (e == 0);
8569         e_conv = DecodeError_clone(&e_conv);
8570         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
8571         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
8572         return (long)ret_conv;
8573 }
8574
8575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8576         if ((_res & 1) != 0) return;
8577         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8578         FREE((void*)_res);
8579         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
8580 }
8581
8582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8583         LDKChannelFeatures o_conv;
8584         o_conv.inner = (void*)(o & (~1));
8585         o_conv.is_owned = (o & 1) || (o == 0);
8586         o_conv = ChannelFeatures_clone(&o_conv);
8587         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
8588         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
8589         return (long)ret_conv;
8590 }
8591
8592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8593         LDKDecodeError e_conv;
8594         e_conv.inner = (void*)(e & (~1));
8595         e_conv.is_owned = (e & 1) || (e == 0);
8596         e_conv = DecodeError_clone(&e_conv);
8597         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
8598         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
8599         return (long)ret_conv;
8600 }
8601
8602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8603         if ((_res & 1) != 0) return;
8604         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8605         FREE((void*)_res);
8606         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
8607 }
8608
8609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8610         LDKInvoiceFeatures o_conv;
8611         o_conv.inner = (void*)(o & (~1));
8612         o_conv.is_owned = (o & 1) || (o == 0);
8613         o_conv = InvoiceFeatures_clone(&o_conv);
8614         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
8615         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
8616         return (long)ret_conv;
8617 }
8618
8619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8620         LDKDecodeError e_conv;
8621         e_conv.inner = (void*)(e & (~1));
8622         e_conv.is_owned = (e & 1) || (e == 0);
8623         e_conv = DecodeError_clone(&e_conv);
8624         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
8625         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
8626         return (long)ret_conv;
8627 }
8628
8629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8630         if ((_res & 1) != 0) return;
8631         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8632         FREE((void*)_res);
8633         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
8634 }
8635
8636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
8637         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
8638         FREE((void*)o);
8639         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8640         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
8641         return (long)ret_conv;
8642 }
8643
8644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
8645         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8646         *ret_conv = CResult_NetAddressu8Z_err(e);
8647         return (long)ret_conv;
8648 }
8649
8650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
8651         if ((_res & 1) != 0) return;
8652         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
8653         FREE((void*)_res);
8654         CResult_NetAddressu8Z_free(_res_conv);
8655 }
8656
8657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8658         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
8659         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8660         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
8661         return (long)ret_conv;
8662 }
8663
8664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8665         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
8666         FREE((void*)o);
8667         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8668         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
8669         return (long)ret_conv;
8670 }
8671
8672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8673         LDKDecodeError e_conv;
8674         e_conv.inner = (void*)(e & (~1));
8675         e_conv.is_owned = (e & 1) || (e == 0);
8676         e_conv = DecodeError_clone(&e_conv);
8677         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8678         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
8679         return (long)ret_conv;
8680 }
8681
8682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8683         if ((_res & 1) != 0) return;
8684         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8685         FREE((void*)_res);
8686         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
8687 }
8688
8689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8690         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
8691         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8692         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
8693         return (long)ret_conv;
8694 }
8695
8696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8697         LDKCVec_UpdateAddHTLCZ _res_constr;
8698         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8699         if (_res_constr.datalen > 0)
8700                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
8701         else
8702                 _res_constr.data = NULL;
8703         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8704         for (size_t p = 0; p < _res_constr.datalen; p++) {
8705                 int64_t _res_conv_15 = _res_vals[p];
8706                 LDKUpdateAddHTLC _res_conv_15_conv;
8707                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
8708                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
8709                 _res_constr.data[p] = _res_conv_15_conv;
8710         }
8711         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8712         CVec_UpdateAddHTLCZ_free(_res_constr);
8713 }
8714
8715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8716         LDKCVec_UpdateFulfillHTLCZ _res_constr;
8717         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8718         if (_res_constr.datalen > 0)
8719                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
8720         else
8721                 _res_constr.data = NULL;
8722         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8723         for (size_t t = 0; t < _res_constr.datalen; t++) {
8724                 int64_t _res_conv_19 = _res_vals[t];
8725                 LDKUpdateFulfillHTLC _res_conv_19_conv;
8726                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
8727                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
8728                 _res_constr.data[t] = _res_conv_19_conv;
8729         }
8730         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8731         CVec_UpdateFulfillHTLCZ_free(_res_constr);
8732 }
8733
8734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8735         LDKCVec_UpdateFailHTLCZ _res_constr;
8736         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8737         if (_res_constr.datalen > 0)
8738                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
8739         else
8740                 _res_constr.data = NULL;
8741         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8742         for (size_t q = 0; q < _res_constr.datalen; q++) {
8743                 int64_t _res_conv_16 = _res_vals[q];
8744                 LDKUpdateFailHTLC _res_conv_16_conv;
8745                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8746                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8747                 _res_constr.data[q] = _res_conv_16_conv;
8748         }
8749         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8750         CVec_UpdateFailHTLCZ_free(_res_constr);
8751 }
8752
8753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8754         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
8755         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8756         if (_res_constr.datalen > 0)
8757                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
8758         else
8759                 _res_constr.data = NULL;
8760         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8761         for (size_t z = 0; z < _res_constr.datalen; z++) {
8762                 int64_t _res_conv_25 = _res_vals[z];
8763                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
8764                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
8765                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
8766                 _res_constr.data[z] = _res_conv_25_conv;
8767         }
8768         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8769         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
8770 }
8771
8772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8773         LDKAcceptChannel o_conv;
8774         o_conv.inner = (void*)(o & (~1));
8775         o_conv.is_owned = (o & 1) || (o == 0);
8776         o_conv = AcceptChannel_clone(&o_conv);
8777         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
8778         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
8779         return (long)ret_conv;
8780 }
8781
8782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8783         LDKDecodeError e_conv;
8784         e_conv.inner = (void*)(e & (~1));
8785         e_conv.is_owned = (e & 1) || (e == 0);
8786         e_conv = DecodeError_clone(&e_conv);
8787         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
8788         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
8789         return (long)ret_conv;
8790 }
8791
8792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8793         if ((_res & 1) != 0) return;
8794         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
8795         FREE((void*)_res);
8796         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
8797 }
8798
8799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8800         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
8801         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
8802         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
8803         return (long)ret_conv;
8804 }
8805
8806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8807         LDKAnnouncementSignatures o_conv;
8808         o_conv.inner = (void*)(o & (~1));
8809         o_conv.is_owned = (o & 1) || (o == 0);
8810         o_conv = AnnouncementSignatures_clone(&o_conv);
8811         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
8812         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
8813         return (long)ret_conv;
8814 }
8815
8816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8817         LDKDecodeError e_conv;
8818         e_conv.inner = (void*)(e & (~1));
8819         e_conv.is_owned = (e & 1) || (e == 0);
8820         e_conv = DecodeError_clone(&e_conv);
8821         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
8822         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
8823         return (long)ret_conv;
8824 }
8825
8826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8827         if ((_res & 1) != 0) return;
8828         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8829         FREE((void*)_res);
8830         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
8831 }
8832
8833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8834         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
8835         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
8836         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
8837         return (long)ret_conv;
8838 }
8839
8840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8841         LDKChannelReestablish o_conv;
8842         o_conv.inner = (void*)(o & (~1));
8843         o_conv.is_owned = (o & 1) || (o == 0);
8844         o_conv = ChannelReestablish_clone(&o_conv);
8845         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
8846         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
8847         return (long)ret_conv;
8848 }
8849
8850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8851         LDKDecodeError e_conv;
8852         e_conv.inner = (void*)(e & (~1));
8853         e_conv.is_owned = (e & 1) || (e == 0);
8854         e_conv = DecodeError_clone(&e_conv);
8855         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
8856         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
8857         return (long)ret_conv;
8858 }
8859
8860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8861         if ((_res & 1) != 0) return;
8862         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
8863         FREE((void*)_res);
8864         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
8865 }
8866
8867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8868         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
8869         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
8870         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
8871         return (long)ret_conv;
8872 }
8873
8874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8875         LDKClosingSigned o_conv;
8876         o_conv.inner = (void*)(o & (~1));
8877         o_conv.is_owned = (o & 1) || (o == 0);
8878         o_conv = ClosingSigned_clone(&o_conv);
8879         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
8880         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
8881         return (long)ret_conv;
8882 }
8883
8884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8885         LDKDecodeError e_conv;
8886         e_conv.inner = (void*)(e & (~1));
8887         e_conv.is_owned = (e & 1) || (e == 0);
8888         e_conv = DecodeError_clone(&e_conv);
8889         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
8890         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
8891         return (long)ret_conv;
8892 }
8893
8894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8895         if ((_res & 1) != 0) return;
8896         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8897         FREE((void*)_res);
8898         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
8899 }
8900
8901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8902         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
8903         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
8904         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
8905         return (long)ret_conv;
8906 }
8907
8908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8909         LDKCommitmentSigned o_conv;
8910         o_conv.inner = (void*)(o & (~1));
8911         o_conv.is_owned = (o & 1) || (o == 0);
8912         o_conv = CommitmentSigned_clone(&o_conv);
8913         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8914         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
8915         return (long)ret_conv;
8916 }
8917
8918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8919         LDKDecodeError e_conv;
8920         e_conv.inner = (void*)(e & (~1));
8921         e_conv.is_owned = (e & 1) || (e == 0);
8922         e_conv = DecodeError_clone(&e_conv);
8923         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8924         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
8925         return (long)ret_conv;
8926 }
8927
8928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8929         if ((_res & 1) != 0) return;
8930         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8931         FREE((void*)_res);
8932         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
8933 }
8934
8935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8936         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
8937         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8938         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
8939         return (long)ret_conv;
8940 }
8941
8942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8943         LDKFundingCreated o_conv;
8944         o_conv.inner = (void*)(o & (~1));
8945         o_conv.is_owned = (o & 1) || (o == 0);
8946         o_conv = FundingCreated_clone(&o_conv);
8947         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8948         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
8949         return (long)ret_conv;
8950 }
8951
8952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8953         LDKDecodeError e_conv;
8954         e_conv.inner = (void*)(e & (~1));
8955         e_conv.is_owned = (e & 1) || (e == 0);
8956         e_conv = DecodeError_clone(&e_conv);
8957         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8958         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
8959         return (long)ret_conv;
8960 }
8961
8962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8963         if ((_res & 1) != 0) return;
8964         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8965         FREE((void*)_res);
8966         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
8967 }
8968
8969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8970         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
8971         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8972         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
8973         return (long)ret_conv;
8974 }
8975
8976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8977         LDKFundingSigned o_conv;
8978         o_conv.inner = (void*)(o & (~1));
8979         o_conv.is_owned = (o & 1) || (o == 0);
8980         o_conv = FundingSigned_clone(&o_conv);
8981         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8982         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
8983         return (long)ret_conv;
8984 }
8985
8986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8987         LDKDecodeError e_conv;
8988         e_conv.inner = (void*)(e & (~1));
8989         e_conv.is_owned = (e & 1) || (e == 0);
8990         e_conv = DecodeError_clone(&e_conv);
8991         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8992         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
8993         return (long)ret_conv;
8994 }
8995
8996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8997         if ((_res & 1) != 0) return;
8998         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8999         FREE((void*)_res);
9000         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
9001 }
9002
9003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9004         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
9005         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9006         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
9007         return (long)ret_conv;
9008 }
9009
9010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9011         LDKFundingLocked o_conv;
9012         o_conv.inner = (void*)(o & (~1));
9013         o_conv.is_owned = (o & 1) || (o == 0);
9014         o_conv = FundingLocked_clone(&o_conv);
9015         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9016         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
9017         return (long)ret_conv;
9018 }
9019
9020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9021         LDKDecodeError e_conv;
9022         e_conv.inner = (void*)(e & (~1));
9023         e_conv.is_owned = (e & 1) || (e == 0);
9024         e_conv = DecodeError_clone(&e_conv);
9025         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9026         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
9027         return (long)ret_conv;
9028 }
9029
9030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9031         if ((_res & 1) != 0) return;
9032         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9033         FREE((void*)_res);
9034         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
9035 }
9036
9037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9038         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
9039         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9040         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
9041         return (long)ret_conv;
9042 }
9043
9044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9045         LDKInit o_conv;
9046         o_conv.inner = (void*)(o & (~1));
9047         o_conv.is_owned = (o & 1) || (o == 0);
9048         o_conv = Init_clone(&o_conv);
9049         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9050         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
9051         return (long)ret_conv;
9052 }
9053
9054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9055         LDKDecodeError e_conv;
9056         e_conv.inner = (void*)(e & (~1));
9057         e_conv.is_owned = (e & 1) || (e == 0);
9058         e_conv = DecodeError_clone(&e_conv);
9059         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9060         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
9061         return (long)ret_conv;
9062 }
9063
9064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9065         if ((_res & 1) != 0) return;
9066         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
9067         FREE((void*)_res);
9068         CResult_InitDecodeErrorZ_free(_res_conv);
9069 }
9070
9071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9072         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
9073         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9074         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
9075         return (long)ret_conv;
9076 }
9077
9078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9079         LDKOpenChannel o_conv;
9080         o_conv.inner = (void*)(o & (~1));
9081         o_conv.is_owned = (o & 1) || (o == 0);
9082         o_conv = OpenChannel_clone(&o_conv);
9083         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9084         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
9085         return (long)ret_conv;
9086 }
9087
9088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9089         LDKDecodeError e_conv;
9090         e_conv.inner = (void*)(e & (~1));
9091         e_conv.is_owned = (e & 1) || (e == 0);
9092         e_conv = DecodeError_clone(&e_conv);
9093         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9094         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
9095         return (long)ret_conv;
9096 }
9097
9098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9099         if ((_res & 1) != 0) return;
9100         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
9101         FREE((void*)_res);
9102         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
9103 }
9104
9105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9106         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
9107         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9108         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
9109         return (long)ret_conv;
9110 }
9111
9112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9113         LDKRevokeAndACK o_conv;
9114         o_conv.inner = (void*)(o & (~1));
9115         o_conv.is_owned = (o & 1) || (o == 0);
9116         o_conv = RevokeAndACK_clone(&o_conv);
9117         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9118         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
9119         return (long)ret_conv;
9120 }
9121
9122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9123         LDKDecodeError e_conv;
9124         e_conv.inner = (void*)(e & (~1));
9125         e_conv.is_owned = (e & 1) || (e == 0);
9126         e_conv = DecodeError_clone(&e_conv);
9127         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9128         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
9129         return (long)ret_conv;
9130 }
9131
9132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9133         if ((_res & 1) != 0) return;
9134         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
9135         FREE((void*)_res);
9136         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
9137 }
9138
9139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9140         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
9141         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9142         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
9143         return (long)ret_conv;
9144 }
9145
9146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9147         LDKShutdown o_conv;
9148         o_conv.inner = (void*)(o & (~1));
9149         o_conv.is_owned = (o & 1) || (o == 0);
9150         o_conv = Shutdown_clone(&o_conv);
9151         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9152         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
9153         return (long)ret_conv;
9154 }
9155
9156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9157         LDKDecodeError e_conv;
9158         e_conv.inner = (void*)(e & (~1));
9159         e_conv.is_owned = (e & 1) || (e == 0);
9160         e_conv = DecodeError_clone(&e_conv);
9161         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9162         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
9163         return (long)ret_conv;
9164 }
9165
9166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9167         if ((_res & 1) != 0) return;
9168         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
9169         FREE((void*)_res);
9170         CResult_ShutdownDecodeErrorZ_free(_res_conv);
9171 }
9172
9173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9174         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
9175         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9176         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
9177         return (long)ret_conv;
9178 }
9179
9180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9181         LDKUpdateFailHTLC o_conv;
9182         o_conv.inner = (void*)(o & (~1));
9183         o_conv.is_owned = (o & 1) || (o == 0);
9184         o_conv = UpdateFailHTLC_clone(&o_conv);
9185         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9186         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
9187         return (long)ret_conv;
9188 }
9189
9190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9191         LDKDecodeError e_conv;
9192         e_conv.inner = (void*)(e & (~1));
9193         e_conv.is_owned = (e & 1) || (e == 0);
9194         e_conv = DecodeError_clone(&e_conv);
9195         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9196         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
9197         return (long)ret_conv;
9198 }
9199
9200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9201         if ((_res & 1) != 0) return;
9202         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9203         FREE((void*)_res);
9204         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
9205 }
9206
9207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9208         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
9209         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9210         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
9211         return (long)ret_conv;
9212 }
9213
9214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9215         LDKUpdateFailMalformedHTLC o_conv;
9216         o_conv.inner = (void*)(o & (~1));
9217         o_conv.is_owned = (o & 1) || (o == 0);
9218         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
9219         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
9220         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
9221         return (long)ret_conv;
9222 }
9223
9224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9225         LDKDecodeError e_conv;
9226         e_conv.inner = (void*)(e & (~1));
9227         e_conv.is_owned = (e & 1) || (e == 0);
9228         e_conv = DecodeError_clone(&e_conv);
9229         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
9230         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
9231         return (long)ret_conv;
9232 }
9233
9234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9235         if ((_res & 1) != 0) return;
9236         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9237         FREE((void*)_res);
9238         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
9239 }
9240
9241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9242         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
9243         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
9244         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
9245         return (long)ret_conv;
9246 }
9247
9248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9249         LDKUpdateFee o_conv;
9250         o_conv.inner = (void*)(o & (~1));
9251         o_conv.is_owned = (o & 1) || (o == 0);
9252         o_conv = UpdateFee_clone(&o_conv);
9253         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
9254         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
9255         return (long)ret_conv;
9256 }
9257
9258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9259         LDKDecodeError e_conv;
9260         e_conv.inner = (void*)(e & (~1));
9261         e_conv.is_owned = (e & 1) || (e == 0);
9262         e_conv = DecodeError_clone(&e_conv);
9263         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
9264         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
9265         return (long)ret_conv;
9266 }
9267
9268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9269         if ((_res & 1) != 0) return;
9270         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9271         FREE((void*)_res);
9272         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
9273 }
9274
9275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9276         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
9277         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
9278         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
9279         return (long)ret_conv;
9280 }
9281
9282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9283         LDKUpdateFulfillHTLC o_conv;
9284         o_conv.inner = (void*)(o & (~1));
9285         o_conv.is_owned = (o & 1) || (o == 0);
9286         o_conv = UpdateFulfillHTLC_clone(&o_conv);
9287         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
9288         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
9289         return (long)ret_conv;
9290 }
9291
9292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9293         LDKDecodeError e_conv;
9294         e_conv.inner = (void*)(e & (~1));
9295         e_conv.is_owned = (e & 1) || (e == 0);
9296         e_conv = DecodeError_clone(&e_conv);
9297         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
9298         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
9299         return (long)ret_conv;
9300 }
9301
9302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9303         if ((_res & 1) != 0) return;
9304         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9305         FREE((void*)_res);
9306         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
9307 }
9308
9309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9310         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
9311         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
9312         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
9313         return (long)ret_conv;
9314 }
9315
9316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9317         LDKUpdateAddHTLC o_conv;
9318         o_conv.inner = (void*)(o & (~1));
9319         o_conv.is_owned = (o & 1) || (o == 0);
9320         o_conv = UpdateAddHTLC_clone(&o_conv);
9321         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
9322         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
9323         return (long)ret_conv;
9324 }
9325
9326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9327         LDKDecodeError e_conv;
9328         e_conv.inner = (void*)(e & (~1));
9329         e_conv.is_owned = (e & 1) || (e == 0);
9330         e_conv = DecodeError_clone(&e_conv);
9331         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
9332         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
9333         return (long)ret_conv;
9334 }
9335
9336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9337         if ((_res & 1) != 0) return;
9338         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9339         FREE((void*)_res);
9340         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
9341 }
9342
9343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9344         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
9345         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
9346         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
9347         return (long)ret_conv;
9348 }
9349
9350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9351         LDKPing o_conv;
9352         o_conv.inner = (void*)(o & (~1));
9353         o_conv.is_owned = (o & 1) || (o == 0);
9354         o_conv = Ping_clone(&o_conv);
9355         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
9356         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
9357         return (long)ret_conv;
9358 }
9359
9360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9361         LDKDecodeError e_conv;
9362         e_conv.inner = (void*)(e & (~1));
9363         e_conv.is_owned = (e & 1) || (e == 0);
9364         e_conv = DecodeError_clone(&e_conv);
9365         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
9366         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
9367         return (long)ret_conv;
9368 }
9369
9370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9371         if ((_res & 1) != 0) return;
9372         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
9373         FREE((void*)_res);
9374         CResult_PingDecodeErrorZ_free(_res_conv);
9375 }
9376
9377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9378         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
9379         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
9380         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
9381         return (long)ret_conv;
9382 }
9383
9384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9385         LDKPong o_conv;
9386         o_conv.inner = (void*)(o & (~1));
9387         o_conv.is_owned = (o & 1) || (o == 0);
9388         o_conv = Pong_clone(&o_conv);
9389         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
9390         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
9391         return (long)ret_conv;
9392 }
9393
9394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9395         LDKDecodeError e_conv;
9396         e_conv.inner = (void*)(e & (~1));
9397         e_conv.is_owned = (e & 1) || (e == 0);
9398         e_conv = DecodeError_clone(&e_conv);
9399         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
9400         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
9401         return (long)ret_conv;
9402 }
9403
9404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9405         if ((_res & 1) != 0) return;
9406         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
9407         FREE((void*)_res);
9408         CResult_PongDecodeErrorZ_free(_res_conv);
9409 }
9410
9411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9412         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
9413         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
9414         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
9415         return (long)ret_conv;
9416 }
9417
9418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9419         LDKUnsignedChannelAnnouncement o_conv;
9420         o_conv.inner = (void*)(o & (~1));
9421         o_conv.is_owned = (o & 1) || (o == 0);
9422         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
9423         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
9424         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
9425         return (long)ret_conv;
9426 }
9427
9428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9429         LDKDecodeError e_conv;
9430         e_conv.inner = (void*)(e & (~1));
9431         e_conv.is_owned = (e & 1) || (e == 0);
9432         e_conv = DecodeError_clone(&e_conv);
9433         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
9434         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
9435         return (long)ret_conv;
9436 }
9437
9438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9439         if ((_res & 1) != 0) return;
9440         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9441         FREE((void*)_res);
9442         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
9443 }
9444
9445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9446         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
9447         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
9448         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
9449         return (long)ret_conv;
9450 }
9451
9452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9453         LDKChannelAnnouncement o_conv;
9454         o_conv.inner = (void*)(o & (~1));
9455         o_conv.is_owned = (o & 1) || (o == 0);
9456         o_conv = ChannelAnnouncement_clone(&o_conv);
9457         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
9458         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
9459         return (long)ret_conv;
9460 }
9461
9462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9463         LDKDecodeError e_conv;
9464         e_conv.inner = (void*)(e & (~1));
9465         e_conv.is_owned = (e & 1) || (e == 0);
9466         e_conv = DecodeError_clone(&e_conv);
9467         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
9468         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
9469         return (long)ret_conv;
9470 }
9471
9472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9473         if ((_res & 1) != 0) return;
9474         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9475         FREE((void*)_res);
9476         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
9477 }
9478
9479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9480         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
9481         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
9482         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
9483         return (long)ret_conv;
9484 }
9485
9486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9487         LDKUnsignedChannelUpdate o_conv;
9488         o_conv.inner = (void*)(o & (~1));
9489         o_conv.is_owned = (o & 1) || (o == 0);
9490         o_conv = UnsignedChannelUpdate_clone(&o_conv);
9491         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
9492         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
9493         return (long)ret_conv;
9494 }
9495
9496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9497         LDKDecodeError e_conv;
9498         e_conv.inner = (void*)(e & (~1));
9499         e_conv.is_owned = (e & 1) || (e == 0);
9500         e_conv = DecodeError_clone(&e_conv);
9501         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
9502         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
9503         return (long)ret_conv;
9504 }
9505
9506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9507         if ((_res & 1) != 0) return;
9508         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
9509         FREE((void*)_res);
9510         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
9511 }
9512
9513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9514         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
9515         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
9516         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
9517         return (long)ret_conv;
9518 }
9519
9520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9521         LDKChannelUpdate o_conv;
9522         o_conv.inner = (void*)(o & (~1));
9523         o_conv.is_owned = (o & 1) || (o == 0);
9524         o_conv = ChannelUpdate_clone(&o_conv);
9525         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
9526         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
9527         return (long)ret_conv;
9528 }
9529
9530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9531         LDKDecodeError e_conv;
9532         e_conv.inner = (void*)(e & (~1));
9533         e_conv.is_owned = (e & 1) || (e == 0);
9534         e_conv = DecodeError_clone(&e_conv);
9535         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
9536         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
9537         return (long)ret_conv;
9538 }
9539
9540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9541         if ((_res & 1) != 0) return;
9542         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
9543         FREE((void*)_res);
9544         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
9545 }
9546
9547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9548         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
9549         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
9550         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
9551         return (long)ret_conv;
9552 }
9553
9554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9555         LDKErrorMessage o_conv;
9556         o_conv.inner = (void*)(o & (~1));
9557         o_conv.is_owned = (o & 1) || (o == 0);
9558         o_conv = ErrorMessage_clone(&o_conv);
9559         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
9560         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
9561         return (long)ret_conv;
9562 }
9563
9564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9565         LDKDecodeError e_conv;
9566         e_conv.inner = (void*)(e & (~1));
9567         e_conv.is_owned = (e & 1) || (e == 0);
9568         e_conv = DecodeError_clone(&e_conv);
9569         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
9570         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
9571         return (long)ret_conv;
9572 }
9573
9574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9575         if ((_res & 1) != 0) return;
9576         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
9577         FREE((void*)_res);
9578         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
9579 }
9580
9581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9582         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
9583         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
9584         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
9585         return (long)ret_conv;
9586 }
9587
9588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9589         LDKUnsignedNodeAnnouncement o_conv;
9590         o_conv.inner = (void*)(o & (~1));
9591         o_conv.is_owned = (o & 1) || (o == 0);
9592         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
9593         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
9594         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
9595         return (long)ret_conv;
9596 }
9597
9598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9599         LDKDecodeError e_conv;
9600         e_conv.inner = (void*)(e & (~1));
9601         e_conv.is_owned = (e & 1) || (e == 0);
9602         e_conv = DecodeError_clone(&e_conv);
9603         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
9604         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
9605         return (long)ret_conv;
9606 }
9607
9608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9609         if ((_res & 1) != 0) return;
9610         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9611         FREE((void*)_res);
9612         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
9613 }
9614
9615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9616         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
9617         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
9618         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
9619         return (long)ret_conv;
9620 }
9621
9622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9623         LDKNodeAnnouncement o_conv;
9624         o_conv.inner = (void*)(o & (~1));
9625         o_conv.is_owned = (o & 1) || (o == 0);
9626         o_conv = NodeAnnouncement_clone(&o_conv);
9627         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9628         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
9629         return (long)ret_conv;
9630 }
9631
9632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9633         LDKDecodeError e_conv;
9634         e_conv.inner = (void*)(e & (~1));
9635         e_conv.is_owned = (e & 1) || (e == 0);
9636         e_conv = DecodeError_clone(&e_conv);
9637         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9638         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
9639         return (long)ret_conv;
9640 }
9641
9642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9643         if ((_res & 1) != 0) return;
9644         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9645         FREE((void*)_res);
9646         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
9647 }
9648
9649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9650         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
9651         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9652         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
9653         return (long)ret_conv;
9654 }
9655
9656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9657         LDKQueryShortChannelIds o_conv;
9658         o_conv.inner = (void*)(o & (~1));
9659         o_conv.is_owned = (o & 1) || (o == 0);
9660         o_conv = QueryShortChannelIds_clone(&o_conv);
9661         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9662         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
9663         return (long)ret_conv;
9664 }
9665
9666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9667         LDKDecodeError e_conv;
9668         e_conv.inner = (void*)(e & (~1));
9669         e_conv.is_owned = (e & 1) || (e == 0);
9670         e_conv = DecodeError_clone(&e_conv);
9671         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9672         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
9673         return (long)ret_conv;
9674 }
9675
9676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9677         if ((_res & 1) != 0) return;
9678         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
9679         FREE((void*)_res);
9680         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
9681 }
9682
9683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9684         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
9685         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9686         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
9687         return (long)ret_conv;
9688 }
9689
9690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9691         LDKReplyShortChannelIdsEnd o_conv;
9692         o_conv.inner = (void*)(o & (~1));
9693         o_conv.is_owned = (o & 1) || (o == 0);
9694         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
9695         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9696         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
9697         return (long)ret_conv;
9698 }
9699
9700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9701         LDKDecodeError e_conv;
9702         e_conv.inner = (void*)(e & (~1));
9703         e_conv.is_owned = (e & 1) || (e == 0);
9704         e_conv = DecodeError_clone(&e_conv);
9705         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9706         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
9707         return (long)ret_conv;
9708 }
9709
9710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9711         if ((_res & 1) != 0) return;
9712         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
9713         FREE((void*)_res);
9714         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
9715 }
9716
9717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9718         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
9719         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9720         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
9721         return (long)ret_conv;
9722 }
9723
9724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9725         LDKQueryChannelRange o_conv;
9726         o_conv.inner = (void*)(o & (~1));
9727         o_conv.is_owned = (o & 1) || (o == 0);
9728         o_conv = QueryChannelRange_clone(&o_conv);
9729         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9730         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
9731         return (long)ret_conv;
9732 }
9733
9734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9735         LDKDecodeError e_conv;
9736         e_conv.inner = (void*)(e & (~1));
9737         e_conv.is_owned = (e & 1) || (e == 0);
9738         e_conv = DecodeError_clone(&e_conv);
9739         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9740         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
9741         return (long)ret_conv;
9742 }
9743
9744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9745         if ((_res & 1) != 0) return;
9746         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9747         FREE((void*)_res);
9748         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
9749 }
9750
9751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9752         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
9753         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9754         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
9755         return (long)ret_conv;
9756 }
9757
9758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9759         LDKReplyChannelRange o_conv;
9760         o_conv.inner = (void*)(o & (~1));
9761         o_conv.is_owned = (o & 1) || (o == 0);
9762         o_conv = ReplyChannelRange_clone(&o_conv);
9763         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
9764         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
9765         return (long)ret_conv;
9766 }
9767
9768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9769         LDKDecodeError e_conv;
9770         e_conv.inner = (void*)(e & (~1));
9771         e_conv.is_owned = (e & 1) || (e == 0);
9772         e_conv = DecodeError_clone(&e_conv);
9773         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
9774         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
9775         return (long)ret_conv;
9776 }
9777
9778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9779         if ((_res & 1) != 0) return;
9780         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9781         FREE((void*)_res);
9782         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
9783 }
9784
9785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9786         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
9787         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
9788         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
9789         return (long)ret_conv;
9790 }
9791
9792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9793         LDKGossipTimestampFilter o_conv;
9794         o_conv.inner = (void*)(o & (~1));
9795         o_conv.is_owned = (o & 1) || (o == 0);
9796         o_conv = GossipTimestampFilter_clone(&o_conv);
9797         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
9798         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
9799         return (long)ret_conv;
9800 }
9801
9802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9803         LDKDecodeError e_conv;
9804         e_conv.inner = (void*)(e & (~1));
9805         e_conv.is_owned = (e & 1) || (e == 0);
9806         e_conv = DecodeError_clone(&e_conv);
9807         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
9808         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
9809         return (long)ret_conv;
9810 }
9811
9812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9813         if ((_res & 1) != 0) return;
9814         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
9815         FREE((void*)_res);
9816         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
9817 }
9818
9819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9820         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
9821         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
9822         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
9823         return (long)ret_conv;
9824 }
9825
9826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9827         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
9828         FREE((void*)o);
9829         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9830         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
9831         return (long)ret_conv;
9832 }
9833
9834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_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_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9840         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
9841         return (long)ret_conv;
9842 }
9843
9844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9845         if ((_res & 1) != 0) return;
9846         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
9847         FREE((void*)_res);
9848         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
9849 }
9850
9851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9852         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
9853         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9854         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
9855         return (long)ret_conv;
9856 }
9857
9858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9859         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
9860         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
9861         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
9862         return (long)ret_ref;
9863 }
9864
9865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
9866         LDKSignature a_ref;
9867         CHECK((*env)->GetArrayLength(env, a) == 64);
9868         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
9869         LDKCVec_SignatureZ b_constr;
9870         b_constr.datalen = (*env)->GetArrayLength(env, b);
9871         if (b_constr.datalen > 0)
9872                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9873         else
9874                 b_constr.data = NULL;
9875         for (size_t i = 0; i < b_constr.datalen; i++) {
9876                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
9877                 LDKSignature b_conv_8_ref;
9878                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
9879                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
9880                 b_constr.data[i] = b_conv_8_ref;
9881         }
9882         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
9883         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
9884         return (long)ret_ref;
9885 }
9886
9887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9888         if ((_res & 1) != 0) return;
9889         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
9890         FREE((void*)_res);
9891         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
9892 }
9893
9894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9895         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
9896         FREE((void*)o);
9897         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
9898         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
9899         return (long)ret_conv;
9900 }
9901
9902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
9903         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
9904         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
9905         return (long)ret_conv;
9906 }
9907
9908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9909         if ((_res & 1) != 0) return;
9910         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
9911         FREE((void*)_res);
9912         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
9913 }
9914
9915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9916         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
9917         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
9918         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
9919         return (long)ret_conv;
9920 }
9921
9922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9923         LDKSignature o_ref;
9924         CHECK((*env)->GetArrayLength(env, o) == 64);
9925         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
9926         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
9927         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
9928         return (long)ret_conv;
9929 }
9930
9931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
9932         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
9933         *ret_conv = CResult_SignatureNoneZ_err();
9934         return (long)ret_conv;
9935 }
9936
9937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9938         if ((_res & 1) != 0) return;
9939         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
9940         FREE((void*)_res);
9941         CResult_SignatureNoneZ_free(_res_conv);
9942 }
9943
9944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9945         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
9946         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
9947         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
9948         return (long)ret_conv;
9949 }
9950
9951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9952         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
9953         if (o_conv.free == LDKSign_JCalls_free) {
9954                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9955                 LDKSign_JCalls_clone(o_conv.this_arg);
9956         }
9957         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
9958         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
9959         return (long)ret_conv;
9960 }
9961
9962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9963         LDKDecodeError e_conv;
9964         e_conv.inner = (void*)(e & (~1));
9965         e_conv.is_owned = (e & 1) || (e == 0);
9966         e_conv = DecodeError_clone(&e_conv);
9967         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
9968         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
9969         return (long)ret_conv;
9970 }
9971
9972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9973         if ((_res & 1) != 0) return;
9974         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
9975         FREE((void*)_res);
9976         CResult_SignDecodeErrorZ_free(_res_conv);
9977 }
9978
9979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9980         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
9981         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
9982         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
9983         return (long)ret_conv;
9984 }
9985
9986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9987         LDKCVec_CVec_u8ZZ _res_constr;
9988         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9989         if (_res_constr.datalen > 0)
9990                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
9991         else
9992                 _res_constr.data = NULL;
9993         for (size_t i = 0; i < _res_constr.datalen; i++) {
9994                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9995                 LDKCVec_u8Z _res_conv_8_ref;
9996                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
9997                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
9998                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
9999                 _res_constr.data[i] = _res_conv_8_ref;
10000         }
10001         CVec_CVec_u8ZZ_free(_res_constr);
10002 }
10003
10004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
10005         LDKCVec_CVec_u8ZZ o_constr;
10006         o_constr.datalen = (*env)->GetArrayLength(env, o);
10007         if (o_constr.datalen > 0)
10008                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10009         else
10010                 o_constr.data = NULL;
10011         for (size_t i = 0; i < o_constr.datalen; i++) {
10012                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
10013                 LDKCVec_u8Z o_conv_8_ref;
10014                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
10015                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10016                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
10017                 o_constr.data[i] = o_conv_8_ref;
10018         }
10019         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10020         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
10021         return (long)ret_conv;
10022 }
10023
10024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
10025         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10026         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
10027         return (long)ret_conv;
10028 }
10029
10030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10031         if ((_res & 1) != 0) return;
10032         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
10033         FREE((void*)_res);
10034         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
10035 }
10036
10037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10038         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
10039         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10040         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
10041         return (long)ret_conv;
10042 }
10043
10044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10045         LDKInMemorySigner o_conv;
10046         o_conv.inner = (void*)(o & (~1));
10047         o_conv.is_owned = (o & 1) || (o == 0);
10048         o_conv = InMemorySigner_clone(&o_conv);
10049         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10050         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
10051         return (long)ret_conv;
10052 }
10053
10054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10055         LDKDecodeError e_conv;
10056         e_conv.inner = (void*)(e & (~1));
10057         e_conv.is_owned = (e & 1) || (e == 0);
10058         e_conv = DecodeError_clone(&e_conv);
10059         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10060         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
10061         return (long)ret_conv;
10062 }
10063
10064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10065         if ((_res & 1) != 0) return;
10066         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
10067         FREE((void*)_res);
10068         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
10069 }
10070
10071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10072         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
10073         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10074         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
10075         return (long)ret_conv;
10076 }
10077
10078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10079         LDKCVec_TxOutZ _res_constr;
10080         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10081         if (_res_constr.datalen > 0)
10082                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10083         else
10084                 _res_constr.data = NULL;
10085         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10086         for (size_t h = 0; h < _res_constr.datalen; h++) {
10087                 int64_t _res_conv_7 = _res_vals[h];
10088                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
10089                 FREE((void*)_res_conv_7);
10090                 _res_constr.data[h] = _res_conv_7_conv;
10091         }
10092         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10093         CVec_TxOutZ_free(_res_constr);
10094 }
10095
10096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10097         LDKTransaction o_ref;
10098         o_ref.datalen = (*env)->GetArrayLength(env, o);
10099         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
10100         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
10101         o_ref.data_is_owned = true;
10102         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10103         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
10104         return (long)ret_conv;
10105 }
10106
10107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10108         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10109         *ret_conv = CResult_TransactionNoneZ_err();
10110         return (long)ret_conv;
10111 }
10112
10113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10114         if ((_res & 1) != 0) return;
10115         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
10116         FREE((void*)_res);
10117         CResult_TransactionNoneZ_free(_res_conv);
10118 }
10119
10120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
10121         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10122         *ret_conv = CResult_NoneErrorZ_ok();
10123         return (long)ret_conv;
10124 }
10125
10126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10127         LDKIOError e_conv = LDKIOError_from_java(env, e);
10128         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10129         *ret_conv = CResult_NoneErrorZ_err(e_conv);
10130         return (long)ret_conv;
10131 }
10132
10133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10134         if ((_res & 1) != 0) return;
10135         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
10136         FREE((void*)_res);
10137         CResult_NoneErrorZ_free(_res_conv);
10138 }
10139
10140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10141         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
10142         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10143         if (_res_constr.datalen > 0)
10144                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10145         else
10146                 _res_constr.data = NULL;
10147         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10148         for (size_t i = 0; i < _res_constr.datalen; i++) {
10149                 int64_t _res_conv_34 = _res_vals[i];
10150                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_34) & ~1);
10151                 FREE((void*)_res_conv_34);
10152                 _res_constr.data[i] = _res_conv_34_conv;
10153         }
10154         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10155         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
10156 }
10157
10158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
10159         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
10160         o_constr.datalen = (*env)->GetArrayLength(env, o);
10161         if (o_constr.datalen > 0)
10162                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10163         else
10164                 o_constr.data = NULL;
10165         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
10166         for (size_t i = 0; i < o_constr.datalen; i++) {
10167                 int64_t o_conv_34 = o_vals[i];
10168                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_34) & ~1);
10169                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
10170                 o_constr.data[i] = o_conv_34_conv;
10171         }
10172         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
10173         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10174         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
10175         return (long)ret_conv;
10176 }
10177
10178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10179         LDKIOError e_conv = LDKIOError_from_java(env, e);
10180         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10181         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
10182         return (long)ret_conv;
10183 }
10184
10185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10186         if ((_res & 1) != 0) return;
10187         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
10188         FREE((void*)_res);
10189         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
10190 }
10191
10192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
10193         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10194         *ret_conv = CResult_NoneAPIErrorZ_ok();
10195         return (long)ret_conv;
10196 }
10197
10198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10199         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10200         FREE((void*)e);
10201         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10202         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
10203         return (long)ret_conv;
10204 }
10205
10206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10207         if ((_res & 1) != 0) return;
10208         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
10209         FREE((void*)_res);
10210         CResult_NoneAPIErrorZ_free(_res_conv);
10211 }
10212
10213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10214         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
10215         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10216         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
10217         return (long)ret_conv;
10218 }
10219
10220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10221         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
10222         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10223         if (_res_constr.datalen > 0)
10224                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
10225         else
10226                 _res_constr.data = NULL;
10227         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10228         for (size_t w = 0; w < _res_constr.datalen; w++) {
10229                 int64_t _res_conv_22 = _res_vals[w];
10230                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
10231                 FREE((void*)_res_conv_22);
10232                 _res_constr.data[w] = _res_conv_22_conv;
10233         }
10234         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10235         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
10236 }
10237
10238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10239         LDKCVec_APIErrorZ _res_constr;
10240         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10241         if (_res_constr.datalen > 0)
10242                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
10243         else
10244                 _res_constr.data = NULL;
10245         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10246         for (size_t k = 0; k < _res_constr.datalen; k++) {
10247                 int64_t _res_conv_10 = _res_vals[k];
10248                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
10249                 FREE((void*)_res_conv_10);
10250                 _res_constr.data[k] = _res_conv_10_conv;
10251         }
10252         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10253         CVec_APIErrorZ_free(_res_constr);
10254 }
10255
10256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
10257         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10258         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
10259         return (long)ret_conv;
10260 }
10261
10262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10263         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10264         FREE((void*)e);
10265         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10266         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
10267         return (long)ret_conv;
10268 }
10269
10270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10271         if ((_res & 1) != 0) return;
10272         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10273         FREE((void*)_res);
10274         CResult_NonePaymentSendFailureZ_free(_res_conv);
10275 }
10276
10277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10278         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
10279         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10280         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
10281         return (long)ret_conv;
10282 }
10283
10284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10285         LDKCVec_ChannelMonitorZ _res_constr;
10286         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10287         if (_res_constr.datalen > 0)
10288                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
10289         else
10290                 _res_constr.data = NULL;
10291         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10292         for (size_t q = 0; q < _res_constr.datalen; q++) {
10293                 int64_t _res_conv_16 = _res_vals[q];
10294                 LDKChannelMonitor _res_conv_16_conv;
10295                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10296                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10297                 _res_constr.data[q] = _res_conv_16_conv;
10298         }
10299         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10300         CVec_ChannelMonitorZ_free(_res_constr);
10301 }
10302
10303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10304         LDKThirtyTwoBytes a_ref;
10305         CHECK((*env)->GetArrayLength(env, a) == 32);
10306         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10307         LDKChannelManager b_conv;
10308         b_conv.inner = (void*)(b & (~1));
10309         b_conv.is_owned = (b & 1) || (b == 0);
10310         // Warning: we need a move here but no clone is available for LDKChannelManager
10311         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
10312         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
10313         return (long)ret_ref;
10314 }
10315
10316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10317         if ((_res & 1) != 0) return;
10318         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
10319         FREE((void*)_res);
10320         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
10321 }
10322
10323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10324         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
10325         FREE((void*)o);
10326         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10327         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
10328         return (long)ret_conv;
10329 }
10330
10331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10332         LDKDecodeError e_conv;
10333         e_conv.inner = (void*)(e & (~1));
10334         e_conv.is_owned = (e & 1) || (e == 0);
10335         e_conv = DecodeError_clone(&e_conv);
10336         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10337         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
10338         return (long)ret_conv;
10339 }
10340
10341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10342         if ((_res & 1) != 0) return;
10343         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10344         FREE((void*)_res);
10345         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
10346 }
10347
10348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10349         if ((this_ptr & 1) != 0) return;
10350         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
10351         FREE((void*)this_ptr);
10352         Event_free(this_ptr_conv);
10353 }
10354
10355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10356         LDKEvent* orig_conv = (LDKEvent*)orig;
10357         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
10358         *ret_copy = Event_clone(orig_conv);
10359         long ret_ref = (long)ret_copy;
10360         return ret_ref;
10361 }
10362
10363 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
10364         LDKEvent* obj_conv = (LDKEvent*)obj;
10365         LDKCVec_u8Z ret_var = Event_write(obj_conv);
10366         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10367         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10368         CVec_u8Z_free(ret_var);
10369         return ret_arr;
10370 }
10371
10372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10373         if ((this_ptr & 1) != 0) return;
10374         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
10375         FREE((void*)this_ptr);
10376         MessageSendEvent_free(this_ptr_conv);
10377 }
10378
10379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10380         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
10381         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10382         *ret_copy = MessageSendEvent_clone(orig_conv);
10383         long ret_ref = (long)ret_copy;
10384         return ret_ref;
10385 }
10386
10387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10388         if ((this_ptr & 1) != 0) return;
10389         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
10390         FREE((void*)this_ptr);
10391         MessageSendEventsProvider_free(this_ptr_conv);
10392 }
10393
10394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10395         if ((this_ptr & 1) != 0) return;
10396         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
10397         FREE((void*)this_ptr);
10398         EventsProvider_free(this_ptr_conv);
10399 }
10400
10401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10402         if ((this_ptr & 1) != 0) return;
10403         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
10404         FREE((void*)this_ptr);
10405         APIError_free(this_ptr_conv);
10406 }
10407
10408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10409         LDKAPIError* orig_conv = (LDKAPIError*)orig;
10410         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
10411         *ret_copy = APIError_clone(orig_conv);
10412         long ret_ref = (long)ret_copy;
10413         return ret_ref;
10414 }
10415
10416 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10417         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
10418         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
10419         return ret_conv;
10420 }
10421
10422 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
10423         jclass ret_conv = LDKLevel_to_java(env, Level_max());
10424         return ret_conv;
10425 }
10426
10427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10428         if ((this_ptr & 1) != 0) return;
10429         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
10430         FREE((void*)this_ptr);
10431         Logger_free(this_ptr_conv);
10432 }
10433
10434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10435         LDKChannelHandshakeConfig this_obj_conv;
10436         this_obj_conv.inner = (void*)(this_obj & (~1));
10437         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10438         ChannelHandshakeConfig_free(this_obj_conv);
10439 }
10440
10441 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
10442         LDKChannelHandshakeConfig this_ptr_conv;
10443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10444         this_ptr_conv.is_owned = false;
10445         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
10446         return ret_val;
10447 }
10448
10449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
10450         LDKChannelHandshakeConfig this_ptr_conv;
10451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10452         this_ptr_conv.is_owned = false;
10453         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
10454 }
10455
10456 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
10457         LDKChannelHandshakeConfig this_ptr_conv;
10458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10459         this_ptr_conv.is_owned = false;
10460         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
10461         return ret_val;
10462 }
10463
10464 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) {
10465         LDKChannelHandshakeConfig this_ptr_conv;
10466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10467         this_ptr_conv.is_owned = false;
10468         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
10469 }
10470
10471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
10472         LDKChannelHandshakeConfig this_ptr_conv;
10473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10474         this_ptr_conv.is_owned = false;
10475         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
10476         return ret_val;
10477 }
10478
10479 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) {
10480         LDKChannelHandshakeConfig this_ptr_conv;
10481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10482         this_ptr_conv.is_owned = false;
10483         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
10484 }
10485
10486 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) {
10487         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
10488         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10489         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10490         long ret_ref = (long)ret_var.inner;
10491         if (ret_var.is_owned) {
10492                 ret_ref |= 1;
10493         }
10494         return ret_ref;
10495 }
10496
10497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10498         LDKChannelHandshakeConfig orig_conv;
10499         orig_conv.inner = (void*)(orig & (~1));
10500         orig_conv.is_owned = false;
10501         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
10502         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10503         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10504         long ret_ref = (long)ret_var.inner;
10505         if (ret_var.is_owned) {
10506                 ret_ref |= 1;
10507         }
10508         return ret_ref;
10509 }
10510
10511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
10512         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
10513         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10514         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10515         long ret_ref = (long)ret_var.inner;
10516         if (ret_var.is_owned) {
10517                 ret_ref |= 1;
10518         }
10519         return ret_ref;
10520 }
10521
10522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10523         LDKChannelHandshakeLimits this_obj_conv;
10524         this_obj_conv.inner = (void*)(this_obj & (~1));
10525         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10526         ChannelHandshakeLimits_free(this_obj_conv);
10527 }
10528
10529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10530         LDKChannelHandshakeLimits this_ptr_conv;
10531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10532         this_ptr_conv.is_owned = false;
10533         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
10534         return ret_val;
10535 }
10536
10537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10538         LDKChannelHandshakeLimits this_ptr_conv;
10539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10540         this_ptr_conv.is_owned = false;
10541         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
10542 }
10543
10544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
10545         LDKChannelHandshakeLimits this_ptr_conv;
10546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10547         this_ptr_conv.is_owned = false;
10548         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
10549         return ret_val;
10550 }
10551
10552 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) {
10553         LDKChannelHandshakeLimits this_ptr_conv;
10554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10555         this_ptr_conv.is_owned = false;
10556         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
10557 }
10558
10559 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) {
10560         LDKChannelHandshakeLimits this_ptr_conv;
10561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10562         this_ptr_conv.is_owned = false;
10563         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
10564         return ret_val;
10565 }
10566
10567 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) {
10568         LDKChannelHandshakeLimits this_ptr_conv;
10569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10570         this_ptr_conv.is_owned = false;
10571         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
10572 }
10573
10574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10575         LDKChannelHandshakeLimits this_ptr_conv;
10576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10577         this_ptr_conv.is_owned = false;
10578         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
10579         return ret_val;
10580 }
10581
10582 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) {
10583         LDKChannelHandshakeLimits this_ptr_conv;
10584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10585         this_ptr_conv.is_owned = false;
10586         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
10587 }
10588
10589 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
10590         LDKChannelHandshakeLimits this_ptr_conv;
10591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10592         this_ptr_conv.is_owned = false;
10593         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
10594         return ret_val;
10595 }
10596
10597 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) {
10598         LDKChannelHandshakeLimits this_ptr_conv;
10599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10600         this_ptr_conv.is_owned = false;
10601         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
10602 }
10603
10604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10605         LDKChannelHandshakeLimits this_ptr_conv;
10606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10607         this_ptr_conv.is_owned = false;
10608         int64_t ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
10609         return ret_val;
10610 }
10611
10612 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) {
10613         LDKChannelHandshakeLimits this_ptr_conv;
10614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10615         this_ptr_conv.is_owned = false;
10616         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
10617 }
10618
10619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10620         LDKChannelHandshakeLimits this_ptr_conv;
10621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10622         this_ptr_conv.is_owned = false;
10623         int64_t ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
10624         return ret_val;
10625 }
10626
10627 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) {
10628         LDKChannelHandshakeLimits this_ptr_conv;
10629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10630         this_ptr_conv.is_owned = false;
10631         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
10632 }
10633
10634 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
10635         LDKChannelHandshakeLimits this_ptr_conv;
10636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10637         this_ptr_conv.is_owned = false;
10638         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
10639         return ret_val;
10640 }
10641
10642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
10643         LDKChannelHandshakeLimits this_ptr_conv;
10644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10645         this_ptr_conv.is_owned = false;
10646         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
10647 }
10648
10649 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
10650         LDKChannelHandshakeLimits this_ptr_conv;
10651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10652         this_ptr_conv.is_owned = false;
10653         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
10654         return ret_val;
10655 }
10656
10657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
10658         LDKChannelHandshakeLimits this_ptr_conv;
10659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10660         this_ptr_conv.is_owned = false;
10661         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
10662 }
10663
10664 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
10665         LDKChannelHandshakeLimits this_ptr_conv;
10666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10667         this_ptr_conv.is_owned = false;
10668         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
10669         return ret_val;
10670 }
10671
10672 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) {
10673         LDKChannelHandshakeLimits this_ptr_conv;
10674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10675         this_ptr_conv.is_owned = false;
10676         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
10677 }
10678
10679 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) {
10680         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);
10681         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10682         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10683         long ret_ref = (long)ret_var.inner;
10684         if (ret_var.is_owned) {
10685                 ret_ref |= 1;
10686         }
10687         return ret_ref;
10688 }
10689
10690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10691         LDKChannelHandshakeLimits orig_conv;
10692         orig_conv.inner = (void*)(orig & (~1));
10693         orig_conv.is_owned = false;
10694         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
10695         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10696         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10697         long ret_ref = (long)ret_var.inner;
10698         if (ret_var.is_owned) {
10699                 ret_ref |= 1;
10700         }
10701         return ret_ref;
10702 }
10703
10704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
10705         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
10706         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10707         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10708         long ret_ref = (long)ret_var.inner;
10709         if (ret_var.is_owned) {
10710                 ret_ref |= 1;
10711         }
10712         return ret_ref;
10713 }
10714
10715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10716         LDKChannelConfig this_obj_conv;
10717         this_obj_conv.inner = (void*)(this_obj & (~1));
10718         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10719         ChannelConfig_free(this_obj_conv);
10720 }
10721
10722 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
10723         LDKChannelConfig this_ptr_conv;
10724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10725         this_ptr_conv.is_owned = false;
10726         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
10727         return ret_val;
10728 }
10729
10730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
10731         LDKChannelConfig this_ptr_conv;
10732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10733         this_ptr_conv.is_owned = false;
10734         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
10735 }
10736
10737 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
10738         LDKChannelConfig this_ptr_conv;
10739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10740         this_ptr_conv.is_owned = false;
10741         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
10742         return ret_val;
10743 }
10744
10745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
10746         LDKChannelConfig this_ptr_conv;
10747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10748         this_ptr_conv.is_owned = false;
10749         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
10750 }
10751
10752 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
10753         LDKChannelConfig this_ptr_conv;
10754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10755         this_ptr_conv.is_owned = false;
10756         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
10757         return ret_val;
10758 }
10759
10760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
10761         LDKChannelConfig this_ptr_conv;
10762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10763         this_ptr_conv.is_owned = false;
10764         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
10765 }
10766
10767 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
10768         LDKChannelConfig this_ptr_conv;
10769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10770         this_ptr_conv.is_owned = false;
10771         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
10772         return ret_val;
10773 }
10774
10775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
10776         LDKChannelConfig this_ptr_conv;
10777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10778         this_ptr_conv.is_owned = false;
10779         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
10780 }
10781
10782 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) {
10783         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
10784         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10785         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10786         long ret_ref = (long)ret_var.inner;
10787         if (ret_var.is_owned) {
10788                 ret_ref |= 1;
10789         }
10790         return ret_ref;
10791 }
10792
10793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10794         LDKChannelConfig orig_conv;
10795         orig_conv.inner = (void*)(orig & (~1));
10796         orig_conv.is_owned = false;
10797         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
10798         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10799         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10800         long ret_ref = (long)ret_var.inner;
10801         if (ret_var.is_owned) {
10802                 ret_ref |= 1;
10803         }
10804         return ret_ref;
10805 }
10806
10807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
10808         LDKChannelConfig ret_var = ChannelConfig_default();
10809         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10810         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10811         long ret_ref = (long)ret_var.inner;
10812         if (ret_var.is_owned) {
10813                 ret_ref |= 1;
10814         }
10815         return ret_ref;
10816 }
10817
10818 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
10819         LDKChannelConfig obj_conv;
10820         obj_conv.inner = (void*)(obj & (~1));
10821         obj_conv.is_owned = false;
10822         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
10823         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10824         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10825         CVec_u8Z_free(ret_var);
10826         return ret_arr;
10827 }
10828
10829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10830         LDKu8slice ser_ref;
10831         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10832         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10833         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10834         *ret_conv = ChannelConfig_read(ser_ref);
10835         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10836         return (long)ret_conv;
10837 }
10838
10839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10840         LDKUserConfig this_obj_conv;
10841         this_obj_conv.inner = (void*)(this_obj & (~1));
10842         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10843         UserConfig_free(this_obj_conv);
10844 }
10845
10846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
10847         LDKUserConfig this_ptr_conv;
10848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10849         this_ptr_conv.is_owned = false;
10850         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
10851         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10852         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10853         long ret_ref = (long)ret_var.inner;
10854         if (ret_var.is_owned) {
10855                 ret_ref |= 1;
10856         }
10857         return ret_ref;
10858 }
10859
10860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10861         LDKUserConfig this_ptr_conv;
10862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10863         this_ptr_conv.is_owned = false;
10864         LDKChannelHandshakeConfig val_conv;
10865         val_conv.inner = (void*)(val & (~1));
10866         val_conv.is_owned = (val & 1) || (val == 0);
10867         val_conv = ChannelHandshakeConfig_clone(&val_conv);
10868         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
10869 }
10870
10871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
10872         LDKUserConfig this_ptr_conv;
10873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10874         this_ptr_conv.is_owned = false;
10875         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
10876         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10877         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10878         long ret_ref = (long)ret_var.inner;
10879         if (ret_var.is_owned) {
10880                 ret_ref |= 1;
10881         }
10882         return ret_ref;
10883 }
10884
10885 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) {
10886         LDKUserConfig this_ptr_conv;
10887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10888         this_ptr_conv.is_owned = false;
10889         LDKChannelHandshakeLimits val_conv;
10890         val_conv.inner = (void*)(val & (~1));
10891         val_conv.is_owned = (val & 1) || (val == 0);
10892         val_conv = ChannelHandshakeLimits_clone(&val_conv);
10893         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
10894 }
10895
10896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
10897         LDKUserConfig this_ptr_conv;
10898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10899         this_ptr_conv.is_owned = false;
10900         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
10901         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10902         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10903         long ret_ref = (long)ret_var.inner;
10904         if (ret_var.is_owned) {
10905                 ret_ref |= 1;
10906         }
10907         return ret_ref;
10908 }
10909
10910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10911         LDKUserConfig this_ptr_conv;
10912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10913         this_ptr_conv.is_owned = false;
10914         LDKChannelConfig val_conv;
10915         val_conv.inner = (void*)(val & (~1));
10916         val_conv.is_owned = (val & 1) || (val == 0);
10917         val_conv = ChannelConfig_clone(&val_conv);
10918         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
10919 }
10920
10921 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) {
10922         LDKChannelHandshakeConfig own_channel_config_arg_conv;
10923         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
10924         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
10925         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
10926         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
10927         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
10928         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
10929         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
10930         LDKChannelConfig channel_options_arg_conv;
10931         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
10932         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
10933         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
10934         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
10935         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10936         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10937         long ret_ref = (long)ret_var.inner;
10938         if (ret_var.is_owned) {
10939                 ret_ref |= 1;
10940         }
10941         return ret_ref;
10942 }
10943
10944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10945         LDKUserConfig orig_conv;
10946         orig_conv.inner = (void*)(orig & (~1));
10947         orig_conv.is_owned = false;
10948         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
10949         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10950         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10951         long ret_ref = (long)ret_var.inner;
10952         if (ret_var.is_owned) {
10953                 ret_ref |= 1;
10954         }
10955         return ret_ref;
10956 }
10957
10958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
10959         LDKUserConfig ret_var = UserConfig_default();
10960         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10961         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10962         long ret_ref = (long)ret_var.inner;
10963         if (ret_var.is_owned) {
10964                 ret_ref |= 1;
10965         }
10966         return ret_ref;
10967 }
10968
10969 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10970         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
10971         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
10972         return ret_conv;
10973 }
10974
10975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10976         if ((this_ptr & 1) != 0) return;
10977         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
10978         FREE((void*)this_ptr);
10979         Access_free(this_ptr_conv);
10980 }
10981
10982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10983         if ((this_ptr & 1) != 0) return;
10984         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
10985         FREE((void*)this_ptr);
10986         Listen_free(this_ptr_conv);
10987 }
10988
10989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10990         if ((this_ptr & 1) != 0) return;
10991         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
10992         FREE((void*)this_ptr);
10993         Watch_free(this_ptr_conv);
10994 }
10995
10996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10997         if ((this_ptr & 1) != 0) return;
10998         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
10999         FREE((void*)this_ptr);
11000         Filter_free(this_ptr_conv);
11001 }
11002
11003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11004         LDKWatchedOutput this_obj_conv;
11005         this_obj_conv.inner = (void*)(this_obj & (~1));
11006         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11007         WatchedOutput_free(this_obj_conv);
11008 }
11009
11010 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
11011         LDKWatchedOutput this_ptr_conv;
11012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11013         this_ptr_conv.is_owned = false;
11014         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11015         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
11016         return ret_arr;
11017 }
11018
11019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11020         LDKWatchedOutput this_ptr_conv;
11021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11022         this_ptr_conv.is_owned = false;
11023         LDKThirtyTwoBytes val_ref;
11024         CHECK((*env)->GetArrayLength(env, val) == 32);
11025         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11026         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
11027 }
11028
11029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
11030         LDKWatchedOutput this_ptr_conv;
11031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11032         this_ptr_conv.is_owned = false;
11033         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
11034         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11035         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11036         long ret_ref = (long)ret_var.inner;
11037         if (ret_var.is_owned) {
11038                 ret_ref |= 1;
11039         }
11040         return ret_ref;
11041 }
11042
11043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11044         LDKWatchedOutput this_ptr_conv;
11045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11046         this_ptr_conv.is_owned = false;
11047         LDKOutPoint val_conv;
11048         val_conv.inner = (void*)(val & (~1));
11049         val_conv.is_owned = (val & 1) || (val == 0);
11050         val_conv = OutPoint_clone(&val_conv);
11051         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
11052 }
11053
11054 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
11055         LDKWatchedOutput this_ptr_conv;
11056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11057         this_ptr_conv.is_owned = false;
11058         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_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         return ret_arr;
11062 }
11063
11064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11065         LDKWatchedOutput this_ptr_conv;
11066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11067         this_ptr_conv.is_owned = false;
11068         LDKCVec_u8Z val_ref;
11069         val_ref.datalen = (*env)->GetArrayLength(env, val);
11070         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
11071         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
11072         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
11073 }
11074
11075 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) {
11076         LDKThirtyTwoBytes block_hash_arg_ref;
11077         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
11078         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
11079         LDKOutPoint outpoint_arg_conv;
11080         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
11081         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
11082         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
11083         LDKCVec_u8Z script_pubkey_arg_ref;
11084         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
11085         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
11086         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
11087         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
11088         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11089         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11090         long ret_ref = (long)ret_var.inner;
11091         if (ret_var.is_owned) {
11092                 ret_ref |= 1;
11093         }
11094         return ret_ref;
11095 }
11096
11097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11098         if ((this_ptr & 1) != 0) return;
11099         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
11100         FREE((void*)this_ptr);
11101         BroadcasterInterface_free(this_ptr_conv);
11102 }
11103
11104 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11105         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
11106         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
11107         return ret_conv;
11108 }
11109
11110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11111         if ((this_ptr & 1) != 0) return;
11112         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
11113         FREE((void*)this_ptr);
11114         FeeEstimator_free(this_ptr_conv);
11115 }
11116
11117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11118         LDKChainMonitor this_obj_conv;
11119         this_obj_conv.inner = (void*)(this_obj & (~1));
11120         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11121         ChainMonitor_free(this_obj_conv);
11122 }
11123
11124 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) {
11125         LDKChainMonitor this_arg_conv;
11126         this_arg_conv.inner = (void*)(this_arg & (~1));
11127         this_arg_conv.is_owned = false;
11128         unsigned char header_arr[80];
11129         CHECK((*env)->GetArrayLength(env, header) == 80);
11130         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11131         unsigned char (*header_ref)[80] = &header_arr;
11132         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11133         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11134         if (txdata_constr.datalen > 0)
11135                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11136         else
11137                 txdata_constr.data = NULL;
11138         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11139         for (size_t y = 0; y < txdata_constr.datalen; y++) {
11140                 int64_t txdata_conv_24 = txdata_vals[y];
11141                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
11142                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
11143                 txdata_constr.data[y] = txdata_conv_24_conv;
11144         }
11145         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11146         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
11147 }
11148
11149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1transactions_1confirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
11150         LDKChainMonitor this_arg_conv;
11151         this_arg_conv.inner = (void*)(this_arg & (~1));
11152         this_arg_conv.is_owned = false;
11153         unsigned char header_arr[80];
11154         CHECK((*env)->GetArrayLength(env, header) == 80);
11155         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11156         unsigned char (*header_ref)[80] = &header_arr;
11157         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11158         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11159         if (txdata_constr.datalen > 0)
11160                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11161         else
11162                 txdata_constr.data = NULL;
11163         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11164         for (size_t y = 0; y < txdata_constr.datalen; y++) {
11165                 int64_t txdata_conv_24 = txdata_vals[y];
11166                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
11167                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
11168                 txdata_constr.data[y] = txdata_conv_24_conv;
11169         }
11170         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11171         ChainMonitor_transactions_confirmed(&this_arg_conv, header_ref, txdata_constr, height);
11172 }
11173
11174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1update_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height) {
11175         LDKChainMonitor this_arg_conv;
11176         this_arg_conv.inner = (void*)(this_arg & (~1));
11177         this_arg_conv.is_owned = false;
11178         unsigned char header_arr[80];
11179         CHECK((*env)->GetArrayLength(env, header) == 80);
11180         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11181         unsigned char (*header_ref)[80] = &header_arr;
11182         ChainMonitor_update_best_block(&this_arg_conv, header_ref, height);
11183 }
11184
11185 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) {
11186         LDKChainMonitor this_arg_conv;
11187         this_arg_conv.inner = (void*)(this_arg & (~1));
11188         this_arg_conv.is_owned = false;
11189         unsigned char header_arr[80];
11190         CHECK((*env)->GetArrayLength(env, header) == 80);
11191         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11192         unsigned char (*header_ref)[80] = &header_arr;
11193         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
11194 }
11195
11196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
11197         LDKChainMonitor this_arg_conv;
11198         this_arg_conv.inner = (void*)(this_arg & (~1));
11199         this_arg_conv.is_owned = false;
11200         unsigned char txid_arr[32];
11201         CHECK((*env)->GetArrayLength(env, txid) == 32);
11202         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11203         unsigned char (*txid_ref)[32] = &txid_arr;
11204         ChainMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref);
11205 }
11206
11207 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
11208         LDKChainMonitor this_arg_conv;
11209         this_arg_conv.inner = (void*)(this_arg & (~1));
11210         this_arg_conv.is_owned = false;
11211         LDKCVec_TxidZ ret_var = ChainMonitor_get_relevant_txids(&this_arg_conv);
11212         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11213         ;
11214         for (size_t i = 0; i < ret_var.datalen; i++) {
11215                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
11216                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
11217                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11218         }
11219         FREE(ret_var.data);
11220         return ret_arr;
11221 }
11222
11223 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) {
11224         LDKFilter *chain_source_conv_ptr = NULL;
11225         if (chain_source != 0) {
11226                 LDKFilter chain_source_conv;
11227                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
11228                 if (chain_source_conv.free == LDKFilter_JCalls_free) {
11229                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11230                         LDKFilter_JCalls_clone(chain_source_conv.this_arg);
11231                 }
11232                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
11233                 *chain_source_conv_ptr = chain_source_conv;
11234         }
11235         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11236         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11237                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11238                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
11239         }
11240         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11241         if (logger_conv.free == LDKLogger_JCalls_free) {
11242                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11243                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11244         }
11245         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
11246         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
11247                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11248                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
11249         }
11250         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
11251         if (persister_conv.free == LDKPersist_JCalls_free) {
11252                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11253                 LDKPersist_JCalls_clone(persister_conv.this_arg);
11254         }
11255         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
11256         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11257         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11258         long ret_ref = (long)ret_var.inner;
11259         if (ret_var.is_owned) {
11260                 ret_ref |= 1;
11261         }
11262         return ret_ref;
11263 }
11264
11265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
11266         LDKChainMonitor this_arg_conv;
11267         this_arg_conv.inner = (void*)(this_arg & (~1));
11268         this_arg_conv.is_owned = false;
11269         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
11270         *ret = ChainMonitor_as_Watch(&this_arg_conv);
11271         return (long)ret;
11272 }
11273
11274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
11275         LDKChainMonitor this_arg_conv;
11276         this_arg_conv.inner = (void*)(this_arg & (~1));
11277         this_arg_conv.is_owned = false;
11278         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
11279         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
11280         return (long)ret;
11281 }
11282
11283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11284         LDKChannelMonitorUpdate this_obj_conv;
11285         this_obj_conv.inner = (void*)(this_obj & (~1));
11286         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11287         ChannelMonitorUpdate_free(this_obj_conv);
11288 }
11289
11290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11291         LDKChannelMonitorUpdate this_ptr_conv;
11292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11293         this_ptr_conv.is_owned = false;
11294         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
11295         return ret_val;
11296 }
11297
11298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11299         LDKChannelMonitorUpdate this_ptr_conv;
11300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11301         this_ptr_conv.is_owned = false;
11302         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
11303 }
11304
11305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11306         LDKChannelMonitorUpdate orig_conv;
11307         orig_conv.inner = (void*)(orig & (~1));
11308         orig_conv.is_owned = false;
11309         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
11310         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11311         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11312         long ret_ref = (long)ret_var.inner;
11313         if (ret_var.is_owned) {
11314                 ret_ref |= 1;
11315         }
11316         return ret_ref;
11317 }
11318
11319 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
11320         LDKChannelMonitorUpdate obj_conv;
11321         obj_conv.inner = (void*)(obj & (~1));
11322         obj_conv.is_owned = false;
11323         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
11324         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11325         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11326         CVec_u8Z_free(ret_var);
11327         return ret_arr;
11328 }
11329
11330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
11331         LDKu8slice ser_ref;
11332         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11333         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11334         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11335         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
11336         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11337         return (long)ret_conv;
11338 }
11339
11340 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11341         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
11342         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
11343         return ret_conv;
11344 }
11345
11346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11347         LDKMonitorUpdateError this_obj_conv;
11348         this_obj_conv.inner = (void*)(this_obj & (~1));
11349         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11350         MonitorUpdateError_free(this_obj_conv);
11351 }
11352
11353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11354         LDKMonitorUpdateError orig_conv;
11355         orig_conv.inner = (void*)(orig & (~1));
11356         orig_conv.is_owned = false;
11357         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
11358         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11359         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11360         long ret_ref = (long)ret_var.inner;
11361         if (ret_var.is_owned) {
11362                 ret_ref |= 1;
11363         }
11364         return ret_ref;
11365 }
11366
11367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11368         if ((this_ptr & 1) != 0) return;
11369         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
11370         FREE((void*)this_ptr);
11371         MonitorEvent_free(this_ptr_conv);
11372 }
11373
11374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11375         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
11376         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
11377         *ret_copy = MonitorEvent_clone(orig_conv);
11378         long ret_ref = (long)ret_copy;
11379         return ret_ref;
11380 }
11381
11382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11383         LDKHTLCUpdate this_obj_conv;
11384         this_obj_conv.inner = (void*)(this_obj & (~1));
11385         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11386         HTLCUpdate_free(this_obj_conv);
11387 }
11388
11389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11390         LDKHTLCUpdate orig_conv;
11391         orig_conv.inner = (void*)(orig & (~1));
11392         orig_conv.is_owned = false;
11393         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
11394         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11395         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11396         long ret_ref = (long)ret_var.inner;
11397         if (ret_var.is_owned) {
11398                 ret_ref |= 1;
11399         }
11400         return ret_ref;
11401 }
11402
11403 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
11404         LDKHTLCUpdate obj_conv;
11405         obj_conv.inner = (void*)(obj & (~1));
11406         obj_conv.is_owned = false;
11407         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
11408         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11409         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11410         CVec_u8Z_free(ret_var);
11411         return ret_arr;
11412 }
11413
11414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
11415         LDKu8slice ser_ref;
11416         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11417         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11418         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11419         *ret_conv = HTLCUpdate_read(ser_ref);
11420         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11421         return (long)ret_conv;
11422 }
11423
11424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11425         LDKChannelMonitor this_obj_conv;
11426         this_obj_conv.inner = (void*)(this_obj & (~1));
11427         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11428         ChannelMonitor_free(this_obj_conv);
11429 }
11430
11431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11432         LDKChannelMonitor orig_conv;
11433         orig_conv.inner = (void*)(orig & (~1));
11434         orig_conv.is_owned = false;
11435         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
11436         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11437         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11438         long ret_ref = (long)ret_var.inner;
11439         if (ret_var.is_owned) {
11440                 ret_ref |= 1;
11441         }
11442         return ret_ref;
11443 }
11444
11445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
11446         LDKChannelMonitor obj_conv;
11447         obj_conv.inner = (void*)(obj & (~1));
11448         obj_conv.is_owned = false;
11449         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
11450         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11451         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11452         CVec_u8Z_free(ret_var);
11453         return ret_arr;
11454 }
11455
11456 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) {
11457         LDKChannelMonitor this_arg_conv;
11458         this_arg_conv.inner = (void*)(this_arg & (~1));
11459         this_arg_conv.is_owned = false;
11460         LDKChannelMonitorUpdate updates_conv;
11461         updates_conv.inner = (void*)(updates & (~1));
11462         updates_conv.is_owned = false;
11463         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11464         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11465         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
11466         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11467         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
11468         return (long)ret_conv;
11469 }
11470
11471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
11472         LDKChannelMonitor this_arg_conv;
11473         this_arg_conv.inner = (void*)(this_arg & (~1));
11474         this_arg_conv.is_owned = false;
11475         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
11476         return ret_val;
11477 }
11478
11479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
11480         LDKChannelMonitor this_arg_conv;
11481         this_arg_conv.inner = (void*)(this_arg & (~1));
11482         this_arg_conv.is_owned = false;
11483         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11484         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
11485         return (long)ret_ref;
11486 }
11487
11488 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
11489         LDKChannelMonitor this_arg_conv;
11490         this_arg_conv.inner = (void*)(this_arg & (~1));
11491         this_arg_conv.is_owned = false;
11492         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
11493         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11494         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11495         for (size_t v = 0; v < ret_var.datalen; v++) {
11496                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_47_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11497                 *ret_conv_47_ref = ret_var.data[v];
11498                 ret_arr_ptr[v] = (long)ret_conv_47_ref;
11499         }
11500         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11501         FREE(ret_var.data);
11502         return ret_arr;
11503 }
11504
11505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
11506         LDKChannelMonitor this_arg_conv;
11507         this_arg_conv.inner = (void*)(this_arg & (~1));
11508         this_arg_conv.is_owned = false;
11509         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
11510         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
11511 }
11512
11513 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
11514         LDKChannelMonitor this_arg_conv;
11515         this_arg_conv.inner = (void*)(this_arg & (~1));
11516         this_arg_conv.is_owned = false;
11517         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
11518         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11519         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11520         for (size_t o = 0; o < ret_var.datalen; o++) {
11521                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
11522                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
11523                 long ret_conv_14_ref = (long)ret_conv_14_copy;
11524                 ret_arr_ptr[o] = ret_conv_14_ref;
11525         }
11526         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11527         FREE(ret_var.data);
11528         return ret_arr;
11529 }
11530
11531 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
11532         LDKChannelMonitor this_arg_conv;
11533         this_arg_conv.inner = (void*)(this_arg & (~1));
11534         this_arg_conv.is_owned = false;
11535         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
11536         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11537         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11538         for (size_t h = 0; h < ret_var.datalen; h++) {
11539                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11540                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
11541                 long ret_conv_7_ref = (long)ret_conv_7_copy;
11542                 ret_arr_ptr[h] = ret_conv_7_ref;
11543         }
11544         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11545         FREE(ret_var.data);
11546         return ret_arr;
11547 }
11548
11549 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) {
11550         LDKChannelMonitor this_arg_conv;
11551         this_arg_conv.inner = (void*)(this_arg & (~1));
11552         this_arg_conv.is_owned = false;
11553         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
11554         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
11555         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11556         ;
11557         for (size_t i = 0; i < ret_var.datalen; i++) {
11558                 LDKTransaction ret_conv_8_var = ret_var.data[i];
11559                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
11560                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
11561                 Transaction_free(ret_conv_8_var);
11562                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11563         }
11564         FREE(ret_var.data);
11565         return ret_arr;
11566 }
11567
11568 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) {
11569         LDKChannelMonitor this_arg_conv;
11570         this_arg_conv.inner = (void*)(this_arg & (~1));
11571         this_arg_conv.is_owned = false;
11572         unsigned char header_arr[80];
11573         CHECK((*env)->GetArrayLength(env, header) == 80);
11574         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11575         unsigned char (*header_ref)[80] = &header_arr;
11576         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11577         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11578         if (txdata_constr.datalen > 0)
11579                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11580         else
11581                 txdata_constr.data = NULL;
11582         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11583         for (size_t y = 0; y < txdata_constr.datalen; y++) {
11584                 int64_t txdata_conv_24 = txdata_vals[y];
11585                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
11586                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
11587                 txdata_constr.data[y] = txdata_conv_24_conv;
11588         }
11589         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11590         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11591         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11592                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11593                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
11594         }
11595         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11596         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
11597                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11598                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
11599         }
11600         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11601         if (logger_conv.free == LDKLogger_JCalls_free) {
11602                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11603                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11604         }
11605         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);
11606         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11607         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11608         for (size_t u = 0; u < ret_var.datalen; u++) {
11609                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11610                 *ret_conv_46_ref = ret_var.data[u];
11611                 ret_arr_ptr[u] = (long)ret_conv_46_ref;
11612         }
11613         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11614         FREE(ret_var.data);
11615         return ret_arr;
11616 }
11617
11618 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) {
11619         LDKChannelMonitor this_arg_conv;
11620         this_arg_conv.inner = (void*)(this_arg & (~1));
11621         this_arg_conv.is_owned = false;
11622         unsigned char header_arr[80];
11623         CHECK((*env)->GetArrayLength(env, header) == 80);
11624         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11625         unsigned char (*header_ref)[80] = &header_arr;
11626         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11627         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11628                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11629                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
11630         }
11631         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11632         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
11633                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11634                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
11635         }
11636         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11637         if (logger_conv.free == LDKLogger_JCalls_free) {
11638                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11639                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11640         }
11641         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
11642 }
11643
11644 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1transactions_1confirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
11645         LDKChannelMonitor this_arg_conv;
11646         this_arg_conv.inner = (void*)(this_arg & (~1));
11647         this_arg_conv.is_owned = false;
11648         unsigned char header_arr[80];
11649         CHECK((*env)->GetArrayLength(env, header) == 80);
11650         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11651         unsigned char (*header_ref)[80] = &header_arr;
11652         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11653         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11654         if (txdata_constr.datalen > 0)
11655                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11656         else
11657                 txdata_constr.data = NULL;
11658         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11659         for (size_t y = 0; y < txdata_constr.datalen; y++) {
11660                 int64_t txdata_conv_24 = txdata_vals[y];
11661                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
11662                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
11663                 txdata_constr.data[y] = txdata_conv_24_conv;
11664         }
11665         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11666         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11667         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11668                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11669                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
11670         }
11671         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11672         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
11673                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11674                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
11675         }
11676         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11677         if (logger_conv.free == LDKLogger_JCalls_free) {
11678                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11679                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11680         }
11681         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_transactions_confirmed(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
11682         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11683         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11684         for (size_t u = 0; u < ret_var.datalen; u++) {
11685                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11686                 *ret_conv_46_ref = ret_var.data[u];
11687                 ret_arr_ptr[u] = (long)ret_conv_46_ref;
11688         }
11689         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11690         FREE(ret_var.data);
11691         return ret_arr;
11692 }
11693
11694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
11695         LDKChannelMonitor this_arg_conv;
11696         this_arg_conv.inner = (void*)(this_arg & (~1));
11697         this_arg_conv.is_owned = false;
11698         unsigned char txid_arr[32];
11699         CHECK((*env)->GetArrayLength(env, txid) == 32);
11700         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11701         unsigned char (*txid_ref)[32] = &txid_arr;
11702         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11703         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11704                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11705                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
11706         }
11707         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11708         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
11709                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11710                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
11711         }
11712         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11713         if (logger_conv.free == LDKLogger_JCalls_free) {
11714                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11715                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11716         }
11717         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
11718 }
11719
11720 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1update_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
11721         LDKChannelMonitor this_arg_conv;
11722         this_arg_conv.inner = (void*)(this_arg & (~1));
11723         this_arg_conv.is_owned = false;
11724         unsigned char header_arr[80];
11725         CHECK((*env)->GetArrayLength(env, header) == 80);
11726         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11727         unsigned char (*header_ref)[80] = &header_arr;
11728         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11729         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11730                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11731                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
11732         }
11733         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11734         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
11735                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11736                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
11737         }
11738         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11739         if (logger_conv.free == LDKLogger_JCalls_free) {
11740                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11741                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11742         }
11743         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_update_best_block(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
11744         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11745         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11746         for (size_t u = 0; u < ret_var.datalen; u++) {
11747                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11748                 *ret_conv_46_ref = ret_var.data[u];
11749                 ret_arr_ptr[u] = (long)ret_conv_46_ref;
11750         }
11751         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11752         FREE(ret_var.data);
11753         return ret_arr;
11754 }
11755
11756 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
11757         LDKChannelMonitor this_arg_conv;
11758         this_arg_conv.inner = (void*)(this_arg & (~1));
11759         this_arg_conv.is_owned = false;
11760         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
11761         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11762         ;
11763         for (size_t i = 0; i < ret_var.datalen; i++) {
11764                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
11765                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
11766                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11767         }
11768         FREE(ret_var.data);
11769         return ret_arr;
11770 }
11771
11772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11773         if ((this_ptr & 1) != 0) return;
11774         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
11775         FREE((void*)this_ptr);
11776         Persist_free(this_ptr_conv);
11777 }
11778
11779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
11780         LDKu8slice ser_ref;
11781         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11782         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11783         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
11784         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11785         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
11786         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11787         return (long)ret_conv;
11788 }
11789
11790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11791         LDKOutPoint this_obj_conv;
11792         this_obj_conv.inner = (void*)(this_obj & (~1));
11793         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11794         OutPoint_free(this_obj_conv);
11795 }
11796
11797 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
11798         LDKOutPoint this_ptr_conv;
11799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11800         this_ptr_conv.is_owned = false;
11801         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11802         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
11803         return ret_arr;
11804 }
11805
11806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11807         LDKOutPoint this_ptr_conv;
11808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11809         this_ptr_conv.is_owned = false;
11810         LDKThirtyTwoBytes val_ref;
11811         CHECK((*env)->GetArrayLength(env, val) == 32);
11812         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11813         OutPoint_set_txid(&this_ptr_conv, val_ref);
11814 }
11815
11816 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
11817         LDKOutPoint this_ptr_conv;
11818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11819         this_ptr_conv.is_owned = false;
11820         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
11821         return ret_val;
11822 }
11823
11824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
11825         LDKOutPoint this_ptr_conv;
11826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11827         this_ptr_conv.is_owned = false;
11828         OutPoint_set_index(&this_ptr_conv, val);
11829 }
11830
11831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
11832         LDKThirtyTwoBytes txid_arg_ref;
11833         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
11834         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
11835         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
11836         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11837         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11838         long ret_ref = (long)ret_var.inner;
11839         if (ret_var.is_owned) {
11840                 ret_ref |= 1;
11841         }
11842         return ret_ref;
11843 }
11844
11845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11846         LDKOutPoint orig_conv;
11847         orig_conv.inner = (void*)(orig & (~1));
11848         orig_conv.is_owned = false;
11849         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
11850         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11851         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11852         long ret_ref = (long)ret_var.inner;
11853         if (ret_var.is_owned) {
11854                 ret_ref |= 1;
11855         }
11856         return ret_ref;
11857 }
11858
11859 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
11860         LDKOutPoint this_arg_conv;
11861         this_arg_conv.inner = (void*)(this_arg & (~1));
11862         this_arg_conv.is_owned = false;
11863         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11864         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
11865         return ret_arr;
11866 }
11867
11868 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
11869         LDKOutPoint obj_conv;
11870         obj_conv.inner = (void*)(obj & (~1));
11871         obj_conv.is_owned = false;
11872         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
11873         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11874         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11875         CVec_u8Z_free(ret_var);
11876         return ret_arr;
11877 }
11878
11879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
11880         LDKu8slice ser_ref;
11881         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11882         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11883         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
11884         *ret_conv = OutPoint_read(ser_ref);
11885         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11886         return (long)ret_conv;
11887 }
11888
11889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11890         LDKDelayedPaymentOutputDescriptor this_obj_conv;
11891         this_obj_conv.inner = (void*)(this_obj & (~1));
11892         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11893         DelayedPaymentOutputDescriptor_free(this_obj_conv);
11894 }
11895
11896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
11897         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11899         this_ptr_conv.is_owned = false;
11900         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
11901         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11902         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11903         long ret_ref = (long)ret_var.inner;
11904         if (ret_var.is_owned) {
11905                 ret_ref |= 1;
11906         }
11907         return ret_ref;
11908 }
11909
11910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11911         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11913         this_ptr_conv.is_owned = false;
11914         LDKOutPoint val_conv;
11915         val_conv.inner = (void*)(val & (~1));
11916         val_conv.is_owned = (val & 1) || (val == 0);
11917         val_conv = OutPoint_clone(&val_conv);
11918         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
11919 }
11920
11921 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
11922         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11924         this_ptr_conv.is_owned = false;
11925         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
11926         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
11927         return ret_arr;
11928 }
11929
11930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11931         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11933         this_ptr_conv.is_owned = false;
11934         LDKPublicKey val_ref;
11935         CHECK((*env)->GetArrayLength(env, val) == 33);
11936         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11937         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
11938 }
11939
11940 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
11941         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11943         this_ptr_conv.is_owned = false;
11944         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
11945         return ret_val;
11946 }
11947
11948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
11949         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11951         this_ptr_conv.is_owned = false;
11952         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
11953 }
11954
11955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11956         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11958         this_ptr_conv.is_owned = false;
11959         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
11960         FREE((void*)val);
11961         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
11962 }
11963
11964 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
11965         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11967         this_ptr_conv.is_owned = false;
11968         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
11969         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
11970         return ret_arr;
11971 }
11972
11973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11974         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11976         this_ptr_conv.is_owned = false;
11977         LDKPublicKey val_ref;
11978         CHECK((*env)->GetArrayLength(env, val) == 33);
11979         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11980         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
11981 }
11982
11983 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11984         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11986         this_ptr_conv.is_owned = false;
11987         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11988         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
11989         return ret_arr;
11990 }
11991
11992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11993         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11995         this_ptr_conv.is_owned = false;
11996         LDKThirtyTwoBytes val_ref;
11997         CHECK((*env)->GetArrayLength(env, val) == 32);
11998         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11999         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
12000 }
12001
12002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12003         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12005         this_ptr_conv.is_owned = false;
12006         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
12007         return ret_val;
12008 }
12009
12010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12011         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12013         this_ptr_conv.is_owned = false;
12014         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
12015 }
12016
12017 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) {
12018         LDKOutPoint outpoint_arg_conv;
12019         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
12020         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
12021         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
12022         LDKPublicKey per_commitment_point_arg_ref;
12023         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
12024         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
12025         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
12026         FREE((void*)output_arg);
12027         LDKPublicKey revocation_pubkey_arg_ref;
12028         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
12029         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
12030         LDKThirtyTwoBytes channel_keys_id_arg_ref;
12031         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
12032         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
12033         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);
12034         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12035         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12036         long ret_ref = (long)ret_var.inner;
12037         if (ret_var.is_owned) {
12038                 ret_ref |= 1;
12039         }
12040         return ret_ref;
12041 }
12042
12043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12044         LDKDelayedPaymentOutputDescriptor orig_conv;
12045         orig_conv.inner = (void*)(orig & (~1));
12046         orig_conv.is_owned = false;
12047         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
12048         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12049         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12050         long ret_ref = (long)ret_var.inner;
12051         if (ret_var.is_owned) {
12052                 ret_ref |= 1;
12053         }
12054         return ret_ref;
12055 }
12056
12057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12058         LDKStaticPaymentOutputDescriptor this_obj_conv;
12059         this_obj_conv.inner = (void*)(this_obj & (~1));
12060         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12061         StaticPaymentOutputDescriptor_free(this_obj_conv);
12062 }
12063
12064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
12065         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12067         this_ptr_conv.is_owned = false;
12068         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
12069         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12070         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12071         long ret_ref = (long)ret_var.inner;
12072         if (ret_var.is_owned) {
12073                 ret_ref |= 1;
12074         }
12075         return ret_ref;
12076 }
12077
12078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12079         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12081         this_ptr_conv.is_owned = false;
12082         LDKOutPoint val_conv;
12083         val_conv.inner = (void*)(val & (~1));
12084         val_conv.is_owned = (val & 1) || (val == 0);
12085         val_conv = OutPoint_clone(&val_conv);
12086         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
12087 }
12088
12089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12090         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12092         this_ptr_conv.is_owned = false;
12093         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
12094         FREE((void*)val);
12095         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
12096 }
12097
12098 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12099         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12101         this_ptr_conv.is_owned = false;
12102         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12103         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
12104         return ret_arr;
12105 }
12106
12107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12108         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12110         this_ptr_conv.is_owned = false;
12111         LDKThirtyTwoBytes val_ref;
12112         CHECK((*env)->GetArrayLength(env, val) == 32);
12113         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12114         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
12115 }
12116
12117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12118         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12120         this_ptr_conv.is_owned = false;
12121         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
12122         return ret_val;
12123 }
12124
12125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12126         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12128         this_ptr_conv.is_owned = false;
12129         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
12130 }
12131
12132 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) {
12133         LDKOutPoint outpoint_arg_conv;
12134         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
12135         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
12136         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
12137         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
12138         FREE((void*)output_arg);
12139         LDKThirtyTwoBytes channel_keys_id_arg_ref;
12140         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
12141         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
12142         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
12143         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12144         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12145         long ret_ref = (long)ret_var.inner;
12146         if (ret_var.is_owned) {
12147                 ret_ref |= 1;
12148         }
12149         return ret_ref;
12150 }
12151
12152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12153         LDKStaticPaymentOutputDescriptor orig_conv;
12154         orig_conv.inner = (void*)(orig & (~1));
12155         orig_conv.is_owned = false;
12156         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
12157         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12158         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12159         long ret_ref = (long)ret_var.inner;
12160         if (ret_var.is_owned) {
12161                 ret_ref |= 1;
12162         }
12163         return ret_ref;
12164 }
12165
12166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12167         if ((this_ptr & 1) != 0) return;
12168         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
12169         FREE((void*)this_ptr);
12170         SpendableOutputDescriptor_free(this_ptr_conv);
12171 }
12172
12173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12174         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
12175         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
12176         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
12177         long ret_ref = (long)ret_copy;
12178         return ret_ref;
12179 }
12180
12181 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
12182         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
12183         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
12184         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
12185         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
12186         CVec_u8Z_free(ret_var);
12187         return ret_arr;
12188 }
12189
12190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
12191         LDKu8slice ser_ref;
12192         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
12193         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
12194         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
12195         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
12196         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
12197         return (long)ret_conv;
12198 }
12199
12200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12201         if ((this_ptr & 1) != 0) return;
12202         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
12203         FREE((void*)this_ptr);
12204         BaseSign_free(this_ptr_conv);
12205 }
12206
12207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12208         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
12209         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
12210         *ret = Sign_clone(orig_conv);
12211         return (long)ret;
12212 }
12213
12214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12215         if ((this_ptr & 1) != 0) return;
12216         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
12217         FREE((void*)this_ptr);
12218         Sign_free(this_ptr_conv);
12219 }
12220
12221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12222         if ((this_ptr & 1) != 0) return;
12223         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
12224         FREE((void*)this_ptr);
12225         KeysInterface_free(this_ptr_conv);
12226 }
12227
12228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12229         LDKInMemorySigner this_obj_conv;
12230         this_obj_conv.inner = (void*)(this_obj & (~1));
12231         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12232         InMemorySigner_free(this_obj_conv);
12233 }
12234
12235 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
12236         LDKInMemorySigner this_ptr_conv;
12237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12238         this_ptr_conv.is_owned = false;
12239         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12240         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
12241         return ret_arr;
12242 }
12243
12244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12245         LDKInMemorySigner this_ptr_conv;
12246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12247         this_ptr_conv.is_owned = false;
12248         LDKSecretKey val_ref;
12249         CHECK((*env)->GetArrayLength(env, val) == 32);
12250         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
12251         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
12252 }
12253
12254 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
12255         LDKInMemorySigner this_ptr_conv;
12256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12257         this_ptr_conv.is_owned = false;
12258         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12259         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
12260         return ret_arr;
12261 }
12262
12263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12264         LDKInMemorySigner this_ptr_conv;
12265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12266         this_ptr_conv.is_owned = false;
12267         LDKSecretKey val_ref;
12268         CHECK((*env)->GetArrayLength(env, val) == 32);
12269         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
12270         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
12271 }
12272
12273 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
12274         LDKInMemorySigner this_ptr_conv;
12275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12276         this_ptr_conv.is_owned = false;
12277         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12278         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
12279         return ret_arr;
12280 }
12281
12282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12283         LDKInMemorySigner this_ptr_conv;
12284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12285         this_ptr_conv.is_owned = false;
12286         LDKSecretKey val_ref;
12287         CHECK((*env)->GetArrayLength(env, val) == 32);
12288         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
12289         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
12290 }
12291
12292 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
12293         LDKInMemorySigner this_ptr_conv;
12294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12295         this_ptr_conv.is_owned = false;
12296         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12297         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
12298         return ret_arr;
12299 }
12300
12301 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) {
12302         LDKInMemorySigner this_ptr_conv;
12303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12304         this_ptr_conv.is_owned = false;
12305         LDKSecretKey val_ref;
12306         CHECK((*env)->GetArrayLength(env, val) == 32);
12307         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
12308         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
12309 }
12310
12311 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
12312         LDKInMemorySigner this_ptr_conv;
12313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12314         this_ptr_conv.is_owned = false;
12315         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12316         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
12317         return ret_arr;
12318 }
12319
12320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12321         LDKInMemorySigner this_ptr_conv;
12322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12323         this_ptr_conv.is_owned = false;
12324         LDKSecretKey val_ref;
12325         CHECK((*env)->GetArrayLength(env, val) == 32);
12326         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
12327         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
12328 }
12329
12330 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
12331         LDKInMemorySigner this_ptr_conv;
12332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12333         this_ptr_conv.is_owned = false;
12334         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12335         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
12336         return ret_arr;
12337 }
12338
12339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12340         LDKInMemorySigner this_ptr_conv;
12341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12342         this_ptr_conv.is_owned = false;
12343         LDKThirtyTwoBytes val_ref;
12344         CHECK((*env)->GetArrayLength(env, val) == 32);
12345         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12346         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
12347 }
12348
12349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12350         LDKInMemorySigner orig_conv;
12351         orig_conv.inner = (void*)(orig & (~1));
12352         orig_conv.is_owned = false;
12353         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
12354         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12355         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12356         long ret_ref = (long)ret_var.inner;
12357         if (ret_var.is_owned) {
12358                 ret_ref |= 1;
12359         }
12360         return ret_ref;
12361 }
12362
12363 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) {
12364         LDKSecretKey funding_key_ref;
12365         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
12366         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
12367         LDKSecretKey revocation_base_key_ref;
12368         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
12369         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
12370         LDKSecretKey payment_key_ref;
12371         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
12372         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
12373         LDKSecretKey delayed_payment_base_key_ref;
12374         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
12375         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
12376         LDKSecretKey htlc_base_key_ref;
12377         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
12378         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
12379         LDKThirtyTwoBytes commitment_seed_ref;
12380         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
12381         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
12382         LDKThirtyTwoBytes channel_keys_id_ref;
12383         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
12384         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
12385         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);
12386         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12387         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12388         long ret_ref = (long)ret_var.inner;
12389         if (ret_var.is_owned) {
12390                 ret_ref |= 1;
12391         }
12392         return ret_ref;
12393 }
12394
12395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
12396         LDKInMemorySigner this_arg_conv;
12397         this_arg_conv.inner = (void*)(this_arg & (~1));
12398         this_arg_conv.is_owned = false;
12399         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
12400         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12401         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12402         long ret_ref = (long)ret_var.inner;
12403         if (ret_var.is_owned) {
12404                 ret_ref |= 1;
12405         }
12406         return ret_ref;
12407 }
12408
12409 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
12410         LDKInMemorySigner this_arg_conv;
12411         this_arg_conv.inner = (void*)(this_arg & (~1));
12412         this_arg_conv.is_owned = false;
12413         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
12414         return ret_val;
12415 }
12416
12417 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
12418         LDKInMemorySigner this_arg_conv;
12419         this_arg_conv.inner = (void*)(this_arg & (~1));
12420         this_arg_conv.is_owned = false;
12421         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
12422         return ret_val;
12423 }
12424
12425 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
12426         LDKInMemorySigner this_arg_conv;
12427         this_arg_conv.inner = (void*)(this_arg & (~1));
12428         this_arg_conv.is_owned = false;
12429         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
12430         return ret_val;
12431 }
12432
12433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
12434         LDKInMemorySigner this_arg_conv;
12435         this_arg_conv.inner = (void*)(this_arg & (~1));
12436         this_arg_conv.is_owned = false;
12437         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_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_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
12448         LDKInMemorySigner this_arg_conv;
12449         this_arg_conv.inner = (void*)(this_arg & (~1));
12450         this_arg_conv.is_owned = false;
12451         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
12452         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12453         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12454         long ret_ref = (long)ret_var.inner;
12455         if (ret_var.is_owned) {
12456                 ret_ref |= 1;
12457         }
12458         return ret_ref;
12459 }
12460
12461 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) {
12462         LDKInMemorySigner this_arg_conv;
12463         this_arg_conv.inner = (void*)(this_arg & (~1));
12464         this_arg_conv.is_owned = false;
12465         LDKTransaction spend_tx_ref;
12466         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
12467         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
12468         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
12469         spend_tx_ref.data_is_owned = true;
12470         LDKStaticPaymentOutputDescriptor descriptor_conv;
12471         descriptor_conv.inner = (void*)(descriptor & (~1));
12472         descriptor_conv.is_owned = false;
12473         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12474         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
12475         return (long)ret_conv;
12476 }
12477
12478 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) {
12479         LDKInMemorySigner this_arg_conv;
12480         this_arg_conv.inner = (void*)(this_arg & (~1));
12481         this_arg_conv.is_owned = false;
12482         LDKTransaction spend_tx_ref;
12483         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
12484         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
12485         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
12486         spend_tx_ref.data_is_owned = true;
12487         LDKDelayedPaymentOutputDescriptor descriptor_conv;
12488         descriptor_conv.inner = (void*)(descriptor & (~1));
12489         descriptor_conv.is_owned = false;
12490         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12491         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
12492         return (long)ret_conv;
12493 }
12494
12495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
12496         LDKInMemorySigner this_arg_conv;
12497         this_arg_conv.inner = (void*)(this_arg & (~1));
12498         this_arg_conv.is_owned = false;
12499         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
12500         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
12501         return (long)ret;
12502 }
12503
12504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
12505         LDKInMemorySigner this_arg_conv;
12506         this_arg_conv.inner = (void*)(this_arg & (~1));
12507         this_arg_conv.is_owned = false;
12508         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
12509         *ret = InMemorySigner_as_Sign(&this_arg_conv);
12510         return (long)ret;
12511 }
12512
12513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
12514         LDKInMemorySigner obj_conv;
12515         obj_conv.inner = (void*)(obj & (~1));
12516         obj_conv.is_owned = false;
12517         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
12518         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
12519         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
12520         CVec_u8Z_free(ret_var);
12521         return ret_arr;
12522 }
12523
12524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
12525         LDKu8slice ser_ref;
12526         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
12527         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
12528         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
12529         *ret_conv = InMemorySigner_read(ser_ref);
12530         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
12531         return (long)ret_conv;
12532 }
12533
12534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12535         LDKKeysManager this_obj_conv;
12536         this_obj_conv.inner = (void*)(this_obj & (~1));
12537         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12538         KeysManager_free(this_obj_conv);
12539 }
12540
12541 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) {
12542         unsigned char seed_arr[32];
12543         CHECK((*env)->GetArrayLength(env, seed) == 32);
12544         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
12545         unsigned char (*seed_ref)[32] = &seed_arr;
12546         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
12547         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12548         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12549         long ret_ref = (long)ret_var.inner;
12550         if (ret_var.is_owned) {
12551                 ret_ref |= 1;
12552         }
12553         return ret_ref;
12554 }
12555
12556 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) {
12557         LDKKeysManager this_arg_conv;
12558         this_arg_conv.inner = (void*)(this_arg & (~1));
12559         this_arg_conv.is_owned = false;
12560         unsigned char params_arr[32];
12561         CHECK((*env)->GetArrayLength(env, params) == 32);
12562         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
12563         unsigned char (*params_ref)[32] = &params_arr;
12564         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
12565         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12566         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12567         long ret_ref = (long)ret_var.inner;
12568         if (ret_var.is_owned) {
12569                 ret_ref |= 1;
12570         }
12571         return ret_ref;
12572 }
12573
12574 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) {
12575         LDKKeysManager this_arg_conv;
12576         this_arg_conv.inner = (void*)(this_arg & (~1));
12577         this_arg_conv.is_owned = false;
12578         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
12579         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
12580         if (descriptors_constr.datalen > 0)
12581                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12582         else
12583                 descriptors_constr.data = NULL;
12584         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
12585         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
12586                 int64_t descriptors_conv_27 = descriptors_vals[b];
12587                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
12588                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
12589                 descriptors_constr.data[b] = descriptors_conv_27_conv;
12590         }
12591         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
12592         LDKCVec_TxOutZ outputs_constr;
12593         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
12594         if (outputs_constr.datalen > 0)
12595                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
12596         else
12597                 outputs_constr.data = NULL;
12598         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
12599         for (size_t h = 0; h < outputs_constr.datalen; h++) {
12600                 int64_t outputs_conv_7 = outputs_vals[h];
12601                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
12602                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
12603                 outputs_constr.data[h] = outputs_conv_7_conv;
12604         }
12605         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
12606         LDKCVec_u8Z change_destination_script_ref;
12607         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
12608         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
12609         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
12610         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
12611         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
12612         return (long)ret_conv;
12613 }
12614
12615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
12616         LDKKeysManager this_arg_conv;
12617         this_arg_conv.inner = (void*)(this_arg & (~1));
12618         this_arg_conv.is_owned = false;
12619         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
12620         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
12621         return (long)ret;
12622 }
12623
12624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12625         LDKChannelManager this_obj_conv;
12626         this_obj_conv.inner = (void*)(this_obj & (~1));
12627         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12628         ChannelManager_free(this_obj_conv);
12629 }
12630
12631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12632         LDKChainParameters this_obj_conv;
12633         this_obj_conv.inner = (void*)(this_obj & (~1));
12634         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12635         ChainParameters_free(this_obj_conv);
12636 }
12637
12638 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
12639         LDKChainParameters this_ptr_conv;
12640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12641         this_ptr_conv.is_owned = false;
12642         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
12643         return ret_conv;
12644 }
12645
12646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
12647         LDKChainParameters this_ptr_conv;
12648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12649         this_ptr_conv.is_owned = false;
12650         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
12651         ChainParameters_set_network(&this_ptr_conv, val_conv);
12652 }
12653
12654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
12655         LDKChainParameters this_ptr_conv;
12656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12657         this_ptr_conv.is_owned = false;
12658         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
12659         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12660         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12661         long ret_ref = (long)ret_var.inner;
12662         if (ret_var.is_owned) {
12663                 ret_ref |= 1;
12664         }
12665         return ret_ref;
12666 }
12667
12668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12669         LDKChainParameters this_ptr_conv;
12670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12671         this_ptr_conv.is_owned = false;
12672         LDKBestBlock val_conv;
12673         val_conv.inner = (void*)(val & (~1));
12674         val_conv.is_owned = (val & 1) || (val == 0);
12675         val_conv = BestBlock_clone(&val_conv);
12676         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
12677 }
12678
12679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
12680         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
12681         LDKBestBlock best_block_arg_conv;
12682         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
12683         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
12684         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
12685         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
12686         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12687         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12688         long ret_ref = (long)ret_var.inner;
12689         if (ret_var.is_owned) {
12690                 ret_ref |= 1;
12691         }
12692         return ret_ref;
12693 }
12694
12695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12696         LDKBestBlock this_obj_conv;
12697         this_obj_conv.inner = (void*)(this_obj & (~1));
12698         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12699         BestBlock_free(this_obj_conv);
12700 }
12701
12702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12703         LDKBestBlock orig_conv;
12704         orig_conv.inner = (void*)(orig & (~1));
12705         orig_conv.is_owned = false;
12706         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
12707         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12708         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12709         long ret_ref = (long)ret_var.inner;
12710         if (ret_var.is_owned) {
12711                 ret_ref |= 1;
12712         }
12713         return ret_ref;
12714 }
12715
12716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
12717         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
12718         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
12719         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12720         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12721         long ret_ref = (long)ret_var.inner;
12722         if (ret_var.is_owned) {
12723                 ret_ref |= 1;
12724         }
12725         return ret_ref;
12726 }
12727
12728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
12729         LDKThirtyTwoBytes block_hash_ref;
12730         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
12731         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
12732         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
12733         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12734         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12735         long ret_ref = (long)ret_var.inner;
12736         if (ret_var.is_owned) {
12737                 ret_ref |= 1;
12738         }
12739         return ret_ref;
12740 }
12741
12742 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
12743         LDKBestBlock this_arg_conv;
12744         this_arg_conv.inner = (void*)(this_arg & (~1));
12745         this_arg_conv.is_owned = false;
12746         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12747         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
12748         return ret_arr;
12749 }
12750
12751 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
12752         LDKBestBlock this_arg_conv;
12753         this_arg_conv.inner = (void*)(this_arg & (~1));
12754         this_arg_conv.is_owned = false;
12755         int32_t ret_val = BestBlock_height(&this_arg_conv);
12756         return ret_val;
12757 }
12758
12759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12760         LDKChannelDetails this_obj_conv;
12761         this_obj_conv.inner = (void*)(this_obj & (~1));
12762         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12763         ChannelDetails_free(this_obj_conv);
12764 }
12765
12766 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12767         LDKChannelDetails this_ptr_conv;
12768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12769         this_ptr_conv.is_owned = false;
12770         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12771         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
12772         return ret_arr;
12773 }
12774
12775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12776         LDKChannelDetails this_ptr_conv;
12777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12778         this_ptr_conv.is_owned = false;
12779         LDKThirtyTwoBytes val_ref;
12780         CHECK((*env)->GetArrayLength(env, val) == 32);
12781         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12782         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
12783 }
12784
12785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12786         LDKChannelDetails this_ptr_conv;
12787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12788         this_ptr_conv.is_owned = false;
12789         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12790         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
12791         long ret_ref = (long)ret_copy;
12792         return ret_ref;
12793 }
12794
12795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12796         LDKChannelDetails this_ptr_conv;
12797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12798         this_ptr_conv.is_owned = false;
12799         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
12800         FREE((void*)val);
12801         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
12802 }
12803
12804 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12805         LDKChannelDetails this_ptr_conv;
12806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12807         this_ptr_conv.is_owned = false;
12808         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
12809         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form);
12810         return ret_arr;
12811 }
12812
12813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12814         LDKChannelDetails this_ptr_conv;
12815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12816         this_ptr_conv.is_owned = false;
12817         LDKPublicKey val_ref;
12818         CHECK((*env)->GetArrayLength(env, val) == 33);
12819         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12820         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
12821 }
12822
12823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
12824         LDKChannelDetails this_ptr_conv;
12825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12826         this_ptr_conv.is_owned = false;
12827         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
12828         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12829         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12830         long ret_ref = (long)ret_var.inner;
12831         if (ret_var.is_owned) {
12832                 ret_ref |= 1;
12833         }
12834         return ret_ref;
12835 }
12836
12837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12838         LDKChannelDetails this_ptr_conv;
12839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12840         this_ptr_conv.is_owned = false;
12841         LDKInitFeatures val_conv;
12842         val_conv.inner = (void*)(val & (~1));
12843         val_conv.is_owned = (val & 1) || (val == 0);
12844         val_conv = InitFeatures_clone(&val_conv);
12845         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
12846 }
12847
12848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12849         LDKChannelDetails this_ptr_conv;
12850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12851         this_ptr_conv.is_owned = false;
12852         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
12853         return ret_val;
12854 }
12855
12856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12857         LDKChannelDetails this_ptr_conv;
12858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12859         this_ptr_conv.is_owned = false;
12860         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
12861 }
12862
12863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12864         LDKChannelDetails this_ptr_conv;
12865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12866         this_ptr_conv.is_owned = false;
12867         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
12868         return ret_val;
12869 }
12870
12871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12872         LDKChannelDetails this_ptr_conv;
12873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12874         this_ptr_conv.is_owned = false;
12875         ChannelDetails_set_user_id(&this_ptr_conv, val);
12876 }
12877
12878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
12879         LDKChannelDetails this_ptr_conv;
12880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12881         this_ptr_conv.is_owned = false;
12882         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
12883         return ret_val;
12884 }
12885
12886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12887         LDKChannelDetails this_ptr_conv;
12888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12889         this_ptr_conv.is_owned = false;
12890         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
12891 }
12892
12893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
12894         LDKChannelDetails this_ptr_conv;
12895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12896         this_ptr_conv.is_owned = false;
12897         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
12898         return ret_val;
12899 }
12900
12901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12902         LDKChannelDetails this_ptr_conv;
12903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12904         this_ptr_conv.is_owned = false;
12905         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
12906 }
12907
12908 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1live(JNIEnv *env, jclass clz, int64_t this_ptr) {
12909         LDKChannelDetails this_ptr_conv;
12910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12911         this_ptr_conv.is_owned = false;
12912         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
12913         return ret_val;
12914 }
12915
12916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1live(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
12917         LDKChannelDetails this_ptr_conv;
12918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12919         this_ptr_conv.is_owned = false;
12920         ChannelDetails_set_is_live(&this_ptr_conv, val);
12921 }
12922
12923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12924         LDKChannelDetails orig_conv;
12925         orig_conv.inner = (void*)(orig & (~1));
12926         orig_conv.is_owned = false;
12927         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
12928         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12929         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12930         long ret_ref = (long)ret_var.inner;
12931         if (ret_var.is_owned) {
12932                 ret_ref |= 1;
12933         }
12934         return ret_ref;
12935 }
12936
12937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12938         if ((this_ptr & 1) != 0) return;
12939         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
12940         FREE((void*)this_ptr);
12941         PaymentSendFailure_free(this_ptr_conv);
12942 }
12943
12944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12945         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
12946         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
12947         *ret_copy = PaymentSendFailure_clone(orig_conv);
12948         long ret_ref = (long)ret_copy;
12949         return ret_ref;
12950 }
12951
12952 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) {
12953         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
12954         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
12955                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12956                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
12957         }
12958         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
12959         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
12960                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12961                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
12962         }
12963         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
12964         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
12965                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12966                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
12967         }
12968         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12969         if (logger_conv.free == LDKLogger_JCalls_free) {
12970                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12971                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12972         }
12973         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
12974         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
12975                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12976                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
12977         }
12978         LDKUserConfig config_conv;
12979         config_conv.inner = (void*)(config & (~1));
12980         config_conv.is_owned = (config & 1) || (config == 0);
12981         config_conv = UserConfig_clone(&config_conv);
12982         LDKChainParameters params_conv;
12983         params_conv.inner = (void*)(params & (~1));
12984         params_conv.is_owned = (params & 1) || (params == 0);
12985         // Warning: we need a move here but no clone is available for LDKChainParameters
12986         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
12987         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12988         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12989         long ret_ref = (long)ret_var.inner;
12990         if (ret_var.is_owned) {
12991                 ret_ref |= 1;
12992         }
12993         return ret_ref;
12994 }
12995
12996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
12997         LDKChannelManager this_arg_conv;
12998         this_arg_conv.inner = (void*)(this_arg & (~1));
12999         this_arg_conv.is_owned = false;
13000         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
13001         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13002         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13003         long ret_ref = (long)ret_var.inner;
13004         if (ret_var.is_owned) {
13005                 ret_ref |= 1;
13006         }
13007         return ret_ref;
13008 }
13009
13010 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) {
13011         LDKChannelManager this_arg_conv;
13012         this_arg_conv.inner = (void*)(this_arg & (~1));
13013         this_arg_conv.is_owned = false;
13014         LDKPublicKey their_network_key_ref;
13015         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
13016         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
13017         LDKUserConfig override_config_conv;
13018         override_config_conv.inner = (void*)(override_config & (~1));
13019         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
13020         override_config_conv = UserConfig_clone(&override_config_conv);
13021         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13022         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
13023         return (long)ret_conv;
13024 }
13025
13026 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
13027         LDKChannelManager this_arg_conv;
13028         this_arg_conv.inner = (void*)(this_arg & (~1));
13029         this_arg_conv.is_owned = false;
13030         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
13031         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13032         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13033         for (size_t q = 0; q < ret_var.datalen; q++) {
13034                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13035                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13036                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13037                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
13038                 if (ret_conv_16_var.is_owned) {
13039                         ret_conv_16_ref |= 1;
13040                 }
13041                 ret_arr_ptr[q] = ret_conv_16_ref;
13042         }
13043         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13044         FREE(ret_var.data);
13045         return ret_arr;
13046 }
13047
13048 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
13049         LDKChannelManager this_arg_conv;
13050         this_arg_conv.inner = (void*)(this_arg & (~1));
13051         this_arg_conv.is_owned = false;
13052         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
13053         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13054         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13055         for (size_t q = 0; q < ret_var.datalen; q++) {
13056                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13057                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13058                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13059                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
13060                 if (ret_conv_16_var.is_owned) {
13061                         ret_conv_16_ref |= 1;
13062                 }
13063                 ret_arr_ptr[q] = ret_conv_16_ref;
13064         }
13065         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13066         FREE(ret_var.data);
13067         return ret_arr;
13068 }
13069
13070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
13071         LDKChannelManager this_arg_conv;
13072         this_arg_conv.inner = (void*)(this_arg & (~1));
13073         this_arg_conv.is_owned = false;
13074         unsigned char channel_id_arr[32];
13075         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
13076         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
13077         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
13078         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13079         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
13080         return (long)ret_conv;
13081 }
13082
13083 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) {
13084         LDKChannelManager this_arg_conv;
13085         this_arg_conv.inner = (void*)(this_arg & (~1));
13086         this_arg_conv.is_owned = false;
13087         unsigned char channel_id_arr[32];
13088         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
13089         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
13090         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
13091         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13092         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
13093         return (long)ret_conv;
13094 }
13095
13096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
13097         LDKChannelManager this_arg_conv;
13098         this_arg_conv.inner = (void*)(this_arg & (~1));
13099         this_arg_conv.is_owned = false;
13100         ChannelManager_force_close_all_channels(&this_arg_conv);
13101 }
13102
13103 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) {
13104         LDKChannelManager this_arg_conv;
13105         this_arg_conv.inner = (void*)(this_arg & (~1));
13106         this_arg_conv.is_owned = false;
13107         LDKRoute route_conv;
13108         route_conv.inner = (void*)(route & (~1));
13109         route_conv.is_owned = false;
13110         LDKThirtyTwoBytes payment_hash_ref;
13111         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13112         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13113         LDKThirtyTwoBytes payment_secret_ref;
13114         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13115         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13116         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13117         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
13118         return (long)ret_conv;
13119 }
13120
13121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1transaction_1generated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
13122         LDKChannelManager this_arg_conv;
13123         this_arg_conv.inner = (void*)(this_arg & (~1));
13124         this_arg_conv.is_owned = false;
13125         unsigned char temporary_channel_id_arr[32];
13126         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
13127         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
13128         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
13129         LDKTransaction funding_transaction_ref;
13130         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
13131         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
13132         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
13133         funding_transaction_ref.data_is_owned = true;
13134         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13135         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
13136         return (long)ret_conv;
13137 }
13138
13139 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) {
13140         LDKChannelManager this_arg_conv;
13141         this_arg_conv.inner = (void*)(this_arg & (~1));
13142         this_arg_conv.is_owned = false;
13143         LDKThreeBytes rgb_ref;
13144         CHECK((*env)->GetArrayLength(env, rgb) == 3);
13145         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
13146         LDKThirtyTwoBytes alias_ref;
13147         CHECK((*env)->GetArrayLength(env, alias) == 32);
13148         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
13149         LDKCVec_NetAddressZ addresses_constr;
13150         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
13151         if (addresses_constr.datalen > 0)
13152                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
13153         else
13154                 addresses_constr.data = NULL;
13155         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
13156         for (size_t m = 0; m < addresses_constr.datalen; m++) {
13157                 int64_t addresses_conv_12 = addresses_vals[m];
13158                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
13159                 FREE((void*)addresses_conv_12);
13160                 addresses_constr.data[m] = addresses_conv_12_conv;
13161         }
13162         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
13163         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
13164 }
13165
13166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
13167         LDKChannelManager this_arg_conv;
13168         this_arg_conv.inner = (void*)(this_arg & (~1));
13169         this_arg_conv.is_owned = false;
13170         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
13171 }
13172
13173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
13174         LDKChannelManager this_arg_conv;
13175         this_arg_conv.inner = (void*)(this_arg & (~1));
13176         this_arg_conv.is_owned = false;
13177         ChannelManager_timer_tick_occurred(&this_arg_conv);
13178 }
13179
13180 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) {
13181         LDKChannelManager this_arg_conv;
13182         this_arg_conv.inner = (void*)(this_arg & (~1));
13183         this_arg_conv.is_owned = false;
13184         unsigned char payment_hash_arr[32];
13185         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13186         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
13187         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
13188         LDKThirtyTwoBytes payment_secret_ref;
13189         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13190         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13191         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
13192         return ret_val;
13193 }
13194
13195 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) {
13196         LDKChannelManager this_arg_conv;
13197         this_arg_conv.inner = (void*)(this_arg & (~1));
13198         this_arg_conv.is_owned = false;
13199         LDKThirtyTwoBytes payment_preimage_ref;
13200         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13201         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13202         LDKThirtyTwoBytes payment_secret_ref;
13203         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13204         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13205         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
13206         return ret_val;
13207 }
13208
13209 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
13210         LDKChannelManager this_arg_conv;
13211         this_arg_conv.inner = (void*)(this_arg & (~1));
13212         this_arg_conv.is_owned = false;
13213         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13214         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
13215         return ret_arr;
13216 }
13217
13218 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) {
13219         LDKChannelManager this_arg_conv;
13220         this_arg_conv.inner = (void*)(this_arg & (~1));
13221         this_arg_conv.is_owned = false;
13222         LDKOutPoint funding_txo_conv;
13223         funding_txo_conv.inner = (void*)(funding_txo & (~1));
13224         funding_txo_conv.is_owned = false;
13225         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
13226 }
13227
13228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
13229         LDKChannelManager this_arg_conv;
13230         this_arg_conv.inner = (void*)(this_arg & (~1));
13231         this_arg_conv.is_owned = false;
13232         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
13233         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
13234         return (long)ret;
13235 }
13236
13237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
13238         LDKChannelManager this_arg_conv;
13239         this_arg_conv.inner = (void*)(this_arg & (~1));
13240         this_arg_conv.is_owned = false;
13241         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
13242         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
13243         return (long)ret;
13244 }
13245
13246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
13247         LDKChannelManager this_arg_conv;
13248         this_arg_conv.inner = (void*)(this_arg & (~1));
13249         this_arg_conv.is_owned = false;
13250         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
13251         *ret = ChannelManager_as_Listen(&this_arg_conv);
13252         return (long)ret;
13253 }
13254
13255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1transactions_1confirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height, int64_tArray txdata) {
13256         LDKChannelManager this_arg_conv;
13257         this_arg_conv.inner = (void*)(this_arg & (~1));
13258         this_arg_conv.is_owned = false;
13259         unsigned char header_arr[80];
13260         CHECK((*env)->GetArrayLength(env, header) == 80);
13261         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
13262         unsigned char (*header_ref)[80] = &header_arr;
13263         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
13264         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
13265         if (txdata_constr.datalen > 0)
13266                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
13267         else
13268                 txdata_constr.data = NULL;
13269         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
13270         for (size_t y = 0; y < txdata_constr.datalen; y++) {
13271                 int64_t txdata_conv_24 = txdata_vals[y];
13272                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
13273                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
13274                 txdata_constr.data[y] = txdata_conv_24_conv;
13275         }
13276         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
13277         ChannelManager_transactions_confirmed(&this_arg_conv, header_ref, height, txdata_constr);
13278 }
13279
13280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1update_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height) {
13281         LDKChannelManager this_arg_conv;
13282         this_arg_conv.inner = (void*)(this_arg & (~1));
13283         this_arg_conv.is_owned = false;
13284         unsigned char header_arr[80];
13285         CHECK((*env)->GetArrayLength(env, header) == 80);
13286         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
13287         unsigned char (*header_ref)[80] = &header_arr;
13288         ChannelManager_update_best_block(&this_arg_conv, header_ref, height);
13289 }
13290
13291 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
13292         LDKChannelManager this_arg_conv;
13293         this_arg_conv.inner = (void*)(this_arg & (~1));
13294         this_arg_conv.is_owned = false;
13295         LDKCVec_TxidZ ret_var = ChannelManager_get_relevant_txids(&this_arg_conv);
13296         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
13297         ;
13298         for (size_t i = 0; i < ret_var.datalen; i++) {
13299                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
13300                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
13301                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
13302         }
13303         FREE(ret_var.data);
13304         return ret_arr;
13305 }
13306
13307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
13308         LDKChannelManager this_arg_conv;
13309         this_arg_conv.inner = (void*)(this_arg & (~1));
13310         this_arg_conv.is_owned = false;
13311         unsigned char txid_arr[32];
13312         CHECK((*env)->GetArrayLength(env, txid) == 32);
13313         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
13314         unsigned char (*txid_ref)[32] = &txid_arr;
13315         ChannelManager_transaction_unconfirmed(&this_arg_conv, txid_ref);
13316 }
13317
13318 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) {
13319         LDKChannelManager this_arg_conv;
13320         this_arg_conv.inner = (void*)(this_arg & (~1));
13321         this_arg_conv.is_owned = false;
13322         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
13323         return ret_val;
13324 }
13325
13326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
13327         LDKChannelManager this_arg_conv;
13328         this_arg_conv.inner = (void*)(this_arg & (~1));
13329         this_arg_conv.is_owned = false;
13330         ChannelManager_await_persistable_update(&this_arg_conv);
13331 }
13332
13333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
13334         LDKChannelManager this_arg_conv;
13335         this_arg_conv.inner = (void*)(this_arg & (~1));
13336         this_arg_conv.is_owned = false;
13337         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
13338         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
13339         return (long)ret;
13340 }
13341
13342 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
13343         LDKChannelManager obj_conv;
13344         obj_conv.inner = (void*)(obj & (~1));
13345         obj_conv.is_owned = false;
13346         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
13347         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13348         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13349         CVec_u8Z_free(ret_var);
13350         return ret_arr;
13351 }
13352
13353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13354         LDKChannelManagerReadArgs this_obj_conv;
13355         this_obj_conv.inner = (void*)(this_obj & (~1));
13356         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13357         ChannelManagerReadArgs_free(this_obj_conv);
13358 }
13359
13360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
13361         LDKChannelManagerReadArgs this_ptr_conv;
13362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13363         this_ptr_conv.is_owned = false;
13364         long ret_ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
13365         return ret_ret;
13366 }
13367
13368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13369         LDKChannelManagerReadArgs this_ptr_conv;
13370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13371         this_ptr_conv.is_owned = false;
13372         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
13373         if (val_conv.free == LDKKeysInterface_JCalls_free) {
13374                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13375                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
13376         }
13377         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
13378 }
13379
13380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
13381         LDKChannelManagerReadArgs this_ptr_conv;
13382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13383         this_ptr_conv.is_owned = false;
13384         long ret_ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
13385         return ret_ret;
13386 }
13387
13388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13389         LDKChannelManagerReadArgs this_ptr_conv;
13390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13391         this_ptr_conv.is_owned = false;
13392         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
13393         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
13394                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13395                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
13396         }
13397         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
13398 }
13399
13400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
13401         LDKChannelManagerReadArgs this_ptr_conv;
13402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13403         this_ptr_conv.is_owned = false;
13404         long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
13405         return ret_ret;
13406 }
13407
13408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13409         LDKChannelManagerReadArgs this_ptr_conv;
13410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13411         this_ptr_conv.is_owned = false;
13412         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
13413         if (val_conv.free == LDKWatch_JCalls_free) {
13414                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13415                 LDKWatch_JCalls_clone(val_conv.this_arg);
13416         }
13417         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
13418 }
13419
13420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
13421         LDKChannelManagerReadArgs this_ptr_conv;
13422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13423         this_ptr_conv.is_owned = false;
13424         long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
13425         return ret_ret;
13426 }
13427
13428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13429         LDKChannelManagerReadArgs this_ptr_conv;
13430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13431         this_ptr_conv.is_owned = false;
13432         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
13433         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
13434                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13435                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
13436         }
13437         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
13438 }
13439
13440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
13441         LDKChannelManagerReadArgs this_ptr_conv;
13442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13443         this_ptr_conv.is_owned = false;
13444         long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
13445         return ret_ret;
13446 }
13447
13448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13449         LDKChannelManagerReadArgs this_ptr_conv;
13450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13451         this_ptr_conv.is_owned = false;
13452         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
13453         if (val_conv.free == LDKLogger_JCalls_free) {
13454                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13455                 LDKLogger_JCalls_clone(val_conv.this_arg);
13456         }
13457         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
13458 }
13459
13460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
13461         LDKChannelManagerReadArgs this_ptr_conv;
13462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13463         this_ptr_conv.is_owned = false;
13464         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
13465         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13466         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13467         long ret_ref = (long)ret_var.inner;
13468         if (ret_var.is_owned) {
13469                 ret_ref |= 1;
13470         }
13471         return ret_ref;
13472 }
13473
13474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13475         LDKChannelManagerReadArgs this_ptr_conv;
13476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13477         this_ptr_conv.is_owned = false;
13478         LDKUserConfig val_conv;
13479         val_conv.inner = (void*)(val & (~1));
13480         val_conv.is_owned = (val & 1) || (val == 0);
13481         val_conv = UserConfig_clone(&val_conv);
13482         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
13483 }
13484
13485 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) {
13486         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
13487         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
13488                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13489                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
13490         }
13491         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13492         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
13493                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13494                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
13495         }
13496         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
13497         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
13498                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13499                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
13500         }
13501         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
13502         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
13503                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13504                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
13505         }
13506         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13507         if (logger_conv.free == LDKLogger_JCalls_free) {
13508                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13509                 LDKLogger_JCalls_clone(logger_conv.this_arg);
13510         }
13511         LDKUserConfig default_config_conv;
13512         default_config_conv.inner = (void*)(default_config & (~1));
13513         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
13514         default_config_conv = UserConfig_clone(&default_config_conv);
13515         LDKCVec_ChannelMonitorZ channel_monitors_constr;
13516         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
13517         if (channel_monitors_constr.datalen > 0)
13518                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
13519         else
13520                 channel_monitors_constr.data = NULL;
13521         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
13522         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
13523                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
13524                 LDKChannelMonitor channel_monitors_conv_16_conv;
13525                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
13526                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
13527                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
13528         }
13529         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
13530         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);
13531         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13532         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13533         long ret_ref = (long)ret_var.inner;
13534         if (ret_var.is_owned) {
13535                 ret_ref |= 1;
13536         }
13537         return ret_ref;
13538 }
13539
13540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
13541         LDKu8slice ser_ref;
13542         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13543         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13544         LDKChannelManagerReadArgs arg_conv;
13545         arg_conv.inner = (void*)(arg & (~1));
13546         arg_conv.is_owned = (arg & 1) || (arg == 0);
13547         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
13548         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
13549         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
13550         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
13551         return (long)ret_conv;
13552 }
13553
13554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13555         LDKDecodeError this_obj_conv;
13556         this_obj_conv.inner = (void*)(this_obj & (~1));
13557         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13558         DecodeError_free(this_obj_conv);
13559 }
13560
13561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13562         LDKDecodeError orig_conv;
13563         orig_conv.inner = (void*)(orig & (~1));
13564         orig_conv.is_owned = false;
13565         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
13566         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13567         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13568         long ret_ref = (long)ret_var.inner;
13569         if (ret_var.is_owned) {
13570                 ret_ref |= 1;
13571         }
13572         return ret_ref;
13573 }
13574
13575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13576         LDKInit this_obj_conv;
13577         this_obj_conv.inner = (void*)(this_obj & (~1));
13578         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13579         Init_free(this_obj_conv);
13580 }
13581
13582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
13583         LDKInit this_ptr_conv;
13584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13585         this_ptr_conv.is_owned = false;
13586         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
13587         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13588         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13589         long ret_ref = (long)ret_var.inner;
13590         if (ret_var.is_owned) {
13591                 ret_ref |= 1;
13592         }
13593         return ret_ref;
13594 }
13595
13596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13597         LDKInit this_ptr_conv;
13598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13599         this_ptr_conv.is_owned = false;
13600         LDKInitFeatures val_conv;
13601         val_conv.inner = (void*)(val & (~1));
13602         val_conv.is_owned = (val & 1) || (val == 0);
13603         val_conv = InitFeatures_clone(&val_conv);
13604         Init_set_features(&this_ptr_conv, val_conv);
13605 }
13606
13607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
13608         LDKInitFeatures features_arg_conv;
13609         features_arg_conv.inner = (void*)(features_arg & (~1));
13610         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
13611         features_arg_conv = InitFeatures_clone(&features_arg_conv);
13612         LDKInit ret_var = Init_new(features_arg_conv);
13613         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13614         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13615         long ret_ref = (long)ret_var.inner;
13616         if (ret_var.is_owned) {
13617                 ret_ref |= 1;
13618         }
13619         return ret_ref;
13620 }
13621
13622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13623         LDKInit orig_conv;
13624         orig_conv.inner = (void*)(orig & (~1));
13625         orig_conv.is_owned = false;
13626         LDKInit ret_var = Init_clone(&orig_conv);
13627         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13628         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13629         long ret_ref = (long)ret_var.inner;
13630         if (ret_var.is_owned) {
13631                 ret_ref |= 1;
13632         }
13633         return ret_ref;
13634 }
13635
13636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13637         LDKErrorMessage this_obj_conv;
13638         this_obj_conv.inner = (void*)(this_obj & (~1));
13639         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13640         ErrorMessage_free(this_obj_conv);
13641 }
13642
13643 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13644         LDKErrorMessage this_ptr_conv;
13645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13646         this_ptr_conv.is_owned = false;
13647         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13648         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
13649         return ret_arr;
13650 }
13651
13652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13653         LDKErrorMessage this_ptr_conv;
13654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13655         this_ptr_conv.is_owned = false;
13656         LDKThirtyTwoBytes val_ref;
13657         CHECK((*env)->GetArrayLength(env, val) == 32);
13658         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13659         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
13660 }
13661
13662 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
13663         LDKErrorMessage this_ptr_conv;
13664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13665         this_ptr_conv.is_owned = false;
13666         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
13667         jstring _conv = str_ref_to_java(env, _str.chars, _str.len);
13668         return _conv;
13669 }
13670
13671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13672         LDKErrorMessage this_ptr_conv;
13673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13674         this_ptr_conv.is_owned = false;
13675         LDKCVec_u8Z val_ref;
13676         val_ref.datalen = (*env)->GetArrayLength(env, val);
13677         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
13678         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
13679         ErrorMessage_set_data(&this_ptr_conv, val_ref);
13680 }
13681
13682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray data_arg) {
13683         LDKThirtyTwoBytes channel_id_arg_ref;
13684         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13685         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13686         LDKCVec_u8Z data_arg_ref;
13687         data_arg_ref.datalen = (*env)->GetArrayLength(env, data_arg);
13688         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
13689         (*env)->GetByteArrayRegion(env, data_arg, 0, data_arg_ref.datalen, data_arg_ref.data);
13690         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
13691         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13692         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13693         long ret_ref = (long)ret_var.inner;
13694         if (ret_var.is_owned) {
13695                 ret_ref |= 1;
13696         }
13697         return ret_ref;
13698 }
13699
13700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13701         LDKErrorMessage orig_conv;
13702         orig_conv.inner = (void*)(orig & (~1));
13703         orig_conv.is_owned = false;
13704         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
13705         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13706         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13707         long ret_ref = (long)ret_var.inner;
13708         if (ret_var.is_owned) {
13709                 ret_ref |= 1;
13710         }
13711         return ret_ref;
13712 }
13713
13714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13715         LDKPing this_obj_conv;
13716         this_obj_conv.inner = (void*)(this_obj & (~1));
13717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13718         Ping_free(this_obj_conv);
13719 }
13720
13721 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
13722         LDKPing this_ptr_conv;
13723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13724         this_ptr_conv.is_owned = false;
13725         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
13726         return ret_val;
13727 }
13728
13729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13730         LDKPing this_ptr_conv;
13731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13732         this_ptr_conv.is_owned = false;
13733         Ping_set_ponglen(&this_ptr_conv, val);
13734 }
13735
13736 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
13737         LDKPing this_ptr_conv;
13738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13739         this_ptr_conv.is_owned = false;
13740         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
13741         return ret_val;
13742 }
13743
13744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13745         LDKPing this_ptr_conv;
13746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13747         this_ptr_conv.is_owned = false;
13748         Ping_set_byteslen(&this_ptr_conv, val);
13749 }
13750
13751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
13752         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
13753         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13754         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13755         long ret_ref = (long)ret_var.inner;
13756         if (ret_var.is_owned) {
13757                 ret_ref |= 1;
13758         }
13759         return ret_ref;
13760 }
13761
13762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13763         LDKPing orig_conv;
13764         orig_conv.inner = (void*)(orig & (~1));
13765         orig_conv.is_owned = false;
13766         LDKPing ret_var = Ping_clone(&orig_conv);
13767         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13768         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13769         long ret_ref = (long)ret_var.inner;
13770         if (ret_var.is_owned) {
13771                 ret_ref |= 1;
13772         }
13773         return ret_ref;
13774 }
13775
13776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13777         LDKPong this_obj_conv;
13778         this_obj_conv.inner = (void*)(this_obj & (~1));
13779         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13780         Pong_free(this_obj_conv);
13781 }
13782
13783 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
13784         LDKPong this_ptr_conv;
13785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13786         this_ptr_conv.is_owned = false;
13787         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
13788         return ret_val;
13789 }
13790
13791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13792         LDKPong this_ptr_conv;
13793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13794         this_ptr_conv.is_owned = false;
13795         Pong_set_byteslen(&this_ptr_conv, val);
13796 }
13797
13798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
13799         LDKPong ret_var = Pong_new(byteslen_arg);
13800         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13801         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13802         long ret_ref = (long)ret_var.inner;
13803         if (ret_var.is_owned) {
13804                 ret_ref |= 1;
13805         }
13806         return ret_ref;
13807 }
13808
13809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13810         LDKPong orig_conv;
13811         orig_conv.inner = (void*)(orig & (~1));
13812         orig_conv.is_owned = false;
13813         LDKPong ret_var = Pong_clone(&orig_conv);
13814         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13815         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13816         long ret_ref = (long)ret_var.inner;
13817         if (ret_var.is_owned) {
13818                 ret_ref |= 1;
13819         }
13820         return ret_ref;
13821 }
13822
13823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13824         LDKOpenChannel this_obj_conv;
13825         this_obj_conv.inner = (void*)(this_obj & (~1));
13826         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13827         OpenChannel_free(this_obj_conv);
13828 }
13829
13830 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
13831         LDKOpenChannel 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, *OpenChannel_get_chain_hash(&this_ptr_conv));
13836         return ret_arr;
13837 }
13838
13839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13840         LDKOpenChannel 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         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
13847 }
13848
13849 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13850         LDKOpenChannel this_ptr_conv;
13851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13852         this_ptr_conv.is_owned = false;
13853         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13854         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
13855         return ret_arr;
13856 }
13857
13858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13859         LDKOpenChannel this_ptr_conv;
13860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13861         this_ptr_conv.is_owned = false;
13862         LDKThirtyTwoBytes val_ref;
13863         CHECK((*env)->GetArrayLength(env, val) == 32);
13864         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13865         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
13866 }
13867
13868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13869         LDKOpenChannel this_ptr_conv;
13870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13871         this_ptr_conv.is_owned = false;
13872         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
13873         return ret_val;
13874 }
13875
13876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13877         LDKOpenChannel this_ptr_conv;
13878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13879         this_ptr_conv.is_owned = false;
13880         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
13881 }
13882
13883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13884         LDKOpenChannel this_ptr_conv;
13885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13886         this_ptr_conv.is_owned = false;
13887         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
13888         return ret_val;
13889 }
13890
13891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13892         LDKOpenChannel this_ptr_conv;
13893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13894         this_ptr_conv.is_owned = false;
13895         OpenChannel_set_push_msat(&this_ptr_conv, val);
13896 }
13897
13898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13899         LDKOpenChannel this_ptr_conv;
13900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13901         this_ptr_conv.is_owned = false;
13902         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
13903         return ret_val;
13904 }
13905
13906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13907         LDKOpenChannel this_ptr_conv;
13908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13909         this_ptr_conv.is_owned = false;
13910         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
13911 }
13912
13913 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) {
13914         LDKOpenChannel this_ptr_conv;
13915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13916         this_ptr_conv.is_owned = false;
13917         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
13918         return ret_val;
13919 }
13920
13921 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) {
13922         LDKOpenChannel this_ptr_conv;
13923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13924         this_ptr_conv.is_owned = false;
13925         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13926 }
13927
13928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13929         LDKOpenChannel this_ptr_conv;
13930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13931         this_ptr_conv.is_owned = false;
13932         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
13933         return ret_val;
13934 }
13935
13936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13937         LDKOpenChannel this_ptr_conv;
13938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13939         this_ptr_conv.is_owned = false;
13940         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
13941 }
13942
13943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13944         LDKOpenChannel this_ptr_conv;
13945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13946         this_ptr_conv.is_owned = false;
13947         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
13948         return ret_val;
13949 }
13950
13951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13952         LDKOpenChannel this_ptr_conv;
13953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13954         this_ptr_conv.is_owned = false;
13955         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
13956 }
13957
13958 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
13959         LDKOpenChannel this_ptr_conv;
13960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13961         this_ptr_conv.is_owned = false;
13962         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
13963         return ret_val;
13964 }
13965
13966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13967         LDKOpenChannel this_ptr_conv;
13968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13969         this_ptr_conv.is_owned = false;
13970         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
13971 }
13972
13973 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13974         LDKOpenChannel this_ptr_conv;
13975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13976         this_ptr_conv.is_owned = false;
13977         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
13978         return ret_val;
13979 }
13980
13981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13982         LDKOpenChannel this_ptr_conv;
13983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13984         this_ptr_conv.is_owned = false;
13985         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
13986 }
13987
13988 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13989         LDKOpenChannel this_ptr_conv;
13990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13991         this_ptr_conv.is_owned = false;
13992         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
13993         return ret_val;
13994 }
13995
13996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13997         LDKOpenChannel this_ptr_conv;
13998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13999         this_ptr_conv.is_owned = false;
14000         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
14001 }
14002
14003 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14004         LDKOpenChannel this_ptr_conv;
14005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14006         this_ptr_conv.is_owned = false;
14007         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14008         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
14009         return ret_arr;
14010 }
14011
14012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14013         LDKOpenChannel this_ptr_conv;
14014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14015         this_ptr_conv.is_owned = false;
14016         LDKPublicKey val_ref;
14017         CHECK((*env)->GetArrayLength(env, val) == 33);
14018         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14019         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
14020 }
14021
14022 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14023         LDKOpenChannel this_ptr_conv;
14024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14025         this_ptr_conv.is_owned = false;
14026         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14027         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
14028         return ret_arr;
14029 }
14030
14031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14032         LDKOpenChannel this_ptr_conv;
14033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14034         this_ptr_conv.is_owned = false;
14035         LDKPublicKey val_ref;
14036         CHECK((*env)->GetArrayLength(env, val) == 33);
14037         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14038         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
14039 }
14040
14041 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14042         LDKOpenChannel this_ptr_conv;
14043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14044         this_ptr_conv.is_owned = false;
14045         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14046         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
14047         return ret_arr;
14048 }
14049
14050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14051         LDKOpenChannel this_ptr_conv;
14052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14053         this_ptr_conv.is_owned = false;
14054         LDKPublicKey val_ref;
14055         CHECK((*env)->GetArrayLength(env, val) == 33);
14056         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14057         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
14058 }
14059
14060 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14061         LDKOpenChannel this_ptr_conv;
14062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14063         this_ptr_conv.is_owned = false;
14064         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14065         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
14066         return ret_arr;
14067 }
14068
14069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14070         LDKOpenChannel this_ptr_conv;
14071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14072         this_ptr_conv.is_owned = false;
14073         LDKPublicKey val_ref;
14074         CHECK((*env)->GetArrayLength(env, val) == 33);
14075         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14076         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
14077 }
14078
14079 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14080         LDKOpenChannel this_ptr_conv;
14081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14082         this_ptr_conv.is_owned = false;
14083         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14084         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
14085         return ret_arr;
14086 }
14087
14088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14089         LDKOpenChannel this_ptr_conv;
14090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14091         this_ptr_conv.is_owned = false;
14092         LDKPublicKey val_ref;
14093         CHECK((*env)->GetArrayLength(env, val) == 33);
14094         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14095         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
14096 }
14097
14098 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14099         LDKOpenChannel this_ptr_conv;
14100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14101         this_ptr_conv.is_owned = false;
14102         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14103         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
14104         return ret_arr;
14105 }
14106
14107 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) {
14108         LDKOpenChannel this_ptr_conv;
14109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14110         this_ptr_conv.is_owned = false;
14111         LDKPublicKey val_ref;
14112         CHECK((*env)->GetArrayLength(env, val) == 33);
14113         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14114         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
14115 }
14116
14117 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
14118         LDKOpenChannel this_ptr_conv;
14119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14120         this_ptr_conv.is_owned = false;
14121         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
14122         return ret_val;
14123 }
14124
14125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
14126         LDKOpenChannel this_ptr_conv;
14127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14128         this_ptr_conv.is_owned = false;
14129         OpenChannel_set_channel_flags(&this_ptr_conv, val);
14130 }
14131
14132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14133         LDKOpenChannel orig_conv;
14134         orig_conv.inner = (void*)(orig & (~1));
14135         orig_conv.is_owned = false;
14136         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
14137         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14138         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14139         long ret_ref = (long)ret_var.inner;
14140         if (ret_var.is_owned) {
14141                 ret_ref |= 1;
14142         }
14143         return ret_ref;
14144 }
14145
14146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14147         LDKAcceptChannel this_obj_conv;
14148         this_obj_conv.inner = (void*)(this_obj & (~1));
14149         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14150         AcceptChannel_free(this_obj_conv);
14151 }
14152
14153 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14154         LDKAcceptChannel this_ptr_conv;
14155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14156         this_ptr_conv.is_owned = false;
14157         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14158         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
14159         return ret_arr;
14160 }
14161
14162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14163         LDKAcceptChannel this_ptr_conv;
14164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14165         this_ptr_conv.is_owned = false;
14166         LDKThirtyTwoBytes val_ref;
14167         CHECK((*env)->GetArrayLength(env, val) == 32);
14168         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14169         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
14170 }
14171
14172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14173         LDKAcceptChannel this_ptr_conv;
14174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14175         this_ptr_conv.is_owned = false;
14176         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
14177         return ret_val;
14178 }
14179
14180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14181         LDKAcceptChannel this_ptr_conv;
14182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14183         this_ptr_conv.is_owned = false;
14184         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
14185 }
14186
14187 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) {
14188         LDKAcceptChannel this_ptr_conv;
14189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14190         this_ptr_conv.is_owned = false;
14191         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
14192         return ret_val;
14193 }
14194
14195 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) {
14196         LDKAcceptChannel this_ptr_conv;
14197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14198         this_ptr_conv.is_owned = false;
14199         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
14200 }
14201
14202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14203         LDKAcceptChannel this_ptr_conv;
14204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14205         this_ptr_conv.is_owned = false;
14206         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
14207         return ret_val;
14208 }
14209
14210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14211         LDKAcceptChannel this_ptr_conv;
14212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14213         this_ptr_conv.is_owned = false;
14214         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
14215 }
14216
14217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14218         LDKAcceptChannel this_ptr_conv;
14219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14220         this_ptr_conv.is_owned = false;
14221         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
14222         return ret_val;
14223 }
14224
14225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14226         LDKAcceptChannel this_ptr_conv;
14227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14228         this_ptr_conv.is_owned = false;
14229         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
14230 }
14231
14232 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
14233         LDKAcceptChannel this_ptr_conv;
14234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14235         this_ptr_conv.is_owned = false;
14236         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
14237         return ret_val;
14238 }
14239
14240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14241         LDKAcceptChannel this_ptr_conv;
14242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14243         this_ptr_conv.is_owned = false;
14244         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
14245 }
14246
14247 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
14248         LDKAcceptChannel this_ptr_conv;
14249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14250         this_ptr_conv.is_owned = false;
14251         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
14252         return ret_val;
14253 }
14254
14255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14256         LDKAcceptChannel this_ptr_conv;
14257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14258         this_ptr_conv.is_owned = false;
14259         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
14260 }
14261
14262 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
14263         LDKAcceptChannel this_ptr_conv;
14264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14265         this_ptr_conv.is_owned = false;
14266         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
14267         return ret_val;
14268 }
14269
14270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14271         LDKAcceptChannel this_ptr_conv;
14272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14273         this_ptr_conv.is_owned = false;
14274         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
14275 }
14276
14277 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14278         LDKAcceptChannel this_ptr_conv;
14279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14280         this_ptr_conv.is_owned = false;
14281         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14282         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
14283         return ret_arr;
14284 }
14285
14286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14287         LDKAcceptChannel this_ptr_conv;
14288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14289         this_ptr_conv.is_owned = false;
14290         LDKPublicKey val_ref;
14291         CHECK((*env)->GetArrayLength(env, val) == 33);
14292         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14293         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
14294 }
14295
14296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14297         LDKAcceptChannel this_ptr_conv;
14298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14299         this_ptr_conv.is_owned = false;
14300         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14301         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
14302         return ret_arr;
14303 }
14304
14305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14306         LDKAcceptChannel this_ptr_conv;
14307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14308         this_ptr_conv.is_owned = false;
14309         LDKPublicKey val_ref;
14310         CHECK((*env)->GetArrayLength(env, val) == 33);
14311         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14312         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
14313 }
14314
14315 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14316         LDKAcceptChannel this_ptr_conv;
14317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14318         this_ptr_conv.is_owned = false;
14319         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14320         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
14321         return ret_arr;
14322 }
14323
14324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14325         LDKAcceptChannel this_ptr_conv;
14326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14327         this_ptr_conv.is_owned = false;
14328         LDKPublicKey val_ref;
14329         CHECK((*env)->GetArrayLength(env, val) == 33);
14330         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14331         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
14332 }
14333
14334 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14335         LDKAcceptChannel this_ptr_conv;
14336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14337         this_ptr_conv.is_owned = false;
14338         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14339         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
14340         return ret_arr;
14341 }
14342
14343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14344         LDKAcceptChannel this_ptr_conv;
14345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14346         this_ptr_conv.is_owned = false;
14347         LDKPublicKey val_ref;
14348         CHECK((*env)->GetArrayLength(env, val) == 33);
14349         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14350         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
14351 }
14352
14353 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14354         LDKAcceptChannel this_ptr_conv;
14355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14356         this_ptr_conv.is_owned = false;
14357         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14358         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
14359         return ret_arr;
14360 }
14361
14362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14363         LDKAcceptChannel this_ptr_conv;
14364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14365         this_ptr_conv.is_owned = false;
14366         LDKPublicKey val_ref;
14367         CHECK((*env)->GetArrayLength(env, val) == 33);
14368         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14369         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
14370 }
14371
14372 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14373         LDKAcceptChannel this_ptr_conv;
14374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14375         this_ptr_conv.is_owned = false;
14376         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14377         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
14378         return ret_arr;
14379 }
14380
14381 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) {
14382         LDKAcceptChannel this_ptr_conv;
14383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14384         this_ptr_conv.is_owned = false;
14385         LDKPublicKey val_ref;
14386         CHECK((*env)->GetArrayLength(env, val) == 33);
14387         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14388         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
14389 }
14390
14391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14392         LDKAcceptChannel orig_conv;
14393         orig_conv.inner = (void*)(orig & (~1));
14394         orig_conv.is_owned = false;
14395         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
14396         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14397         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14398         long ret_ref = (long)ret_var.inner;
14399         if (ret_var.is_owned) {
14400                 ret_ref |= 1;
14401         }
14402         return ret_ref;
14403 }
14404
14405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14406         LDKFundingCreated this_obj_conv;
14407         this_obj_conv.inner = (void*)(this_obj & (~1));
14408         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14409         FundingCreated_free(this_obj_conv);
14410 }
14411
14412 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14413         LDKFundingCreated this_ptr_conv;
14414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14415         this_ptr_conv.is_owned = false;
14416         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14417         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
14418         return ret_arr;
14419 }
14420
14421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14422         LDKFundingCreated this_ptr_conv;
14423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14424         this_ptr_conv.is_owned = false;
14425         LDKThirtyTwoBytes val_ref;
14426         CHECK((*env)->GetArrayLength(env, val) == 32);
14427         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14428         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
14429 }
14430
14431 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
14432         LDKFundingCreated this_ptr_conv;
14433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14434         this_ptr_conv.is_owned = false;
14435         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14436         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
14437         return ret_arr;
14438 }
14439
14440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14441         LDKFundingCreated this_ptr_conv;
14442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14443         this_ptr_conv.is_owned = false;
14444         LDKThirtyTwoBytes val_ref;
14445         CHECK((*env)->GetArrayLength(env, val) == 32);
14446         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14447         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
14448 }
14449
14450 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
14451         LDKFundingCreated this_ptr_conv;
14452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14453         this_ptr_conv.is_owned = false;
14454         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
14455         return ret_val;
14456 }
14457
14458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14459         LDKFundingCreated this_ptr_conv;
14460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14461         this_ptr_conv.is_owned = false;
14462         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
14463 }
14464
14465 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14466         LDKFundingCreated this_ptr_conv;
14467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14468         this_ptr_conv.is_owned = false;
14469         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14470         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
14471         return ret_arr;
14472 }
14473
14474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14475         LDKFundingCreated this_ptr_conv;
14476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14477         this_ptr_conv.is_owned = false;
14478         LDKSignature val_ref;
14479         CHECK((*env)->GetArrayLength(env, val) == 64);
14480         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14481         FundingCreated_set_signature(&this_ptr_conv, val_ref);
14482 }
14483
14484 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) {
14485         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
14486         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
14487         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
14488         LDKThirtyTwoBytes funding_txid_arg_ref;
14489         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
14490         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
14491         LDKSignature signature_arg_ref;
14492         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
14493         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
14494         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
14495         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14496         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14497         long ret_ref = (long)ret_var.inner;
14498         if (ret_var.is_owned) {
14499                 ret_ref |= 1;
14500         }
14501         return ret_ref;
14502 }
14503
14504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14505         LDKFundingCreated orig_conv;
14506         orig_conv.inner = (void*)(orig & (~1));
14507         orig_conv.is_owned = false;
14508         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
14509         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14510         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14511         long ret_ref = (long)ret_var.inner;
14512         if (ret_var.is_owned) {
14513                 ret_ref |= 1;
14514         }
14515         return ret_ref;
14516 }
14517
14518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14519         LDKFundingSigned this_obj_conv;
14520         this_obj_conv.inner = (void*)(this_obj & (~1));
14521         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14522         FundingSigned_free(this_obj_conv);
14523 }
14524
14525 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14526         LDKFundingSigned this_ptr_conv;
14527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14528         this_ptr_conv.is_owned = false;
14529         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14530         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
14531         return ret_arr;
14532 }
14533
14534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14535         LDKFundingSigned this_ptr_conv;
14536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14537         this_ptr_conv.is_owned = false;
14538         LDKThirtyTwoBytes val_ref;
14539         CHECK((*env)->GetArrayLength(env, val) == 32);
14540         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14541         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
14542 }
14543
14544 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14545         LDKFundingSigned this_ptr_conv;
14546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14547         this_ptr_conv.is_owned = false;
14548         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14549         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
14550         return ret_arr;
14551 }
14552
14553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14554         LDKFundingSigned this_ptr_conv;
14555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14556         this_ptr_conv.is_owned = false;
14557         LDKSignature val_ref;
14558         CHECK((*env)->GetArrayLength(env, val) == 64);
14559         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14560         FundingSigned_set_signature(&this_ptr_conv, val_ref);
14561 }
14562
14563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
14564         LDKThirtyTwoBytes channel_id_arg_ref;
14565         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14566         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14567         LDKSignature signature_arg_ref;
14568         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
14569         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
14570         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
14571         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14572         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14573         long ret_ref = (long)ret_var.inner;
14574         if (ret_var.is_owned) {
14575                 ret_ref |= 1;
14576         }
14577         return ret_ref;
14578 }
14579
14580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14581         LDKFundingSigned orig_conv;
14582         orig_conv.inner = (void*)(orig & (~1));
14583         orig_conv.is_owned = false;
14584         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
14585         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14586         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14587         long ret_ref = (long)ret_var.inner;
14588         if (ret_var.is_owned) {
14589                 ret_ref |= 1;
14590         }
14591         return ret_ref;
14592 }
14593
14594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14595         LDKFundingLocked this_obj_conv;
14596         this_obj_conv.inner = (void*)(this_obj & (~1));
14597         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14598         FundingLocked_free(this_obj_conv);
14599 }
14600
14601 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14602         LDKFundingLocked this_ptr_conv;
14603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14604         this_ptr_conv.is_owned = false;
14605         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14606         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
14607         return ret_arr;
14608 }
14609
14610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14611         LDKFundingLocked this_ptr_conv;
14612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14613         this_ptr_conv.is_owned = false;
14614         LDKThirtyTwoBytes val_ref;
14615         CHECK((*env)->GetArrayLength(env, val) == 32);
14616         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14617         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
14618 }
14619
14620 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14621         LDKFundingLocked this_ptr_conv;
14622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14623         this_ptr_conv.is_owned = false;
14624         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14625         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
14626         return ret_arr;
14627 }
14628
14629 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) {
14630         LDKFundingLocked this_ptr_conv;
14631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14632         this_ptr_conv.is_owned = false;
14633         LDKPublicKey val_ref;
14634         CHECK((*env)->GetArrayLength(env, val) == 33);
14635         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14636         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
14637 }
14638
14639 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) {
14640         LDKThirtyTwoBytes channel_id_arg_ref;
14641         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14642         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14643         LDKPublicKey next_per_commitment_point_arg_ref;
14644         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
14645         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
14646         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
14647         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14648         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14649         long ret_ref = (long)ret_var.inner;
14650         if (ret_var.is_owned) {
14651                 ret_ref |= 1;
14652         }
14653         return ret_ref;
14654 }
14655
14656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14657         LDKFundingLocked orig_conv;
14658         orig_conv.inner = (void*)(orig & (~1));
14659         orig_conv.is_owned = false;
14660         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
14661         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14662         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14663         long ret_ref = (long)ret_var.inner;
14664         if (ret_var.is_owned) {
14665                 ret_ref |= 1;
14666         }
14667         return ret_ref;
14668 }
14669
14670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14671         LDKShutdown this_obj_conv;
14672         this_obj_conv.inner = (void*)(this_obj & (~1));
14673         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14674         Shutdown_free(this_obj_conv);
14675 }
14676
14677 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14678         LDKShutdown this_ptr_conv;
14679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14680         this_ptr_conv.is_owned = false;
14681         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14682         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
14683         return ret_arr;
14684 }
14685
14686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14687         LDKShutdown this_ptr_conv;
14688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14689         this_ptr_conv.is_owned = false;
14690         LDKThirtyTwoBytes val_ref;
14691         CHECK((*env)->GetArrayLength(env, val) == 32);
14692         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14693         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
14694 }
14695
14696 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14697         LDKShutdown this_ptr_conv;
14698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14699         this_ptr_conv.is_owned = false;
14700         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
14701         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14702         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14703         return ret_arr;
14704 }
14705
14706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14707         LDKShutdown this_ptr_conv;
14708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14709         this_ptr_conv.is_owned = false;
14710         LDKCVec_u8Z val_ref;
14711         val_ref.datalen = (*env)->GetArrayLength(env, val);
14712         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14713         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
14714         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
14715 }
14716
14717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
14718         LDKThirtyTwoBytes channel_id_arg_ref;
14719         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14720         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14721         LDKCVec_u8Z scriptpubkey_arg_ref;
14722         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
14723         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14724         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
14725         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
14726         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14727         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14728         long ret_ref = (long)ret_var.inner;
14729         if (ret_var.is_owned) {
14730                 ret_ref |= 1;
14731         }
14732         return ret_ref;
14733 }
14734
14735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14736         LDKShutdown orig_conv;
14737         orig_conv.inner = (void*)(orig & (~1));
14738         orig_conv.is_owned = false;
14739         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
14740         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14741         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14742         long ret_ref = (long)ret_var.inner;
14743         if (ret_var.is_owned) {
14744                 ret_ref |= 1;
14745         }
14746         return ret_ref;
14747 }
14748
14749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14750         LDKClosingSigned this_obj_conv;
14751         this_obj_conv.inner = (void*)(this_obj & (~1));
14752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14753         ClosingSigned_free(this_obj_conv);
14754 }
14755
14756 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14757         LDKClosingSigned this_ptr_conv;
14758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14759         this_ptr_conv.is_owned = false;
14760         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14761         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
14762         return ret_arr;
14763 }
14764
14765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14766         LDKClosingSigned this_ptr_conv;
14767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14768         this_ptr_conv.is_owned = false;
14769         LDKThirtyTwoBytes val_ref;
14770         CHECK((*env)->GetArrayLength(env, val) == 32);
14771         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14772         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
14773 }
14774
14775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14776         LDKClosingSigned this_ptr_conv;
14777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14778         this_ptr_conv.is_owned = false;
14779         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
14780         return ret_val;
14781 }
14782
14783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14784         LDKClosingSigned this_ptr_conv;
14785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14786         this_ptr_conv.is_owned = false;
14787         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
14788 }
14789
14790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14791         LDKClosingSigned this_ptr_conv;
14792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14793         this_ptr_conv.is_owned = false;
14794         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14795         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
14796         return ret_arr;
14797 }
14798
14799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14800         LDKClosingSigned this_ptr_conv;
14801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14802         this_ptr_conv.is_owned = false;
14803         LDKSignature val_ref;
14804         CHECK((*env)->GetArrayLength(env, val) == 64);
14805         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14806         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
14807 }
14808
14809 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) {
14810         LDKThirtyTwoBytes channel_id_arg_ref;
14811         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14812         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14813         LDKSignature signature_arg_ref;
14814         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
14815         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
14816         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
14817         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14818         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14819         long ret_ref = (long)ret_var.inner;
14820         if (ret_var.is_owned) {
14821                 ret_ref |= 1;
14822         }
14823         return ret_ref;
14824 }
14825
14826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14827         LDKClosingSigned orig_conv;
14828         orig_conv.inner = (void*)(orig & (~1));
14829         orig_conv.is_owned = false;
14830         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
14831         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14832         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14833         long ret_ref = (long)ret_var.inner;
14834         if (ret_var.is_owned) {
14835                 ret_ref |= 1;
14836         }
14837         return ret_ref;
14838 }
14839
14840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14841         LDKUpdateAddHTLC this_obj_conv;
14842         this_obj_conv.inner = (void*)(this_obj & (~1));
14843         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14844         UpdateAddHTLC_free(this_obj_conv);
14845 }
14846
14847 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14848         LDKUpdateAddHTLC this_ptr_conv;
14849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14850         this_ptr_conv.is_owned = false;
14851         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14852         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
14853         return ret_arr;
14854 }
14855
14856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14857         LDKUpdateAddHTLC this_ptr_conv;
14858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14859         this_ptr_conv.is_owned = false;
14860         LDKThirtyTwoBytes val_ref;
14861         CHECK((*env)->GetArrayLength(env, val) == 32);
14862         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14863         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
14864 }
14865
14866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14867         LDKUpdateAddHTLC this_ptr_conv;
14868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14869         this_ptr_conv.is_owned = false;
14870         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
14871         return ret_val;
14872 }
14873
14874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14875         LDKUpdateAddHTLC this_ptr_conv;
14876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14877         this_ptr_conv.is_owned = false;
14878         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
14879 }
14880
14881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14882         LDKUpdateAddHTLC this_ptr_conv;
14883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14884         this_ptr_conv.is_owned = false;
14885         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
14886         return ret_val;
14887 }
14888
14889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14890         LDKUpdateAddHTLC this_ptr_conv;
14891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14892         this_ptr_conv.is_owned = false;
14893         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
14894 }
14895
14896 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14897         LDKUpdateAddHTLC this_ptr_conv;
14898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14899         this_ptr_conv.is_owned = false;
14900         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14901         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
14902         return ret_arr;
14903 }
14904
14905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14906         LDKUpdateAddHTLC this_ptr_conv;
14907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14908         this_ptr_conv.is_owned = false;
14909         LDKThirtyTwoBytes val_ref;
14910         CHECK((*env)->GetArrayLength(env, val) == 32);
14911         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14912         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
14913 }
14914
14915 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
14916         LDKUpdateAddHTLC this_ptr_conv;
14917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14918         this_ptr_conv.is_owned = false;
14919         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
14920         return ret_val;
14921 }
14922
14923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14924         LDKUpdateAddHTLC this_ptr_conv;
14925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14926         this_ptr_conv.is_owned = false;
14927         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
14928 }
14929
14930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14931         LDKUpdateAddHTLC orig_conv;
14932         orig_conv.inner = (void*)(orig & (~1));
14933         orig_conv.is_owned = false;
14934         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
14935         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14936         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14937         long ret_ref = (long)ret_var.inner;
14938         if (ret_var.is_owned) {
14939                 ret_ref |= 1;
14940         }
14941         return ret_ref;
14942 }
14943
14944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14945         LDKUpdateFulfillHTLC this_obj_conv;
14946         this_obj_conv.inner = (void*)(this_obj & (~1));
14947         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14948         UpdateFulfillHTLC_free(this_obj_conv);
14949 }
14950
14951 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14952         LDKUpdateFulfillHTLC this_ptr_conv;
14953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14954         this_ptr_conv.is_owned = false;
14955         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14956         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
14957         return ret_arr;
14958 }
14959
14960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14961         LDKUpdateFulfillHTLC this_ptr_conv;
14962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14963         this_ptr_conv.is_owned = false;
14964         LDKThirtyTwoBytes val_ref;
14965         CHECK((*env)->GetArrayLength(env, val) == 32);
14966         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14967         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
14968 }
14969
14970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14971         LDKUpdateFulfillHTLC this_ptr_conv;
14972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14973         this_ptr_conv.is_owned = false;
14974         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
14975         return ret_val;
14976 }
14977
14978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14979         LDKUpdateFulfillHTLC this_ptr_conv;
14980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14981         this_ptr_conv.is_owned = false;
14982         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
14983 }
14984
14985 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
14986         LDKUpdateFulfillHTLC this_ptr_conv;
14987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14988         this_ptr_conv.is_owned = false;
14989         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14990         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
14991         return ret_arr;
14992 }
14993
14994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14995         LDKUpdateFulfillHTLC this_ptr_conv;
14996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14997         this_ptr_conv.is_owned = false;
14998         LDKThirtyTwoBytes val_ref;
14999         CHECK((*env)->GetArrayLength(env, val) == 32);
15000         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15001         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
15002 }
15003
15004 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) {
15005         LDKThirtyTwoBytes channel_id_arg_ref;
15006         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
15007         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
15008         LDKThirtyTwoBytes payment_preimage_arg_ref;
15009         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
15010         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
15011         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
15012         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15013         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15014         long ret_ref = (long)ret_var.inner;
15015         if (ret_var.is_owned) {
15016                 ret_ref |= 1;
15017         }
15018         return ret_ref;
15019 }
15020
15021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15022         LDKUpdateFulfillHTLC orig_conv;
15023         orig_conv.inner = (void*)(orig & (~1));
15024         orig_conv.is_owned = false;
15025         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
15026         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15027         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15028         long ret_ref = (long)ret_var.inner;
15029         if (ret_var.is_owned) {
15030                 ret_ref |= 1;
15031         }
15032         return ret_ref;
15033 }
15034
15035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15036         LDKUpdateFailHTLC this_obj_conv;
15037         this_obj_conv.inner = (void*)(this_obj & (~1));
15038         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15039         UpdateFailHTLC_free(this_obj_conv);
15040 }
15041
15042 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15043         LDKUpdateFailHTLC this_ptr_conv;
15044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15045         this_ptr_conv.is_owned = false;
15046         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15047         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
15048         return ret_arr;
15049 }
15050
15051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15052         LDKUpdateFailHTLC this_ptr_conv;
15053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15054         this_ptr_conv.is_owned = false;
15055         LDKThirtyTwoBytes val_ref;
15056         CHECK((*env)->GetArrayLength(env, val) == 32);
15057         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15058         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
15059 }
15060
15061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15062         LDKUpdateFailHTLC this_ptr_conv;
15063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15064         this_ptr_conv.is_owned = false;
15065         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
15066         return ret_val;
15067 }
15068
15069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15070         LDKUpdateFailHTLC this_ptr_conv;
15071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15072         this_ptr_conv.is_owned = false;
15073         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
15074 }
15075
15076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15077         LDKUpdateFailHTLC orig_conv;
15078         orig_conv.inner = (void*)(orig & (~1));
15079         orig_conv.is_owned = false;
15080         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
15081         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15082         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15083         long ret_ref = (long)ret_var.inner;
15084         if (ret_var.is_owned) {
15085                 ret_ref |= 1;
15086         }
15087         return ret_ref;
15088 }
15089
15090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15091         LDKUpdateFailMalformedHTLC this_obj_conv;
15092         this_obj_conv.inner = (void*)(this_obj & (~1));
15093         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15094         UpdateFailMalformedHTLC_free(this_obj_conv);
15095 }
15096
15097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15098         LDKUpdateFailMalformedHTLC this_ptr_conv;
15099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15100         this_ptr_conv.is_owned = false;
15101         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15102         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
15103         return ret_arr;
15104 }
15105
15106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15107         LDKUpdateFailMalformedHTLC this_ptr_conv;
15108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15109         this_ptr_conv.is_owned = false;
15110         LDKThirtyTwoBytes val_ref;
15111         CHECK((*env)->GetArrayLength(env, val) == 32);
15112         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15113         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
15114 }
15115
15116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15117         LDKUpdateFailMalformedHTLC this_ptr_conv;
15118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15119         this_ptr_conv.is_owned = false;
15120         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
15121         return ret_val;
15122 }
15123
15124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15125         LDKUpdateFailMalformedHTLC this_ptr_conv;
15126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15127         this_ptr_conv.is_owned = false;
15128         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
15129 }
15130
15131 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
15132         LDKUpdateFailMalformedHTLC this_ptr_conv;
15133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15134         this_ptr_conv.is_owned = false;
15135         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
15136         return ret_val;
15137 }
15138
15139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15140         LDKUpdateFailMalformedHTLC this_ptr_conv;
15141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15142         this_ptr_conv.is_owned = false;
15143         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
15144 }
15145
15146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15147         LDKUpdateFailMalformedHTLC orig_conv;
15148         orig_conv.inner = (void*)(orig & (~1));
15149         orig_conv.is_owned = false;
15150         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
15151         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15152         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15153         long ret_ref = (long)ret_var.inner;
15154         if (ret_var.is_owned) {
15155                 ret_ref |= 1;
15156         }
15157         return ret_ref;
15158 }
15159
15160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15161         LDKCommitmentSigned this_obj_conv;
15162         this_obj_conv.inner = (void*)(this_obj & (~1));
15163         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15164         CommitmentSigned_free(this_obj_conv);
15165 }
15166
15167 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15168         LDKCommitmentSigned this_ptr_conv;
15169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15170         this_ptr_conv.is_owned = false;
15171         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15172         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
15173         return ret_arr;
15174 }
15175
15176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15177         LDKCommitmentSigned this_ptr_conv;
15178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15179         this_ptr_conv.is_owned = false;
15180         LDKThirtyTwoBytes val_ref;
15181         CHECK((*env)->GetArrayLength(env, val) == 32);
15182         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15183         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
15184 }
15185
15186 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15187         LDKCommitmentSigned this_ptr_conv;
15188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15189         this_ptr_conv.is_owned = false;
15190         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15191         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
15192         return ret_arr;
15193 }
15194
15195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15196         LDKCommitmentSigned this_ptr_conv;
15197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15198         this_ptr_conv.is_owned = false;
15199         LDKSignature val_ref;
15200         CHECK((*env)->GetArrayLength(env, val) == 64);
15201         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15202         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
15203 }
15204
15205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
15206         LDKCommitmentSigned this_ptr_conv;
15207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15208         this_ptr_conv.is_owned = false;
15209         LDKCVec_SignatureZ val_constr;
15210         val_constr.datalen = (*env)->GetArrayLength(env, val);
15211         if (val_constr.datalen > 0)
15212                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15213         else
15214                 val_constr.data = NULL;
15215         for (size_t i = 0; i < val_constr.datalen; i++) {
15216                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
15217                 LDKSignature val_conv_8_ref;
15218                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
15219                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
15220                 val_constr.data[i] = val_conv_8_ref;
15221         }
15222         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
15223 }
15224
15225 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) {
15226         LDKThirtyTwoBytes channel_id_arg_ref;
15227         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
15228         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
15229         LDKSignature signature_arg_ref;
15230         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
15231         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
15232         LDKCVec_SignatureZ htlc_signatures_arg_constr;
15233         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
15234         if (htlc_signatures_arg_constr.datalen > 0)
15235                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15236         else
15237                 htlc_signatures_arg_constr.data = NULL;
15238         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
15239                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
15240                 LDKSignature htlc_signatures_arg_conv_8_ref;
15241                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
15242                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
15243                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
15244         }
15245         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
15246         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15247         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15248         long ret_ref = (long)ret_var.inner;
15249         if (ret_var.is_owned) {
15250                 ret_ref |= 1;
15251         }
15252         return ret_ref;
15253 }
15254
15255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15256         LDKCommitmentSigned orig_conv;
15257         orig_conv.inner = (void*)(orig & (~1));
15258         orig_conv.is_owned = false;
15259         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
15260         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15261         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15262         long ret_ref = (long)ret_var.inner;
15263         if (ret_var.is_owned) {
15264                 ret_ref |= 1;
15265         }
15266         return ret_ref;
15267 }
15268
15269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15270         LDKRevokeAndACK this_obj_conv;
15271         this_obj_conv.inner = (void*)(this_obj & (~1));
15272         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15273         RevokeAndACK_free(this_obj_conv);
15274 }
15275
15276 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15277         LDKRevokeAndACK this_ptr_conv;
15278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15279         this_ptr_conv.is_owned = false;
15280         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15281         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
15282         return ret_arr;
15283 }
15284
15285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15286         LDKRevokeAndACK this_ptr_conv;
15287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15288         this_ptr_conv.is_owned = false;
15289         LDKThirtyTwoBytes val_ref;
15290         CHECK((*env)->GetArrayLength(env, val) == 32);
15291         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15292         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
15293 }
15294
15295 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
15296         LDKRevokeAndACK this_ptr_conv;
15297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15298         this_ptr_conv.is_owned = false;
15299         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15300         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
15301         return ret_arr;
15302 }
15303
15304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15305         LDKRevokeAndACK this_ptr_conv;
15306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15307         this_ptr_conv.is_owned = false;
15308         LDKThirtyTwoBytes val_ref;
15309         CHECK((*env)->GetArrayLength(env, val) == 32);
15310         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15311         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
15312 }
15313
15314 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
15315         LDKRevokeAndACK this_ptr_conv;
15316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15317         this_ptr_conv.is_owned = false;
15318         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15319         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
15320         return ret_arr;
15321 }
15322
15323 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) {
15324         LDKRevokeAndACK this_ptr_conv;
15325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15326         this_ptr_conv.is_owned = false;
15327         LDKPublicKey val_ref;
15328         CHECK((*env)->GetArrayLength(env, val) == 33);
15329         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15330         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
15331 }
15332
15333 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) {
15334         LDKThirtyTwoBytes channel_id_arg_ref;
15335         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
15336         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
15337         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
15338         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
15339         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
15340         LDKPublicKey next_per_commitment_point_arg_ref;
15341         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
15342         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
15343         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
15344         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15345         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15346         long ret_ref = (long)ret_var.inner;
15347         if (ret_var.is_owned) {
15348                 ret_ref |= 1;
15349         }
15350         return ret_ref;
15351 }
15352
15353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15354         LDKRevokeAndACK orig_conv;
15355         orig_conv.inner = (void*)(orig & (~1));
15356         orig_conv.is_owned = false;
15357         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
15358         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15359         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15360         long ret_ref = (long)ret_var.inner;
15361         if (ret_var.is_owned) {
15362                 ret_ref |= 1;
15363         }
15364         return ret_ref;
15365 }
15366
15367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15368         LDKUpdateFee this_obj_conv;
15369         this_obj_conv.inner = (void*)(this_obj & (~1));
15370         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15371         UpdateFee_free(this_obj_conv);
15372 }
15373
15374 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15375         LDKUpdateFee this_ptr_conv;
15376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15377         this_ptr_conv.is_owned = false;
15378         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15379         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
15380         return ret_arr;
15381 }
15382
15383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15384         LDKUpdateFee this_ptr_conv;
15385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15386         this_ptr_conv.is_owned = false;
15387         LDKThirtyTwoBytes val_ref;
15388         CHECK((*env)->GetArrayLength(env, val) == 32);
15389         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15390         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
15391 }
15392
15393 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
15394         LDKUpdateFee this_ptr_conv;
15395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15396         this_ptr_conv.is_owned = false;
15397         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
15398         return ret_val;
15399 }
15400
15401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15402         LDKUpdateFee this_ptr_conv;
15403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15404         this_ptr_conv.is_owned = false;
15405         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
15406 }
15407
15408 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) {
15409         LDKThirtyTwoBytes channel_id_arg_ref;
15410         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
15411         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
15412         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
15413         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15414         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15415         long ret_ref = (long)ret_var.inner;
15416         if (ret_var.is_owned) {
15417                 ret_ref |= 1;
15418         }
15419         return ret_ref;
15420 }
15421
15422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15423         LDKUpdateFee orig_conv;
15424         orig_conv.inner = (void*)(orig & (~1));
15425         orig_conv.is_owned = false;
15426         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
15427         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15428         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15429         long ret_ref = (long)ret_var.inner;
15430         if (ret_var.is_owned) {
15431                 ret_ref |= 1;
15432         }
15433         return ret_ref;
15434 }
15435
15436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15437         LDKDataLossProtect this_obj_conv;
15438         this_obj_conv.inner = (void*)(this_obj & (~1));
15439         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15440         DataLossProtect_free(this_obj_conv);
15441 }
15442
15443 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
15444         LDKDataLossProtect this_ptr_conv;
15445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15446         this_ptr_conv.is_owned = false;
15447         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15448         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
15449         return ret_arr;
15450 }
15451
15452 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) {
15453         LDKDataLossProtect this_ptr_conv;
15454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15455         this_ptr_conv.is_owned = false;
15456         LDKThirtyTwoBytes val_ref;
15457         CHECK((*env)->GetArrayLength(env, val) == 32);
15458         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15459         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
15460 }
15461
15462 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
15463         LDKDataLossProtect this_ptr_conv;
15464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15465         this_ptr_conv.is_owned = false;
15466         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15467         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
15468         return ret_arr;
15469 }
15470
15471 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) {
15472         LDKDataLossProtect this_ptr_conv;
15473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15474         this_ptr_conv.is_owned = false;
15475         LDKPublicKey val_ref;
15476         CHECK((*env)->GetArrayLength(env, val) == 33);
15477         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15478         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
15479 }
15480
15481 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) {
15482         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
15483         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
15484         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
15485         LDKPublicKey my_current_per_commitment_point_arg_ref;
15486         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
15487         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
15488         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
15489         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15490         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15491         long ret_ref = (long)ret_var.inner;
15492         if (ret_var.is_owned) {
15493                 ret_ref |= 1;
15494         }
15495         return ret_ref;
15496 }
15497
15498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15499         LDKDataLossProtect orig_conv;
15500         orig_conv.inner = (void*)(orig & (~1));
15501         orig_conv.is_owned = false;
15502         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
15503         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15504         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15505         long ret_ref = (long)ret_var.inner;
15506         if (ret_var.is_owned) {
15507                 ret_ref |= 1;
15508         }
15509         return ret_ref;
15510 }
15511
15512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15513         LDKChannelReestablish this_obj_conv;
15514         this_obj_conv.inner = (void*)(this_obj & (~1));
15515         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15516         ChannelReestablish_free(this_obj_conv);
15517 }
15518
15519 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15520         LDKChannelReestablish this_ptr_conv;
15521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15522         this_ptr_conv.is_owned = false;
15523         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15524         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
15525         return ret_arr;
15526 }
15527
15528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15529         LDKChannelReestablish this_ptr_conv;
15530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15531         this_ptr_conv.is_owned = false;
15532         LDKThirtyTwoBytes val_ref;
15533         CHECK((*env)->GetArrayLength(env, val) == 32);
15534         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15535         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
15536 }
15537
15538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
15539         LDKChannelReestablish this_ptr_conv;
15540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15541         this_ptr_conv.is_owned = false;
15542         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
15543         return ret_val;
15544 }
15545
15546 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) {
15547         LDKChannelReestablish this_ptr_conv;
15548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15549         this_ptr_conv.is_owned = false;
15550         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
15551 }
15552
15553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
15554         LDKChannelReestablish this_ptr_conv;
15555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15556         this_ptr_conv.is_owned = false;
15557         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
15558         return ret_val;
15559 }
15560
15561 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) {
15562         LDKChannelReestablish this_ptr_conv;
15563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15564         this_ptr_conv.is_owned = false;
15565         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
15566 }
15567
15568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15569         LDKChannelReestablish orig_conv;
15570         orig_conv.inner = (void*)(orig & (~1));
15571         orig_conv.is_owned = false;
15572         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
15573         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15574         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15575         long ret_ref = (long)ret_var.inner;
15576         if (ret_var.is_owned) {
15577                 ret_ref |= 1;
15578         }
15579         return ret_ref;
15580 }
15581
15582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15583         LDKAnnouncementSignatures this_obj_conv;
15584         this_obj_conv.inner = (void*)(this_obj & (~1));
15585         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15586         AnnouncementSignatures_free(this_obj_conv);
15587 }
15588
15589 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15590         LDKAnnouncementSignatures this_ptr_conv;
15591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15592         this_ptr_conv.is_owned = false;
15593         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15594         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
15595         return ret_arr;
15596 }
15597
15598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15599         LDKAnnouncementSignatures this_ptr_conv;
15600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15601         this_ptr_conv.is_owned = false;
15602         LDKThirtyTwoBytes val_ref;
15603         CHECK((*env)->GetArrayLength(env, val) == 32);
15604         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15605         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
15606 }
15607
15608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15609         LDKAnnouncementSignatures this_ptr_conv;
15610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15611         this_ptr_conv.is_owned = false;
15612         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
15613         return ret_val;
15614 }
15615
15616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15617         LDKAnnouncementSignatures this_ptr_conv;
15618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15619         this_ptr_conv.is_owned = false;
15620         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
15621 }
15622
15623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15624         LDKAnnouncementSignatures this_ptr_conv;
15625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15626         this_ptr_conv.is_owned = false;
15627         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15628         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
15629         return ret_arr;
15630 }
15631
15632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15633         LDKAnnouncementSignatures this_ptr_conv;
15634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15635         this_ptr_conv.is_owned = false;
15636         LDKSignature val_ref;
15637         CHECK((*env)->GetArrayLength(env, val) == 64);
15638         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15639         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
15640 }
15641
15642 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15643         LDKAnnouncementSignatures this_ptr_conv;
15644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15645         this_ptr_conv.is_owned = false;
15646         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15647         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
15648         return ret_arr;
15649 }
15650
15651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15652         LDKAnnouncementSignatures this_ptr_conv;
15653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15654         this_ptr_conv.is_owned = false;
15655         LDKSignature val_ref;
15656         CHECK((*env)->GetArrayLength(env, val) == 64);
15657         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15658         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
15659 }
15660
15661 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) {
15662         LDKThirtyTwoBytes channel_id_arg_ref;
15663         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
15664         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
15665         LDKSignature node_signature_arg_ref;
15666         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
15667         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
15668         LDKSignature bitcoin_signature_arg_ref;
15669         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
15670         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
15671         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
15672         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15673         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15674         long ret_ref = (long)ret_var.inner;
15675         if (ret_var.is_owned) {
15676                 ret_ref |= 1;
15677         }
15678         return ret_ref;
15679 }
15680
15681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15682         LDKAnnouncementSignatures orig_conv;
15683         orig_conv.inner = (void*)(orig & (~1));
15684         orig_conv.is_owned = false;
15685         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
15686         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15687         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15688         long ret_ref = (long)ret_var.inner;
15689         if (ret_var.is_owned) {
15690                 ret_ref |= 1;
15691         }
15692         return ret_ref;
15693 }
15694
15695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15696         if ((this_ptr & 1) != 0) return;
15697         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
15698         FREE((void*)this_ptr);
15699         NetAddress_free(this_ptr_conv);
15700 }
15701
15702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15703         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
15704         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
15705         *ret_copy = NetAddress_clone(orig_conv);
15706         long ret_ref = (long)ret_copy;
15707         return ret_ref;
15708 }
15709
15710 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
15711         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
15712         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
15713         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15714         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15715         CVec_u8Z_free(ret_var);
15716         return ret_arr;
15717 }
15718
15719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15720         LDKu8slice ser_ref;
15721         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15722         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15723         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
15724         *ret_conv = Result_read(ser_ref);
15725         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15726         return (long)ret_conv;
15727 }
15728
15729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15730         LDKUnsignedNodeAnnouncement this_obj_conv;
15731         this_obj_conv.inner = (void*)(this_obj & (~1));
15732         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15733         UnsignedNodeAnnouncement_free(this_obj_conv);
15734 }
15735
15736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
15737         LDKUnsignedNodeAnnouncement this_ptr_conv;
15738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15739         this_ptr_conv.is_owned = false;
15740         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
15741         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15742         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15743         long ret_ref = (long)ret_var.inner;
15744         if (ret_var.is_owned) {
15745                 ret_ref |= 1;
15746         }
15747         return ret_ref;
15748 }
15749
15750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15751         LDKUnsignedNodeAnnouncement this_ptr_conv;
15752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15753         this_ptr_conv.is_owned = false;
15754         LDKNodeFeatures val_conv;
15755         val_conv.inner = (void*)(val & (~1));
15756         val_conv.is_owned = (val & 1) || (val == 0);
15757         val_conv = NodeFeatures_clone(&val_conv);
15758         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
15759 }
15760
15761 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
15762         LDKUnsignedNodeAnnouncement this_ptr_conv;
15763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15764         this_ptr_conv.is_owned = false;
15765         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
15766         return ret_val;
15767 }
15768
15769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15770         LDKUnsignedNodeAnnouncement this_ptr_conv;
15771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15772         this_ptr_conv.is_owned = false;
15773         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
15774 }
15775
15776 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15777         LDKUnsignedNodeAnnouncement this_ptr_conv;
15778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15779         this_ptr_conv.is_owned = false;
15780         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15781         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
15782         return ret_arr;
15783 }
15784
15785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15786         LDKUnsignedNodeAnnouncement this_ptr_conv;
15787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15788         this_ptr_conv.is_owned = false;
15789         LDKPublicKey val_ref;
15790         CHECK((*env)->GetArrayLength(env, val) == 33);
15791         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15792         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
15793 }
15794
15795 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
15796         LDKUnsignedNodeAnnouncement this_ptr_conv;
15797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15798         this_ptr_conv.is_owned = false;
15799         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
15800         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
15801         return ret_arr;
15802 }
15803
15804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15805         LDKUnsignedNodeAnnouncement this_ptr_conv;
15806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15807         this_ptr_conv.is_owned = false;
15808         LDKThreeBytes val_ref;
15809         CHECK((*env)->GetArrayLength(env, val) == 3);
15810         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
15811         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
15812 }
15813
15814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
15815         LDKUnsignedNodeAnnouncement this_ptr_conv;
15816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15817         this_ptr_conv.is_owned = false;
15818         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15819         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
15820         return ret_arr;
15821 }
15822
15823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15824         LDKUnsignedNodeAnnouncement this_ptr_conv;
15825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15826         this_ptr_conv.is_owned = false;
15827         LDKThirtyTwoBytes val_ref;
15828         CHECK((*env)->GetArrayLength(env, val) == 32);
15829         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15830         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
15831 }
15832
15833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
15834         LDKUnsignedNodeAnnouncement this_ptr_conv;
15835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15836         this_ptr_conv.is_owned = false;
15837         LDKCVec_NetAddressZ val_constr;
15838         val_constr.datalen = (*env)->GetArrayLength(env, val);
15839         if (val_constr.datalen > 0)
15840                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15841         else
15842                 val_constr.data = NULL;
15843         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
15844         for (size_t m = 0; m < val_constr.datalen; m++) {
15845                 int64_t val_conv_12 = val_vals[m];
15846                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
15847                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
15848                 val_constr.data[m] = val_conv_12_conv;
15849         }
15850         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
15851         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
15852 }
15853
15854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15855         LDKUnsignedNodeAnnouncement orig_conv;
15856         orig_conv.inner = (void*)(orig & (~1));
15857         orig_conv.is_owned = false;
15858         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
15859         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15860         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15861         long ret_ref = (long)ret_var.inner;
15862         if (ret_var.is_owned) {
15863                 ret_ref |= 1;
15864         }
15865         return ret_ref;
15866 }
15867
15868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15869         LDKNodeAnnouncement this_obj_conv;
15870         this_obj_conv.inner = (void*)(this_obj & (~1));
15871         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15872         NodeAnnouncement_free(this_obj_conv);
15873 }
15874
15875 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15876         LDKNodeAnnouncement this_ptr_conv;
15877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15878         this_ptr_conv.is_owned = false;
15879         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15880         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
15881         return ret_arr;
15882 }
15883
15884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15885         LDKNodeAnnouncement this_ptr_conv;
15886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15887         this_ptr_conv.is_owned = false;
15888         LDKSignature val_ref;
15889         CHECK((*env)->GetArrayLength(env, val) == 64);
15890         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15891         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
15892 }
15893
15894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
15895         LDKNodeAnnouncement this_ptr_conv;
15896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15897         this_ptr_conv.is_owned = false;
15898         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
15899         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15900         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15901         long ret_ref = (long)ret_var.inner;
15902         if (ret_var.is_owned) {
15903                 ret_ref |= 1;
15904         }
15905         return ret_ref;
15906 }
15907
15908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15909         LDKNodeAnnouncement this_ptr_conv;
15910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15911         this_ptr_conv.is_owned = false;
15912         LDKUnsignedNodeAnnouncement val_conv;
15913         val_conv.inner = (void*)(val & (~1));
15914         val_conv.is_owned = (val & 1) || (val == 0);
15915         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
15916         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
15917 }
15918
15919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
15920         LDKSignature signature_arg_ref;
15921         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
15922         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
15923         LDKUnsignedNodeAnnouncement contents_arg_conv;
15924         contents_arg_conv.inner = (void*)(contents_arg & (~1));
15925         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
15926         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
15927         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
15928         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15929         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15930         long ret_ref = (long)ret_var.inner;
15931         if (ret_var.is_owned) {
15932                 ret_ref |= 1;
15933         }
15934         return ret_ref;
15935 }
15936
15937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15938         LDKNodeAnnouncement orig_conv;
15939         orig_conv.inner = (void*)(orig & (~1));
15940         orig_conv.is_owned = false;
15941         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
15942         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15943         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15944         long ret_ref = (long)ret_var.inner;
15945         if (ret_var.is_owned) {
15946                 ret_ref |= 1;
15947         }
15948         return ret_ref;
15949 }
15950
15951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15952         LDKUnsignedChannelAnnouncement this_obj_conv;
15953         this_obj_conv.inner = (void*)(this_obj & (~1));
15954         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15955         UnsignedChannelAnnouncement_free(this_obj_conv);
15956 }
15957
15958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
15959         LDKUnsignedChannelAnnouncement this_ptr_conv;
15960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15961         this_ptr_conv.is_owned = false;
15962         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
15963         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15964         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15965         long ret_ref = (long)ret_var.inner;
15966         if (ret_var.is_owned) {
15967                 ret_ref |= 1;
15968         }
15969         return ret_ref;
15970 }
15971
15972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15973         LDKUnsignedChannelAnnouncement this_ptr_conv;
15974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15975         this_ptr_conv.is_owned = false;
15976         LDKChannelFeatures val_conv;
15977         val_conv.inner = (void*)(val & (~1));
15978         val_conv.is_owned = (val & 1) || (val == 0);
15979         val_conv = ChannelFeatures_clone(&val_conv);
15980         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
15981 }
15982
15983 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15984         LDKUnsignedChannelAnnouncement this_ptr_conv;
15985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15986         this_ptr_conv.is_owned = false;
15987         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15988         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
15989         return ret_arr;
15990 }
15991
15992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15993         LDKUnsignedChannelAnnouncement this_ptr_conv;
15994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15995         this_ptr_conv.is_owned = false;
15996         LDKThirtyTwoBytes val_ref;
15997         CHECK((*env)->GetArrayLength(env, val) == 32);
15998         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15999         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
16000 }
16001
16002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16003         LDKUnsignedChannelAnnouncement this_ptr_conv;
16004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16005         this_ptr_conv.is_owned = false;
16006         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
16007         return ret_val;
16008 }
16009
16010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16011         LDKUnsignedChannelAnnouncement this_ptr_conv;
16012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16013         this_ptr_conv.is_owned = false;
16014         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
16015 }
16016
16017 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
16018         LDKUnsignedChannelAnnouncement this_ptr_conv;
16019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16020         this_ptr_conv.is_owned = false;
16021         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16022         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
16023         return ret_arr;
16024 }
16025
16026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16027         LDKUnsignedChannelAnnouncement this_ptr_conv;
16028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16029         this_ptr_conv.is_owned = false;
16030         LDKPublicKey val_ref;
16031         CHECK((*env)->GetArrayLength(env, val) == 33);
16032         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16033         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
16034 }
16035
16036 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
16037         LDKUnsignedChannelAnnouncement this_ptr_conv;
16038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16039         this_ptr_conv.is_owned = false;
16040         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16041         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
16042         return ret_arr;
16043 }
16044
16045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16046         LDKUnsignedChannelAnnouncement this_ptr_conv;
16047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16048         this_ptr_conv.is_owned = false;
16049         LDKPublicKey val_ref;
16050         CHECK((*env)->GetArrayLength(env, val) == 33);
16051         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16052         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
16053 }
16054
16055 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
16056         LDKUnsignedChannelAnnouncement this_ptr_conv;
16057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16058         this_ptr_conv.is_owned = false;
16059         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16060         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
16061         return ret_arr;
16062 }
16063
16064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16065         LDKUnsignedChannelAnnouncement this_ptr_conv;
16066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16067         this_ptr_conv.is_owned = false;
16068         LDKPublicKey val_ref;
16069         CHECK((*env)->GetArrayLength(env, val) == 33);
16070         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16071         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
16072 }
16073
16074 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
16075         LDKUnsignedChannelAnnouncement this_ptr_conv;
16076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16077         this_ptr_conv.is_owned = false;
16078         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16079         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
16080         return ret_arr;
16081 }
16082
16083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16084         LDKUnsignedChannelAnnouncement this_ptr_conv;
16085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16086         this_ptr_conv.is_owned = false;
16087         LDKPublicKey val_ref;
16088         CHECK((*env)->GetArrayLength(env, val) == 33);
16089         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16090         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
16091 }
16092
16093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16094         LDKUnsignedChannelAnnouncement orig_conv;
16095         orig_conv.inner = (void*)(orig & (~1));
16096         orig_conv.is_owned = false;
16097         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
16098         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16099         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16100         long ret_ref = (long)ret_var.inner;
16101         if (ret_var.is_owned) {
16102                 ret_ref |= 1;
16103         }
16104         return ret_ref;
16105 }
16106
16107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16108         LDKChannelAnnouncement this_obj_conv;
16109         this_obj_conv.inner = (void*)(this_obj & (~1));
16110         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16111         ChannelAnnouncement_free(this_obj_conv);
16112 }
16113
16114 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
16115         LDKChannelAnnouncement this_ptr_conv;
16116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16117         this_ptr_conv.is_owned = false;
16118         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
16119         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
16120         return ret_arr;
16121 }
16122
16123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16124         LDKChannelAnnouncement this_ptr_conv;
16125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16126         this_ptr_conv.is_owned = false;
16127         LDKSignature val_ref;
16128         CHECK((*env)->GetArrayLength(env, val) == 64);
16129         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
16130         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
16131 }
16132
16133 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
16134         LDKChannelAnnouncement this_ptr_conv;
16135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16136         this_ptr_conv.is_owned = false;
16137         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
16138         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
16139         return ret_arr;
16140 }
16141
16142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16143         LDKChannelAnnouncement this_ptr_conv;
16144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16145         this_ptr_conv.is_owned = false;
16146         LDKSignature val_ref;
16147         CHECK((*env)->GetArrayLength(env, val) == 64);
16148         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
16149         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
16150 }
16151
16152 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
16153         LDKChannelAnnouncement this_ptr_conv;
16154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16155         this_ptr_conv.is_owned = false;
16156         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
16157         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
16158         return ret_arr;
16159 }
16160
16161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16162         LDKChannelAnnouncement this_ptr_conv;
16163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16164         this_ptr_conv.is_owned = false;
16165         LDKSignature val_ref;
16166         CHECK((*env)->GetArrayLength(env, val) == 64);
16167         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
16168         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
16169 }
16170
16171 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
16172         LDKChannelAnnouncement this_ptr_conv;
16173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16174         this_ptr_conv.is_owned = false;
16175         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
16176         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
16177         return ret_arr;
16178 }
16179
16180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16181         LDKChannelAnnouncement this_ptr_conv;
16182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16183         this_ptr_conv.is_owned = false;
16184         LDKSignature val_ref;
16185         CHECK((*env)->GetArrayLength(env, val) == 64);
16186         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
16187         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
16188 }
16189
16190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
16191         LDKChannelAnnouncement this_ptr_conv;
16192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16193         this_ptr_conv.is_owned = false;
16194         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
16195         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16196         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16197         long ret_ref = (long)ret_var.inner;
16198         if (ret_var.is_owned) {
16199                 ret_ref |= 1;
16200         }
16201         return ret_ref;
16202 }
16203
16204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16205         LDKChannelAnnouncement this_ptr_conv;
16206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16207         this_ptr_conv.is_owned = false;
16208         LDKUnsignedChannelAnnouncement val_conv;
16209         val_conv.inner = (void*)(val & (~1));
16210         val_conv.is_owned = (val & 1) || (val == 0);
16211         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
16212         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
16213 }
16214
16215 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) {
16216         LDKSignature node_signature_1_arg_ref;
16217         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
16218         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
16219         LDKSignature node_signature_2_arg_ref;
16220         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
16221         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
16222         LDKSignature bitcoin_signature_1_arg_ref;
16223         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
16224         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
16225         LDKSignature bitcoin_signature_2_arg_ref;
16226         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
16227         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
16228         LDKUnsignedChannelAnnouncement contents_arg_conv;
16229         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16230         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16231         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
16232         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);
16233         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16234         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16235         long ret_ref = (long)ret_var.inner;
16236         if (ret_var.is_owned) {
16237                 ret_ref |= 1;
16238         }
16239         return ret_ref;
16240 }
16241
16242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16243         LDKChannelAnnouncement orig_conv;
16244         orig_conv.inner = (void*)(orig & (~1));
16245         orig_conv.is_owned = false;
16246         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
16247         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16248         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16249         long ret_ref = (long)ret_var.inner;
16250         if (ret_var.is_owned) {
16251                 ret_ref |= 1;
16252         }
16253         return ret_ref;
16254 }
16255
16256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16257         LDKUnsignedChannelUpdate this_obj_conv;
16258         this_obj_conv.inner = (void*)(this_obj & (~1));
16259         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16260         UnsignedChannelUpdate_free(this_obj_conv);
16261 }
16262
16263 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16264         LDKUnsignedChannelUpdate this_ptr_conv;
16265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16266         this_ptr_conv.is_owned = false;
16267         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16268         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
16269         return ret_arr;
16270 }
16271
16272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16273         LDKUnsignedChannelUpdate this_ptr_conv;
16274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16275         this_ptr_conv.is_owned = false;
16276         LDKThirtyTwoBytes val_ref;
16277         CHECK((*env)->GetArrayLength(env, val) == 32);
16278         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16279         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
16280 }
16281
16282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16283         LDKUnsignedChannelUpdate this_ptr_conv;
16284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16285         this_ptr_conv.is_owned = false;
16286         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
16287         return ret_val;
16288 }
16289
16290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16291         LDKUnsignedChannelUpdate this_ptr_conv;
16292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16293         this_ptr_conv.is_owned = false;
16294         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
16295 }
16296
16297 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
16298         LDKUnsignedChannelUpdate this_ptr_conv;
16299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16300         this_ptr_conv.is_owned = false;
16301         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
16302         return ret_val;
16303 }
16304
16305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16306         LDKUnsignedChannelUpdate this_ptr_conv;
16307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16308         this_ptr_conv.is_owned = false;
16309         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
16310 }
16311
16312 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
16313         LDKUnsignedChannelUpdate this_ptr_conv;
16314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16315         this_ptr_conv.is_owned = false;
16316         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
16317         return ret_val;
16318 }
16319
16320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
16321         LDKUnsignedChannelUpdate this_ptr_conv;
16322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16323         this_ptr_conv.is_owned = false;
16324         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
16325 }
16326
16327 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
16328         LDKUnsignedChannelUpdate this_ptr_conv;
16329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16330         this_ptr_conv.is_owned = false;
16331         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
16332         return ret_val;
16333 }
16334
16335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16336         LDKUnsignedChannelUpdate this_ptr_conv;
16337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16338         this_ptr_conv.is_owned = false;
16339         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
16340 }
16341
16342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16343         LDKUnsignedChannelUpdate this_ptr_conv;
16344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16345         this_ptr_conv.is_owned = false;
16346         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
16347         return ret_val;
16348 }
16349
16350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16351         LDKUnsignedChannelUpdate this_ptr_conv;
16352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16353         this_ptr_conv.is_owned = false;
16354         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
16355 }
16356
16357 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16358         LDKUnsignedChannelUpdate this_ptr_conv;
16359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16360         this_ptr_conv.is_owned = false;
16361         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
16362         return ret_val;
16363 }
16364
16365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16366         LDKUnsignedChannelUpdate this_ptr_conv;
16367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16368         this_ptr_conv.is_owned = false;
16369         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
16370 }
16371
16372 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
16373         LDKUnsignedChannelUpdate this_ptr_conv;
16374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16375         this_ptr_conv.is_owned = false;
16376         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
16377         return ret_val;
16378 }
16379
16380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16381         LDKUnsignedChannelUpdate this_ptr_conv;
16382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16383         this_ptr_conv.is_owned = false;
16384         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
16385 }
16386
16387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16388         LDKUnsignedChannelUpdate orig_conv;
16389         orig_conv.inner = (void*)(orig & (~1));
16390         orig_conv.is_owned = false;
16391         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
16392         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16393         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16394         long ret_ref = (long)ret_var.inner;
16395         if (ret_var.is_owned) {
16396                 ret_ref |= 1;
16397         }
16398         return ret_ref;
16399 }
16400
16401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16402         LDKChannelUpdate this_obj_conv;
16403         this_obj_conv.inner = (void*)(this_obj & (~1));
16404         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16405         ChannelUpdate_free(this_obj_conv);
16406 }
16407
16408 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
16409         LDKChannelUpdate this_ptr_conv;
16410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16411         this_ptr_conv.is_owned = false;
16412         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
16413         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
16414         return ret_arr;
16415 }
16416
16417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16418         LDKChannelUpdate this_ptr_conv;
16419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16420         this_ptr_conv.is_owned = false;
16421         LDKSignature val_ref;
16422         CHECK((*env)->GetArrayLength(env, val) == 64);
16423         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
16424         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
16425 }
16426
16427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
16428         LDKChannelUpdate this_ptr_conv;
16429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16430         this_ptr_conv.is_owned = false;
16431         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
16432         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16433         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16434         long ret_ref = (long)ret_var.inner;
16435         if (ret_var.is_owned) {
16436                 ret_ref |= 1;
16437         }
16438         return ret_ref;
16439 }
16440
16441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16442         LDKChannelUpdate this_ptr_conv;
16443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16444         this_ptr_conv.is_owned = false;
16445         LDKUnsignedChannelUpdate val_conv;
16446         val_conv.inner = (void*)(val & (~1));
16447         val_conv.is_owned = (val & 1) || (val == 0);
16448         val_conv = UnsignedChannelUpdate_clone(&val_conv);
16449         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
16450 }
16451
16452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
16453         LDKSignature signature_arg_ref;
16454         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
16455         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
16456         LDKUnsignedChannelUpdate contents_arg_conv;
16457         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16458         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16459         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
16460         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
16461         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16462         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16463         long ret_ref = (long)ret_var.inner;
16464         if (ret_var.is_owned) {
16465                 ret_ref |= 1;
16466         }
16467         return ret_ref;
16468 }
16469
16470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16471         LDKChannelUpdate orig_conv;
16472         orig_conv.inner = (void*)(orig & (~1));
16473         orig_conv.is_owned = false;
16474         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
16475         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16476         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16477         long ret_ref = (long)ret_var.inner;
16478         if (ret_var.is_owned) {
16479                 ret_ref |= 1;
16480         }
16481         return ret_ref;
16482 }
16483
16484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16485         LDKQueryChannelRange this_obj_conv;
16486         this_obj_conv.inner = (void*)(this_obj & (~1));
16487         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16488         QueryChannelRange_free(this_obj_conv);
16489 }
16490
16491 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16492         LDKQueryChannelRange this_ptr_conv;
16493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16494         this_ptr_conv.is_owned = false;
16495         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16496         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
16497         return ret_arr;
16498 }
16499
16500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16501         LDKQueryChannelRange this_ptr_conv;
16502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16503         this_ptr_conv.is_owned = false;
16504         LDKThirtyTwoBytes val_ref;
16505         CHECK((*env)->GetArrayLength(env, val) == 32);
16506         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16507         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
16508 }
16509
16510 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
16511         LDKQueryChannelRange this_ptr_conv;
16512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16513         this_ptr_conv.is_owned = false;
16514         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
16515         return ret_val;
16516 }
16517
16518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16519         LDKQueryChannelRange this_ptr_conv;
16520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16521         this_ptr_conv.is_owned = false;
16522         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
16523 }
16524
16525 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
16526         LDKQueryChannelRange this_ptr_conv;
16527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16528         this_ptr_conv.is_owned = false;
16529         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
16530         return ret_val;
16531 }
16532
16533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16534         LDKQueryChannelRange this_ptr_conv;
16535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16536         this_ptr_conv.is_owned = false;
16537         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
16538 }
16539
16540 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) {
16541         LDKThirtyTwoBytes chain_hash_arg_ref;
16542         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16543         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16544         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
16545         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16546         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16547         long ret_ref = (long)ret_var.inner;
16548         if (ret_var.is_owned) {
16549                 ret_ref |= 1;
16550         }
16551         return ret_ref;
16552 }
16553
16554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16555         LDKQueryChannelRange orig_conv;
16556         orig_conv.inner = (void*)(orig & (~1));
16557         orig_conv.is_owned = false;
16558         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
16559         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16560         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16561         long ret_ref = (long)ret_var.inner;
16562         if (ret_var.is_owned) {
16563                 ret_ref |= 1;
16564         }
16565         return ret_ref;
16566 }
16567
16568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16569         LDKReplyChannelRange this_obj_conv;
16570         this_obj_conv.inner = (void*)(this_obj & (~1));
16571         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16572         ReplyChannelRange_free(this_obj_conv);
16573 }
16574
16575 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16576         LDKReplyChannelRange this_ptr_conv;
16577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16578         this_ptr_conv.is_owned = false;
16579         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16580         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
16581         return ret_arr;
16582 }
16583
16584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16585         LDKReplyChannelRange this_ptr_conv;
16586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16587         this_ptr_conv.is_owned = false;
16588         LDKThirtyTwoBytes val_ref;
16589         CHECK((*env)->GetArrayLength(env, val) == 32);
16590         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16591         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
16592 }
16593
16594 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
16595         LDKReplyChannelRange this_ptr_conv;
16596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16597         this_ptr_conv.is_owned = false;
16598         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
16599         return ret_val;
16600 }
16601
16602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16603         LDKReplyChannelRange this_ptr_conv;
16604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16605         this_ptr_conv.is_owned = false;
16606         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
16607 }
16608
16609 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
16610         LDKReplyChannelRange this_ptr_conv;
16611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16612         this_ptr_conv.is_owned = false;
16613         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
16614         return ret_val;
16615 }
16616
16617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16618         LDKReplyChannelRange this_ptr_conv;
16619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16620         this_ptr_conv.is_owned = false;
16621         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
16622 }
16623
16624 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
16625         LDKReplyChannelRange this_ptr_conv;
16626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16627         this_ptr_conv.is_owned = false;
16628         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
16629         return ret_val;
16630 }
16631
16632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16633         LDKReplyChannelRange this_ptr_conv;
16634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16635         this_ptr_conv.is_owned = false;
16636         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
16637 }
16638
16639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16640         LDKReplyChannelRange this_ptr_conv;
16641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16642         this_ptr_conv.is_owned = false;
16643         LDKCVec_u64Z val_constr;
16644         val_constr.datalen = (*env)->GetArrayLength(env, val);
16645         if (val_constr.datalen > 0)
16646                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16647         else
16648                 val_constr.data = NULL;
16649         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16650         for (size_t g = 0; g < val_constr.datalen; g++) {
16651                 int64_t val_conv_6 = val_vals[g];
16652                 val_constr.data[g] = val_conv_6;
16653         }
16654         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16655         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
16656 }
16657
16658 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) {
16659         LDKThirtyTwoBytes chain_hash_arg_ref;
16660         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16661         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16662         LDKCVec_u64Z short_channel_ids_arg_constr;
16663         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
16664         if (short_channel_ids_arg_constr.datalen > 0)
16665                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16666         else
16667                 short_channel_ids_arg_constr.data = NULL;
16668         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
16669         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
16670                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
16671                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
16672         }
16673         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
16674         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
16675         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16676         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16677         long ret_ref = (long)ret_var.inner;
16678         if (ret_var.is_owned) {
16679                 ret_ref |= 1;
16680         }
16681         return ret_ref;
16682 }
16683
16684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16685         LDKReplyChannelRange orig_conv;
16686         orig_conv.inner = (void*)(orig & (~1));
16687         orig_conv.is_owned = false;
16688         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
16689         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16690         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16691         long ret_ref = (long)ret_var.inner;
16692         if (ret_var.is_owned) {
16693                 ret_ref |= 1;
16694         }
16695         return ret_ref;
16696 }
16697
16698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16699         LDKQueryShortChannelIds this_obj_conv;
16700         this_obj_conv.inner = (void*)(this_obj & (~1));
16701         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16702         QueryShortChannelIds_free(this_obj_conv);
16703 }
16704
16705 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16706         LDKQueryShortChannelIds this_ptr_conv;
16707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16708         this_ptr_conv.is_owned = false;
16709         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16710         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
16711         return ret_arr;
16712 }
16713
16714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16715         LDKQueryShortChannelIds this_ptr_conv;
16716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16717         this_ptr_conv.is_owned = false;
16718         LDKThirtyTwoBytes val_ref;
16719         CHECK((*env)->GetArrayLength(env, val) == 32);
16720         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16721         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
16722 }
16723
16724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16725         LDKQueryShortChannelIds this_ptr_conv;
16726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16727         this_ptr_conv.is_owned = false;
16728         LDKCVec_u64Z val_constr;
16729         val_constr.datalen = (*env)->GetArrayLength(env, val);
16730         if (val_constr.datalen > 0)
16731                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16732         else
16733                 val_constr.data = NULL;
16734         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16735         for (size_t g = 0; g < val_constr.datalen; g++) {
16736                 int64_t val_conv_6 = val_vals[g];
16737                 val_constr.data[g] = val_conv_6;
16738         }
16739         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16740         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
16741 }
16742
16743 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) {
16744         LDKThirtyTwoBytes chain_hash_arg_ref;
16745         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16746         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16747         LDKCVec_u64Z short_channel_ids_arg_constr;
16748         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
16749         if (short_channel_ids_arg_constr.datalen > 0)
16750                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16751         else
16752                 short_channel_ids_arg_constr.data = NULL;
16753         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
16754         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
16755                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
16756                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
16757         }
16758         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
16759         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
16760         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16761         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16762         long ret_ref = (long)ret_var.inner;
16763         if (ret_var.is_owned) {
16764                 ret_ref |= 1;
16765         }
16766         return ret_ref;
16767 }
16768
16769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16770         LDKQueryShortChannelIds orig_conv;
16771         orig_conv.inner = (void*)(orig & (~1));
16772         orig_conv.is_owned = false;
16773         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
16774         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16775         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16776         long ret_ref = (long)ret_var.inner;
16777         if (ret_var.is_owned) {
16778                 ret_ref |= 1;
16779         }
16780         return ret_ref;
16781 }
16782
16783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16784         LDKReplyShortChannelIdsEnd this_obj_conv;
16785         this_obj_conv.inner = (void*)(this_obj & (~1));
16786         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16787         ReplyShortChannelIdsEnd_free(this_obj_conv);
16788 }
16789
16790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16791         LDKReplyShortChannelIdsEnd this_ptr_conv;
16792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16793         this_ptr_conv.is_owned = false;
16794         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16795         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
16796         return ret_arr;
16797 }
16798
16799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16800         LDKReplyShortChannelIdsEnd this_ptr_conv;
16801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16802         this_ptr_conv.is_owned = false;
16803         LDKThirtyTwoBytes val_ref;
16804         CHECK((*env)->GetArrayLength(env, val) == 32);
16805         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16806         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
16807 }
16808
16809 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
16810         LDKReplyShortChannelIdsEnd this_ptr_conv;
16811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16812         this_ptr_conv.is_owned = false;
16813         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
16814         return ret_val;
16815 }
16816
16817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16818         LDKReplyShortChannelIdsEnd this_ptr_conv;
16819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16820         this_ptr_conv.is_owned = false;
16821         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
16822 }
16823
16824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
16825         LDKThirtyTwoBytes chain_hash_arg_ref;
16826         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16827         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16828         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
16829         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16830         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16831         long ret_ref = (long)ret_var.inner;
16832         if (ret_var.is_owned) {
16833                 ret_ref |= 1;
16834         }
16835         return ret_ref;
16836 }
16837
16838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16839         LDKReplyShortChannelIdsEnd orig_conv;
16840         orig_conv.inner = (void*)(orig & (~1));
16841         orig_conv.is_owned = false;
16842         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
16843         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16844         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16845         long ret_ref = (long)ret_var.inner;
16846         if (ret_var.is_owned) {
16847                 ret_ref |= 1;
16848         }
16849         return ret_ref;
16850 }
16851
16852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16853         LDKGossipTimestampFilter this_obj_conv;
16854         this_obj_conv.inner = (void*)(this_obj & (~1));
16855         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16856         GossipTimestampFilter_free(this_obj_conv);
16857 }
16858
16859 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16860         LDKGossipTimestampFilter this_ptr_conv;
16861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16862         this_ptr_conv.is_owned = false;
16863         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16864         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
16865         return ret_arr;
16866 }
16867
16868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16869         LDKGossipTimestampFilter this_ptr_conv;
16870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16871         this_ptr_conv.is_owned = false;
16872         LDKThirtyTwoBytes val_ref;
16873         CHECK((*env)->GetArrayLength(env, val) == 32);
16874         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16875         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
16876 }
16877
16878 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
16879         LDKGossipTimestampFilter this_ptr_conv;
16880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16881         this_ptr_conv.is_owned = false;
16882         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
16883         return ret_val;
16884 }
16885
16886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16887         LDKGossipTimestampFilter this_ptr_conv;
16888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16889         this_ptr_conv.is_owned = false;
16890         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
16891 }
16892
16893 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
16894         LDKGossipTimestampFilter this_ptr_conv;
16895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16896         this_ptr_conv.is_owned = false;
16897         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
16898         return ret_val;
16899 }
16900
16901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16902         LDKGossipTimestampFilter this_ptr_conv;
16903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16904         this_ptr_conv.is_owned = false;
16905         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
16906 }
16907
16908 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) {
16909         LDKThirtyTwoBytes chain_hash_arg_ref;
16910         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16911         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16912         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
16913         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16914         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16915         long ret_ref = (long)ret_var.inner;
16916         if (ret_var.is_owned) {
16917                 ret_ref |= 1;
16918         }
16919         return ret_ref;
16920 }
16921
16922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16923         LDKGossipTimestampFilter orig_conv;
16924         orig_conv.inner = (void*)(orig & (~1));
16925         orig_conv.is_owned = false;
16926         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
16927         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16928         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16929         long ret_ref = (long)ret_var.inner;
16930         if (ret_var.is_owned) {
16931                 ret_ref |= 1;
16932         }
16933         return ret_ref;
16934 }
16935
16936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16937         if ((this_ptr & 1) != 0) return;
16938         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
16939         FREE((void*)this_ptr);
16940         ErrorAction_free(this_ptr_conv);
16941 }
16942
16943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16944         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
16945         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
16946         *ret_copy = ErrorAction_clone(orig_conv);
16947         long ret_ref = (long)ret_copy;
16948         return ret_ref;
16949 }
16950
16951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16952         LDKLightningError this_obj_conv;
16953         this_obj_conv.inner = (void*)(this_obj & (~1));
16954         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16955         LightningError_free(this_obj_conv);
16956 }
16957
16958 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
16959         LDKLightningError this_ptr_conv;
16960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16961         this_ptr_conv.is_owned = false;
16962         LDKStr _str = LightningError_get_err(&this_ptr_conv);
16963         jstring _conv = str_ref_to_java(env, _str.chars, _str.len);
16964         return _conv;
16965 }
16966
16967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16968         LDKLightningError this_ptr_conv;
16969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16970         this_ptr_conv.is_owned = false;
16971         LDKCVec_u8Z val_ref;
16972         val_ref.datalen = (*env)->GetArrayLength(env, val);
16973         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
16974         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
16975         LightningError_set_err(&this_ptr_conv, val_ref);
16976 }
16977
16978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
16979         LDKLightningError this_ptr_conv;
16980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16981         this_ptr_conv.is_owned = false;
16982         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
16983         *ret_copy = LightningError_get_action(&this_ptr_conv);
16984         long ret_ref = (long)ret_copy;
16985         return ret_ref;
16986 }
16987
16988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16989         LDKLightningError this_ptr_conv;
16990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16991         this_ptr_conv.is_owned = false;
16992         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
16993         FREE((void*)val);
16994         LightningError_set_action(&this_ptr_conv, val_conv);
16995 }
16996
16997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, int8_tArray err_arg, int64_t action_arg) {
16998         LDKCVec_u8Z err_arg_ref;
16999         err_arg_ref.datalen = (*env)->GetArrayLength(env, err_arg);
17000         err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
17001         (*env)->GetByteArrayRegion(env, err_arg, 0, err_arg_ref.datalen, err_arg_ref.data);
17002         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
17003         FREE((void*)action_arg);
17004         LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
17005         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17006         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17007         long ret_ref = (long)ret_var.inner;
17008         if (ret_var.is_owned) {
17009                 ret_ref |= 1;
17010         }
17011         return ret_ref;
17012 }
17013
17014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17015         LDKLightningError orig_conv;
17016         orig_conv.inner = (void*)(orig & (~1));
17017         orig_conv.is_owned = false;
17018         LDKLightningError ret_var = LightningError_clone(&orig_conv);
17019         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17020         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17021         long ret_ref = (long)ret_var.inner;
17022         if (ret_var.is_owned) {
17023                 ret_ref |= 1;
17024         }
17025         return ret_ref;
17026 }
17027
17028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17029         LDKCommitmentUpdate this_obj_conv;
17030         this_obj_conv.inner = (void*)(this_obj & (~1));
17031         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17032         CommitmentUpdate_free(this_obj_conv);
17033 }
17034
17035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
17036         LDKCommitmentUpdate this_ptr_conv;
17037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17038         this_ptr_conv.is_owned = false;
17039         LDKCVec_UpdateAddHTLCZ val_constr;
17040         val_constr.datalen = (*env)->GetArrayLength(env, val);
17041         if (val_constr.datalen > 0)
17042                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17043         else
17044                 val_constr.data = NULL;
17045         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
17046         for (size_t p = 0; p < val_constr.datalen; p++) {
17047                 int64_t val_conv_15 = val_vals[p];
17048                 LDKUpdateAddHTLC val_conv_15_conv;
17049                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
17050                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
17051                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
17052                 val_constr.data[p] = val_conv_15_conv;
17053         }
17054         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
17055         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
17056 }
17057
17058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
17059         LDKCommitmentUpdate this_ptr_conv;
17060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17061         this_ptr_conv.is_owned = false;
17062         LDKCVec_UpdateFulfillHTLCZ val_constr;
17063         val_constr.datalen = (*env)->GetArrayLength(env, val);
17064         if (val_constr.datalen > 0)
17065                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17066         else
17067                 val_constr.data = NULL;
17068         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
17069         for (size_t t = 0; t < val_constr.datalen; t++) {
17070                 int64_t val_conv_19 = val_vals[t];
17071                 LDKUpdateFulfillHTLC val_conv_19_conv;
17072                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
17073                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
17074                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
17075                 val_constr.data[t] = val_conv_19_conv;
17076         }
17077         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
17078         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
17079 }
17080
17081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
17082         LDKCommitmentUpdate this_ptr_conv;
17083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17084         this_ptr_conv.is_owned = false;
17085         LDKCVec_UpdateFailHTLCZ val_constr;
17086         val_constr.datalen = (*env)->GetArrayLength(env, val);
17087         if (val_constr.datalen > 0)
17088                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17089         else
17090                 val_constr.data = NULL;
17091         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
17092         for (size_t q = 0; q < val_constr.datalen; q++) {
17093                 int64_t val_conv_16 = val_vals[q];
17094                 LDKUpdateFailHTLC val_conv_16_conv;
17095                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
17096                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
17097                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
17098                 val_constr.data[q] = val_conv_16_conv;
17099         }
17100         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
17101         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
17102 }
17103
17104 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) {
17105         LDKCommitmentUpdate this_ptr_conv;
17106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17107         this_ptr_conv.is_owned = false;
17108         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
17109         val_constr.datalen = (*env)->GetArrayLength(env, val);
17110         if (val_constr.datalen > 0)
17111                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17112         else
17113                 val_constr.data = NULL;
17114         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
17115         for (size_t z = 0; z < val_constr.datalen; z++) {
17116                 int64_t val_conv_25 = val_vals[z];
17117                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
17118                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
17119                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
17120                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
17121                 val_constr.data[z] = val_conv_25_conv;
17122         }
17123         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
17124         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
17125 }
17126
17127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
17128         LDKCommitmentUpdate this_ptr_conv;
17129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17130         this_ptr_conv.is_owned = false;
17131         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
17132         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17133         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17134         long ret_ref = (long)ret_var.inner;
17135         if (ret_var.is_owned) {
17136                 ret_ref |= 1;
17137         }
17138         return ret_ref;
17139 }
17140
17141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17142         LDKCommitmentUpdate this_ptr_conv;
17143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17144         this_ptr_conv.is_owned = false;
17145         LDKUpdateFee val_conv;
17146         val_conv.inner = (void*)(val & (~1));
17147         val_conv.is_owned = (val & 1) || (val == 0);
17148         val_conv = UpdateFee_clone(&val_conv);
17149         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
17150 }
17151
17152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
17153         LDKCommitmentUpdate this_ptr_conv;
17154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17155         this_ptr_conv.is_owned = false;
17156         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
17157         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17158         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17159         long ret_ref = (long)ret_var.inner;
17160         if (ret_var.is_owned) {
17161                 ret_ref |= 1;
17162         }
17163         return ret_ref;
17164 }
17165
17166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17167         LDKCommitmentUpdate this_ptr_conv;
17168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17169         this_ptr_conv.is_owned = false;
17170         LDKCommitmentSigned val_conv;
17171         val_conv.inner = (void*)(val & (~1));
17172         val_conv.is_owned = (val & 1) || (val == 0);
17173         val_conv = CommitmentSigned_clone(&val_conv);
17174         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
17175 }
17176
17177 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) {
17178         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
17179         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
17180         if (update_add_htlcs_arg_constr.datalen > 0)
17181                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17182         else
17183                 update_add_htlcs_arg_constr.data = NULL;
17184         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
17185         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
17186                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
17187                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
17188                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
17189                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
17190                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
17191                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
17192         }
17193         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
17194         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
17195         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
17196         if (update_fulfill_htlcs_arg_constr.datalen > 0)
17197                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17198         else
17199                 update_fulfill_htlcs_arg_constr.data = NULL;
17200         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
17201         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
17202                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
17203                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
17204                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
17205                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
17206                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
17207                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
17208         }
17209         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
17210         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
17211         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
17212         if (update_fail_htlcs_arg_constr.datalen > 0)
17213                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17214         else
17215                 update_fail_htlcs_arg_constr.data = NULL;
17216         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
17217         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
17218                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
17219                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
17220                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
17221                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
17222                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
17223                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
17224         }
17225         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
17226         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
17227         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
17228         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
17229                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17230         else
17231                 update_fail_malformed_htlcs_arg_constr.data = NULL;
17232         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
17233         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
17234                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
17235                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
17236                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
17237                 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);
17238                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
17239                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
17240         }
17241         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
17242         LDKUpdateFee update_fee_arg_conv;
17243         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
17244         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
17245         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
17246         LDKCommitmentSigned commitment_signed_arg_conv;
17247         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
17248         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
17249         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
17250         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);
17251         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17252         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17253         long ret_ref = (long)ret_var.inner;
17254         if (ret_var.is_owned) {
17255                 ret_ref |= 1;
17256         }
17257         return ret_ref;
17258 }
17259
17260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17261         LDKCommitmentUpdate orig_conv;
17262         orig_conv.inner = (void*)(orig & (~1));
17263         orig_conv.is_owned = false;
17264         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
17265         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17266         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17267         long ret_ref = (long)ret_var.inner;
17268         if (ret_var.is_owned) {
17269                 ret_ref |= 1;
17270         }
17271         return ret_ref;
17272 }
17273
17274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17275         if ((this_ptr & 1) != 0) return;
17276         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
17277         FREE((void*)this_ptr);
17278         HTLCFailChannelUpdate_free(this_ptr_conv);
17279 }
17280
17281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17282         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
17283         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
17284         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
17285         long ret_ref = (long)ret_copy;
17286         return ret_ref;
17287 }
17288
17289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17290         if ((this_ptr & 1) != 0) return;
17291         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
17292         FREE((void*)this_ptr);
17293         ChannelMessageHandler_free(this_ptr_conv);
17294 }
17295
17296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17297         if ((this_ptr & 1) != 0) return;
17298         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
17299         FREE((void*)this_ptr);
17300         RoutingMessageHandler_free(this_ptr_conv);
17301 }
17302
17303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
17304         LDKAcceptChannel obj_conv;
17305         obj_conv.inner = (void*)(obj & (~1));
17306         obj_conv.is_owned = false;
17307         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
17308         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17309         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17310         CVec_u8Z_free(ret_var);
17311         return ret_arr;
17312 }
17313
17314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17315         LDKu8slice ser_ref;
17316         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17317         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17318         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17319         *ret_conv = AcceptChannel_read(ser_ref);
17320         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17321         return (long)ret_conv;
17322 }
17323
17324 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
17325         LDKAnnouncementSignatures obj_conv;
17326         obj_conv.inner = (void*)(obj & (~1));
17327         obj_conv.is_owned = false;
17328         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
17329         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17330         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17331         CVec_u8Z_free(ret_var);
17332         return ret_arr;
17333 }
17334
17335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17336         LDKu8slice ser_ref;
17337         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17338         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17339         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17340         *ret_conv = AnnouncementSignatures_read(ser_ref);
17341         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17342         return (long)ret_conv;
17343 }
17344
17345 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
17346         LDKChannelReestablish obj_conv;
17347         obj_conv.inner = (void*)(obj & (~1));
17348         obj_conv.is_owned = false;
17349         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
17350         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17351         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17352         CVec_u8Z_free(ret_var);
17353         return ret_arr;
17354 }
17355
17356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17357         LDKu8slice ser_ref;
17358         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17359         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17360         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17361         *ret_conv = ChannelReestablish_read(ser_ref);
17362         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17363         return (long)ret_conv;
17364 }
17365
17366 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
17367         LDKClosingSigned obj_conv;
17368         obj_conv.inner = (void*)(obj & (~1));
17369         obj_conv.is_owned = false;
17370         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
17371         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17372         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17373         CVec_u8Z_free(ret_var);
17374         return ret_arr;
17375 }
17376
17377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17378         LDKu8slice ser_ref;
17379         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17380         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17381         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17382         *ret_conv = ClosingSigned_read(ser_ref);
17383         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17384         return (long)ret_conv;
17385 }
17386
17387 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
17388         LDKCommitmentSigned obj_conv;
17389         obj_conv.inner = (void*)(obj & (~1));
17390         obj_conv.is_owned = false;
17391         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
17392         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17393         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17394         CVec_u8Z_free(ret_var);
17395         return ret_arr;
17396 }
17397
17398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17399         LDKu8slice ser_ref;
17400         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17401         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17402         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17403         *ret_conv = CommitmentSigned_read(ser_ref);
17404         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17405         return (long)ret_conv;
17406 }
17407
17408 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
17409         LDKFundingCreated obj_conv;
17410         obj_conv.inner = (void*)(obj & (~1));
17411         obj_conv.is_owned = false;
17412         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
17413         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17414         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17415         CVec_u8Z_free(ret_var);
17416         return ret_arr;
17417 }
17418
17419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17420         LDKu8slice ser_ref;
17421         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17422         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17423         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17424         *ret_conv = FundingCreated_read(ser_ref);
17425         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17426         return (long)ret_conv;
17427 }
17428
17429 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
17430         LDKFundingSigned obj_conv;
17431         obj_conv.inner = (void*)(obj & (~1));
17432         obj_conv.is_owned = false;
17433         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
17434         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17435         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17436         CVec_u8Z_free(ret_var);
17437         return ret_arr;
17438 }
17439
17440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17441         LDKu8slice ser_ref;
17442         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17443         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17444         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17445         *ret_conv = FundingSigned_read(ser_ref);
17446         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17447         return (long)ret_conv;
17448 }
17449
17450 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
17451         LDKFundingLocked obj_conv;
17452         obj_conv.inner = (void*)(obj & (~1));
17453         obj_conv.is_owned = false;
17454         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
17455         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17456         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17457         CVec_u8Z_free(ret_var);
17458         return ret_arr;
17459 }
17460
17461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17462         LDKu8slice ser_ref;
17463         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17464         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17465         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17466         *ret_conv = FundingLocked_read(ser_ref);
17467         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17468         return (long)ret_conv;
17469 }
17470
17471 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
17472         LDKInit obj_conv;
17473         obj_conv.inner = (void*)(obj & (~1));
17474         obj_conv.is_owned = false;
17475         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
17476         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17477         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17478         CVec_u8Z_free(ret_var);
17479         return ret_arr;
17480 }
17481
17482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17483         LDKu8slice ser_ref;
17484         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17485         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17486         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17487         *ret_conv = Init_read(ser_ref);
17488         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17489         return (long)ret_conv;
17490 }
17491
17492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
17493         LDKOpenChannel obj_conv;
17494         obj_conv.inner = (void*)(obj & (~1));
17495         obj_conv.is_owned = false;
17496         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
17497         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17498         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17499         CVec_u8Z_free(ret_var);
17500         return ret_arr;
17501 }
17502
17503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17504         LDKu8slice ser_ref;
17505         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17506         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17507         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17508         *ret_conv = OpenChannel_read(ser_ref);
17509         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17510         return (long)ret_conv;
17511 }
17512
17513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
17514         LDKRevokeAndACK obj_conv;
17515         obj_conv.inner = (void*)(obj & (~1));
17516         obj_conv.is_owned = false;
17517         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
17518         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17519         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17520         CVec_u8Z_free(ret_var);
17521         return ret_arr;
17522 }
17523
17524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17525         LDKu8slice ser_ref;
17526         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17527         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17528         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17529         *ret_conv = RevokeAndACK_read(ser_ref);
17530         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17531         return (long)ret_conv;
17532 }
17533
17534 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
17535         LDKShutdown obj_conv;
17536         obj_conv.inner = (void*)(obj & (~1));
17537         obj_conv.is_owned = false;
17538         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
17539         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17540         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17541         CVec_u8Z_free(ret_var);
17542         return ret_arr;
17543 }
17544
17545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17546         LDKu8slice ser_ref;
17547         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17548         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17549         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17550         *ret_conv = Shutdown_read(ser_ref);
17551         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17552         return (long)ret_conv;
17553 }
17554
17555 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
17556         LDKUpdateFailHTLC obj_conv;
17557         obj_conv.inner = (void*)(obj & (~1));
17558         obj_conv.is_owned = false;
17559         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
17560         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17561         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17562         CVec_u8Z_free(ret_var);
17563         return ret_arr;
17564 }
17565
17566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17567         LDKu8slice ser_ref;
17568         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17569         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17570         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
17571         *ret_conv = UpdateFailHTLC_read(ser_ref);
17572         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17573         return (long)ret_conv;
17574 }
17575
17576 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
17577         LDKUpdateFailMalformedHTLC obj_conv;
17578         obj_conv.inner = (void*)(obj & (~1));
17579         obj_conv.is_owned = false;
17580         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
17581         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17582         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17583         CVec_u8Z_free(ret_var);
17584         return ret_arr;
17585 }
17586
17587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17588         LDKu8slice ser_ref;
17589         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17590         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17591         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
17592         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
17593         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17594         return (long)ret_conv;
17595 }
17596
17597 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
17598         LDKUpdateFee obj_conv;
17599         obj_conv.inner = (void*)(obj & (~1));
17600         obj_conv.is_owned = false;
17601         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
17602         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17603         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17604         CVec_u8Z_free(ret_var);
17605         return ret_arr;
17606 }
17607
17608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17609         LDKu8slice ser_ref;
17610         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17611         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17612         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
17613         *ret_conv = UpdateFee_read(ser_ref);
17614         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17615         return (long)ret_conv;
17616 }
17617
17618 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
17619         LDKUpdateFulfillHTLC obj_conv;
17620         obj_conv.inner = (void*)(obj & (~1));
17621         obj_conv.is_owned = false;
17622         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
17623         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17624         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17625         CVec_u8Z_free(ret_var);
17626         return ret_arr;
17627 }
17628
17629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17630         LDKu8slice ser_ref;
17631         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17632         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17633         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
17634         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
17635         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17636         return (long)ret_conv;
17637 }
17638
17639 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
17640         LDKUpdateAddHTLC obj_conv;
17641         obj_conv.inner = (void*)(obj & (~1));
17642         obj_conv.is_owned = false;
17643         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
17644         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17645         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17646         CVec_u8Z_free(ret_var);
17647         return ret_arr;
17648 }
17649
17650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17651         LDKu8slice ser_ref;
17652         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17653         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17654         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
17655         *ret_conv = UpdateAddHTLC_read(ser_ref);
17656         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17657         return (long)ret_conv;
17658 }
17659
17660 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
17661         LDKPing obj_conv;
17662         obj_conv.inner = (void*)(obj & (~1));
17663         obj_conv.is_owned = false;
17664         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
17665         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17666         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17667         CVec_u8Z_free(ret_var);
17668         return ret_arr;
17669 }
17670
17671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17672         LDKu8slice ser_ref;
17673         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17674         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17675         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
17676         *ret_conv = Ping_read(ser_ref);
17677         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17678         return (long)ret_conv;
17679 }
17680
17681 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
17682         LDKPong obj_conv;
17683         obj_conv.inner = (void*)(obj & (~1));
17684         obj_conv.is_owned = false;
17685         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
17686         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17687         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17688         CVec_u8Z_free(ret_var);
17689         return ret_arr;
17690 }
17691
17692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17693         LDKu8slice ser_ref;
17694         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17695         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17696         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
17697         *ret_conv = Pong_read(ser_ref);
17698         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17699         return (long)ret_conv;
17700 }
17701
17702 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17703         LDKUnsignedChannelAnnouncement obj_conv;
17704         obj_conv.inner = (void*)(obj & (~1));
17705         obj_conv.is_owned = false;
17706         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
17707         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17708         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17709         CVec_u8Z_free(ret_var);
17710         return ret_arr;
17711 }
17712
17713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17714         LDKu8slice ser_ref;
17715         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17716         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17717         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
17718         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
17719         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17720         return (long)ret_conv;
17721 }
17722
17723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17724         LDKChannelAnnouncement obj_conv;
17725         obj_conv.inner = (void*)(obj & (~1));
17726         obj_conv.is_owned = false;
17727         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
17728         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17729         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17730         CVec_u8Z_free(ret_var);
17731         return ret_arr;
17732 }
17733
17734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17735         LDKu8slice ser_ref;
17736         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17737         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17738         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
17739         *ret_conv = ChannelAnnouncement_read(ser_ref);
17740         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17741         return (long)ret_conv;
17742 }
17743
17744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
17745         LDKUnsignedChannelUpdate obj_conv;
17746         obj_conv.inner = (void*)(obj & (~1));
17747         obj_conv.is_owned = false;
17748         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
17749         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17750         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17751         CVec_u8Z_free(ret_var);
17752         return ret_arr;
17753 }
17754
17755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17756         LDKu8slice ser_ref;
17757         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17758         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17759         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
17760         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
17761         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17762         return (long)ret_conv;
17763 }
17764
17765 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
17766         LDKChannelUpdate obj_conv;
17767         obj_conv.inner = (void*)(obj & (~1));
17768         obj_conv.is_owned = false;
17769         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
17770         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17771         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17772         CVec_u8Z_free(ret_var);
17773         return ret_arr;
17774 }
17775
17776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17777         LDKu8slice ser_ref;
17778         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17779         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17780         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
17781         *ret_conv = ChannelUpdate_read(ser_ref);
17782         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17783         return (long)ret_conv;
17784 }
17785
17786 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
17787         LDKErrorMessage obj_conv;
17788         obj_conv.inner = (void*)(obj & (~1));
17789         obj_conv.is_owned = false;
17790         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
17791         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17792         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17793         CVec_u8Z_free(ret_var);
17794         return ret_arr;
17795 }
17796
17797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17798         LDKu8slice ser_ref;
17799         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17800         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17801         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
17802         *ret_conv = ErrorMessage_read(ser_ref);
17803         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17804         return (long)ret_conv;
17805 }
17806
17807 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17808         LDKUnsignedNodeAnnouncement obj_conv;
17809         obj_conv.inner = (void*)(obj & (~1));
17810         obj_conv.is_owned = false;
17811         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
17812         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17813         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17814         CVec_u8Z_free(ret_var);
17815         return ret_arr;
17816 }
17817
17818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17819         LDKu8slice ser_ref;
17820         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17821         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17822         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
17823         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
17824         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17825         return (long)ret_conv;
17826 }
17827
17828 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17829         LDKNodeAnnouncement obj_conv;
17830         obj_conv.inner = (void*)(obj & (~1));
17831         obj_conv.is_owned = false;
17832         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
17833         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17834         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17835         CVec_u8Z_free(ret_var);
17836         return ret_arr;
17837 }
17838
17839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17840         LDKu8slice ser_ref;
17841         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17842         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17843         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
17844         *ret_conv = NodeAnnouncement_read(ser_ref);
17845         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17846         return (long)ret_conv;
17847 }
17848
17849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17850         LDKu8slice ser_ref;
17851         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17852         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17853         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
17854         *ret_conv = QueryShortChannelIds_read(ser_ref);
17855         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17856         return (long)ret_conv;
17857 }
17858
17859 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
17860         LDKQueryShortChannelIds obj_conv;
17861         obj_conv.inner = (void*)(obj & (~1));
17862         obj_conv.is_owned = false;
17863         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
17864         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17865         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17866         CVec_u8Z_free(ret_var);
17867         return ret_arr;
17868 }
17869
17870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17871         LDKu8slice ser_ref;
17872         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17873         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17874         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
17875         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
17876         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17877         return (long)ret_conv;
17878 }
17879
17880 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
17881         LDKReplyShortChannelIdsEnd obj_conv;
17882         obj_conv.inner = (void*)(obj & (~1));
17883         obj_conv.is_owned = false;
17884         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
17885         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17886         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17887         CVec_u8Z_free(ret_var);
17888         return ret_arr;
17889 }
17890
17891 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
17892         LDKQueryChannelRange this_arg_conv;
17893         this_arg_conv.inner = (void*)(this_arg & (~1));
17894         this_arg_conv.is_owned = false;
17895         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
17896         return ret_val;
17897 }
17898
17899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17900         LDKu8slice ser_ref;
17901         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17902         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17903         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
17904         *ret_conv = QueryChannelRange_read(ser_ref);
17905         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17906         return (long)ret_conv;
17907 }
17908
17909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
17910         LDKQueryChannelRange obj_conv;
17911         obj_conv.inner = (void*)(obj & (~1));
17912         obj_conv.is_owned = false;
17913         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
17914         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17915         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17916         CVec_u8Z_free(ret_var);
17917         return ret_arr;
17918 }
17919
17920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17921         LDKu8slice ser_ref;
17922         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17923         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17924         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
17925         *ret_conv = ReplyChannelRange_read(ser_ref);
17926         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17927         return (long)ret_conv;
17928 }
17929
17930 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
17931         LDKReplyChannelRange obj_conv;
17932         obj_conv.inner = (void*)(obj & (~1));
17933         obj_conv.is_owned = false;
17934         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
17935         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17936         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17937         CVec_u8Z_free(ret_var);
17938         return ret_arr;
17939 }
17940
17941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17942         LDKu8slice ser_ref;
17943         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17944         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17945         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
17946         *ret_conv = GossipTimestampFilter_read(ser_ref);
17947         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17948         return (long)ret_conv;
17949 }
17950
17951 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
17952         LDKGossipTimestampFilter obj_conv;
17953         obj_conv.inner = (void*)(obj & (~1));
17954         obj_conv.is_owned = false;
17955         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
17956         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17957         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17958         CVec_u8Z_free(ret_var);
17959         return ret_arr;
17960 }
17961
17962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17963         LDKIgnoringMessageHandler this_obj_conv;
17964         this_obj_conv.inner = (void*)(this_obj & (~1));
17965         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17966         IgnoringMessageHandler_free(this_obj_conv);
17967 }
17968
17969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
17970         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
17971         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17972         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17973         long ret_ref = (long)ret_var.inner;
17974         if (ret_var.is_owned) {
17975                 ret_ref |= 1;
17976         }
17977         return ret_ref;
17978 }
17979
17980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17981         LDKIgnoringMessageHandler this_arg_conv;
17982         this_arg_conv.inner = (void*)(this_arg & (~1));
17983         this_arg_conv.is_owned = false;
17984         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
17985         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
17986         return (long)ret;
17987 }
17988
17989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
17990         LDKIgnoringMessageHandler this_arg_conv;
17991         this_arg_conv.inner = (void*)(this_arg & (~1));
17992         this_arg_conv.is_owned = false;
17993         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
17994         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
17995         return (long)ret;
17996 }
17997
17998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17999         LDKErroringMessageHandler this_obj_conv;
18000         this_obj_conv.inner = (void*)(this_obj & (~1));
18001         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18002         ErroringMessageHandler_free(this_obj_conv);
18003 }
18004
18005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
18006         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
18007         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18008         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18009         long ret_ref = (long)ret_var.inner;
18010         if (ret_var.is_owned) {
18011                 ret_ref |= 1;
18012         }
18013         return ret_ref;
18014 }
18015
18016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
18017         LDKErroringMessageHandler this_arg_conv;
18018         this_arg_conv.inner = (void*)(this_arg & (~1));
18019         this_arg_conv.is_owned = false;
18020         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
18021         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
18022         return (long)ret;
18023 }
18024
18025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
18026         LDKErroringMessageHandler this_arg_conv;
18027         this_arg_conv.inner = (void*)(this_arg & (~1));
18028         this_arg_conv.is_owned = false;
18029         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
18030         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
18031         return (long)ret;
18032 }
18033
18034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18035         LDKMessageHandler this_obj_conv;
18036         this_obj_conv.inner = (void*)(this_obj & (~1));
18037         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18038         MessageHandler_free(this_obj_conv);
18039 }
18040
18041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
18042         LDKMessageHandler this_ptr_conv;
18043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18044         this_ptr_conv.is_owned = false;
18045         long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
18046         return ret_ret;
18047 }
18048
18049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18050         LDKMessageHandler this_ptr_conv;
18051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18052         this_ptr_conv.is_owned = false;
18053         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
18054         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
18055                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18056                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
18057         }
18058         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
18059 }
18060
18061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
18062         LDKMessageHandler this_ptr_conv;
18063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18064         this_ptr_conv.is_owned = false;
18065         long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
18066         return ret_ret;
18067 }
18068
18069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18070         LDKMessageHandler this_ptr_conv;
18071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18072         this_ptr_conv.is_owned = false;
18073         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
18074         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
18075                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18076                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
18077         }
18078         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
18079 }
18080
18081 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) {
18082         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
18083         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
18084                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18085                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
18086         }
18087         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
18088         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
18089                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18090                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
18091         }
18092         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
18093         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18094         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18095         long ret_ref = (long)ret_var.inner;
18096         if (ret_var.is_owned) {
18097                 ret_ref |= 1;
18098         }
18099         return ret_ref;
18100 }
18101
18102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18103         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
18104         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
18105         *ret = SocketDescriptor_clone(orig_conv);
18106         return (long)ret;
18107 }
18108
18109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18110         if ((this_ptr & 1) != 0) return;
18111         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
18112         FREE((void*)this_ptr);
18113         SocketDescriptor_free(this_ptr_conv);
18114 }
18115
18116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18117         LDKPeerHandleError this_obj_conv;
18118         this_obj_conv.inner = (void*)(this_obj & (~1));
18119         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18120         PeerHandleError_free(this_obj_conv);
18121 }
18122
18123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
18124         LDKPeerHandleError this_ptr_conv;
18125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18126         this_ptr_conv.is_owned = false;
18127         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
18128         return ret_val;
18129 }
18130
18131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18132         LDKPeerHandleError this_ptr_conv;
18133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18134         this_ptr_conv.is_owned = false;
18135         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
18136 }
18137
18138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
18139         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
18140         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18141         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18142         long ret_ref = (long)ret_var.inner;
18143         if (ret_var.is_owned) {
18144                 ret_ref |= 1;
18145         }
18146         return ret_ref;
18147 }
18148
18149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18150         LDKPeerHandleError orig_conv;
18151         orig_conv.inner = (void*)(orig & (~1));
18152         orig_conv.is_owned = false;
18153         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
18154         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18155         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18156         long ret_ref = (long)ret_var.inner;
18157         if (ret_var.is_owned) {
18158                 ret_ref |= 1;
18159         }
18160         return ret_ref;
18161 }
18162
18163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18164         LDKPeerManager this_obj_conv;
18165         this_obj_conv.inner = (void*)(this_obj & (~1));
18166         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18167         PeerManager_free(this_obj_conv);
18168 }
18169
18170 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) {
18171         LDKMessageHandler message_handler_conv;
18172         message_handler_conv.inner = (void*)(message_handler & (~1));
18173         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
18174         // Warning: we need a move here but no clone is available for LDKMessageHandler
18175         LDKSecretKey our_node_secret_ref;
18176         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
18177         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
18178         unsigned char ephemeral_random_data_arr[32];
18179         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
18180         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
18181         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
18182         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18183         if (logger_conv.free == LDKLogger_JCalls_free) {
18184                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18185                 LDKLogger_JCalls_clone(logger_conv.this_arg);
18186         }
18187         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
18188         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18189         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18190         long ret_ref = (long)ret_var.inner;
18191         if (ret_var.is_owned) {
18192                 ret_ref |= 1;
18193         }
18194         return ret_ref;
18195 }
18196
18197 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
18198         LDKPeerManager this_arg_conv;
18199         this_arg_conv.inner = (void*)(this_arg & (~1));
18200         this_arg_conv.is_owned = false;
18201         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
18202         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
18203         ;
18204         for (size_t i = 0; i < ret_var.datalen; i++) {
18205                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
18206                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
18207                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
18208         }
18209         FREE(ret_var.data);
18210         return ret_arr;
18211 }
18212
18213 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) {
18214         LDKPeerManager this_arg_conv;
18215         this_arg_conv.inner = (void*)(this_arg & (~1));
18216         this_arg_conv.is_owned = false;
18217         LDKPublicKey their_node_id_ref;
18218         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
18219         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
18220         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18221         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
18222                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18223                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
18224         }
18225         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18226         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
18227         return (long)ret_conv;
18228 }
18229
18230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
18231         LDKPeerManager this_arg_conv;
18232         this_arg_conv.inner = (void*)(this_arg & (~1));
18233         this_arg_conv.is_owned = false;
18234         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18235         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
18236                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18237                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
18238         }
18239         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18240         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
18241         return (long)ret_conv;
18242 }
18243
18244 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) {
18245         LDKPeerManager this_arg_conv;
18246         this_arg_conv.inner = (void*)(this_arg & (~1));
18247         this_arg_conv.is_owned = false;
18248         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18249         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18250         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
18251         return (long)ret_conv;
18252 }
18253
18254 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) {
18255         LDKPeerManager this_arg_conv;
18256         this_arg_conv.inner = (void*)(this_arg & (~1));
18257         this_arg_conv.is_owned = false;
18258         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
18259         LDKu8slice data_ref;
18260         data_ref.datalen = (*env)->GetArrayLength(env, data);
18261         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
18262         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18263         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
18264         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
18265         return (long)ret_conv;
18266 }
18267
18268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
18269         LDKPeerManager this_arg_conv;
18270         this_arg_conv.inner = (void*)(this_arg & (~1));
18271         this_arg_conv.is_owned = false;
18272         PeerManager_process_events(&this_arg_conv);
18273 }
18274
18275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
18276         LDKPeerManager this_arg_conv;
18277         this_arg_conv.inner = (void*)(this_arg & (~1));
18278         this_arg_conv.is_owned = false;
18279         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18280         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
18281 }
18282
18283 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) {
18284         LDKPeerManager this_arg_conv;
18285         this_arg_conv.inner = (void*)(this_arg & (~1));
18286         this_arg_conv.is_owned = false;
18287         LDKPublicKey node_id_ref;
18288         CHECK((*env)->GetArrayLength(env, node_id) == 33);
18289         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
18290         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
18291 }
18292
18293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
18294         LDKPeerManager this_arg_conv;
18295         this_arg_conv.inner = (void*)(this_arg & (~1));
18296         this_arg_conv.is_owned = false;
18297         PeerManager_timer_tick_occurred(&this_arg_conv);
18298 }
18299
18300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
18301         unsigned char commitment_seed_arr[32];
18302         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
18303         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
18304         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
18305         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18306         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
18307         return ret_arr;
18308 }
18309
18310 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) {
18311         LDKPublicKey per_commitment_point_ref;
18312         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
18313         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
18314         unsigned char base_secret_arr[32];
18315         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
18316         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
18317         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
18318         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
18319         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
18320         return (long)ret_conv;
18321 }
18322
18323 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) {
18324         LDKPublicKey per_commitment_point_ref;
18325         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
18326         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
18327         LDKPublicKey base_point_ref;
18328         CHECK((*env)->GetArrayLength(env, base_point) == 33);
18329         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
18330         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
18331         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
18332         return (long)ret_conv;
18333 }
18334
18335 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) {
18336         unsigned char per_commitment_secret_arr[32];
18337         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
18338         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
18339         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
18340         unsigned char countersignatory_revocation_base_secret_arr[32];
18341         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
18342         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
18343         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
18344         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
18345         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
18346         return (long)ret_conv;
18347 }
18348
18349 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) {
18350         LDKPublicKey per_commitment_point_ref;
18351         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
18352         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
18353         LDKPublicKey countersignatory_revocation_base_point_ref;
18354         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
18355         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
18356         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
18357         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
18358         return (long)ret_conv;
18359 }
18360
18361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18362         LDKTxCreationKeys this_obj_conv;
18363         this_obj_conv.inner = (void*)(this_obj & (~1));
18364         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18365         TxCreationKeys_free(this_obj_conv);
18366 }
18367
18368 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18369         LDKTxCreationKeys this_ptr_conv;
18370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18371         this_ptr_conv.is_owned = false;
18372         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18373         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
18374         return ret_arr;
18375 }
18376
18377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18378         LDKTxCreationKeys this_ptr_conv;
18379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18380         this_ptr_conv.is_owned = false;
18381         LDKPublicKey val_ref;
18382         CHECK((*env)->GetArrayLength(env, val) == 33);
18383         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18384         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
18385 }
18386
18387 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18388         LDKTxCreationKeys this_ptr_conv;
18389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18390         this_ptr_conv.is_owned = false;
18391         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18392         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
18393         return ret_arr;
18394 }
18395
18396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18397         LDKTxCreationKeys this_ptr_conv;
18398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18399         this_ptr_conv.is_owned = false;
18400         LDKPublicKey val_ref;
18401         CHECK((*env)->GetArrayLength(env, val) == 33);
18402         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18403         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
18404 }
18405
18406 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18407         LDKTxCreationKeys this_ptr_conv;
18408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18409         this_ptr_conv.is_owned = false;
18410         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18411         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
18412         return ret_arr;
18413 }
18414
18415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18416         LDKTxCreationKeys this_ptr_conv;
18417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18418         this_ptr_conv.is_owned = false;
18419         LDKPublicKey val_ref;
18420         CHECK((*env)->GetArrayLength(env, val) == 33);
18421         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18422         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
18423 }
18424
18425 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18426         LDKTxCreationKeys this_ptr_conv;
18427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18428         this_ptr_conv.is_owned = false;
18429         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18430         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
18431         return ret_arr;
18432 }
18433
18434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18435         LDKTxCreationKeys this_ptr_conv;
18436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18437         this_ptr_conv.is_owned = false;
18438         LDKPublicKey val_ref;
18439         CHECK((*env)->GetArrayLength(env, val) == 33);
18440         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18441         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
18442 }
18443
18444 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18445         LDKTxCreationKeys this_ptr_conv;
18446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18447         this_ptr_conv.is_owned = false;
18448         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18449         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
18450         return ret_arr;
18451 }
18452
18453 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) {
18454         LDKTxCreationKeys this_ptr_conv;
18455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18456         this_ptr_conv.is_owned = false;
18457         LDKPublicKey val_ref;
18458         CHECK((*env)->GetArrayLength(env, val) == 33);
18459         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18460         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
18461 }
18462
18463 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) {
18464         LDKPublicKey per_commitment_point_arg_ref;
18465         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
18466         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
18467         LDKPublicKey revocation_key_arg_ref;
18468         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
18469         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
18470         LDKPublicKey broadcaster_htlc_key_arg_ref;
18471         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
18472         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
18473         LDKPublicKey countersignatory_htlc_key_arg_ref;
18474         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
18475         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
18476         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
18477         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
18478         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
18479         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);
18480         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18481         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18482         long ret_ref = (long)ret_var.inner;
18483         if (ret_var.is_owned) {
18484                 ret_ref |= 1;
18485         }
18486         return ret_ref;
18487 }
18488
18489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18490         LDKTxCreationKeys orig_conv;
18491         orig_conv.inner = (void*)(orig & (~1));
18492         orig_conv.is_owned = false;
18493         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
18494         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18495         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18496         long ret_ref = (long)ret_var.inner;
18497         if (ret_var.is_owned) {
18498                 ret_ref |= 1;
18499         }
18500         return ret_ref;
18501 }
18502
18503 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
18504         LDKTxCreationKeys obj_conv;
18505         obj_conv.inner = (void*)(obj & (~1));
18506         obj_conv.is_owned = false;
18507         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
18508         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18509         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18510         CVec_u8Z_free(ret_var);
18511         return ret_arr;
18512 }
18513
18514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18515         LDKu8slice ser_ref;
18516         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18517         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18518         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
18519         *ret_conv = TxCreationKeys_read(ser_ref);
18520         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18521         return (long)ret_conv;
18522 }
18523
18524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18525         LDKChannelPublicKeys this_obj_conv;
18526         this_obj_conv.inner = (void*)(this_obj & (~1));
18527         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18528         ChannelPublicKeys_free(this_obj_conv);
18529 }
18530
18531 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18532         LDKChannelPublicKeys this_ptr_conv;
18533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18534         this_ptr_conv.is_owned = false;
18535         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18536         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
18537         return ret_arr;
18538 }
18539
18540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18541         LDKChannelPublicKeys this_ptr_conv;
18542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18543         this_ptr_conv.is_owned = false;
18544         LDKPublicKey val_ref;
18545         CHECK((*env)->GetArrayLength(env, val) == 33);
18546         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18547         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
18548 }
18549
18550 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18551         LDKChannelPublicKeys this_ptr_conv;
18552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18553         this_ptr_conv.is_owned = false;
18554         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18555         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
18556         return ret_arr;
18557 }
18558
18559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18560         LDKChannelPublicKeys this_ptr_conv;
18561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18562         this_ptr_conv.is_owned = false;
18563         LDKPublicKey val_ref;
18564         CHECK((*env)->GetArrayLength(env, val) == 33);
18565         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18566         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
18567 }
18568
18569 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18570         LDKChannelPublicKeys this_ptr_conv;
18571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18572         this_ptr_conv.is_owned = false;
18573         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18574         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
18575         return ret_arr;
18576 }
18577
18578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18579         LDKChannelPublicKeys this_ptr_conv;
18580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18581         this_ptr_conv.is_owned = false;
18582         LDKPublicKey val_ref;
18583         CHECK((*env)->GetArrayLength(env, val) == 33);
18584         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18585         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
18586 }
18587
18588 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18589         LDKChannelPublicKeys this_ptr_conv;
18590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18591         this_ptr_conv.is_owned = false;
18592         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18593         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
18594         return ret_arr;
18595 }
18596
18597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18598         LDKChannelPublicKeys this_ptr_conv;
18599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18600         this_ptr_conv.is_owned = false;
18601         LDKPublicKey val_ref;
18602         CHECK((*env)->GetArrayLength(env, val) == 33);
18603         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18604         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
18605 }
18606
18607 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18608         LDKChannelPublicKeys this_ptr_conv;
18609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18610         this_ptr_conv.is_owned = false;
18611         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18612         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
18613         return ret_arr;
18614 }
18615
18616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18617         LDKChannelPublicKeys this_ptr_conv;
18618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18619         this_ptr_conv.is_owned = false;
18620         LDKPublicKey val_ref;
18621         CHECK((*env)->GetArrayLength(env, val) == 33);
18622         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18623         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
18624 }
18625
18626 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) {
18627         LDKPublicKey funding_pubkey_arg_ref;
18628         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
18629         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
18630         LDKPublicKey revocation_basepoint_arg_ref;
18631         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
18632         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
18633         LDKPublicKey payment_point_arg_ref;
18634         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
18635         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
18636         LDKPublicKey delayed_payment_basepoint_arg_ref;
18637         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
18638         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
18639         LDKPublicKey htlc_basepoint_arg_ref;
18640         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
18641         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
18642         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);
18643         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18644         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18645         long ret_ref = (long)ret_var.inner;
18646         if (ret_var.is_owned) {
18647                 ret_ref |= 1;
18648         }
18649         return ret_ref;
18650 }
18651
18652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18653         LDKChannelPublicKeys orig_conv;
18654         orig_conv.inner = (void*)(orig & (~1));
18655         orig_conv.is_owned = false;
18656         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
18657         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18658         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18659         long ret_ref = (long)ret_var.inner;
18660         if (ret_var.is_owned) {
18661                 ret_ref |= 1;
18662         }
18663         return ret_ref;
18664 }
18665
18666 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
18667         LDKChannelPublicKeys obj_conv;
18668         obj_conv.inner = (void*)(obj & (~1));
18669         obj_conv.is_owned = false;
18670         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
18671         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18672         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18673         CVec_u8Z_free(ret_var);
18674         return ret_arr;
18675 }
18676
18677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18678         LDKu8slice ser_ref;
18679         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18680         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18681         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
18682         *ret_conv = ChannelPublicKeys_read(ser_ref);
18683         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18684         return (long)ret_conv;
18685 }
18686
18687 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) {
18688         LDKPublicKey per_commitment_point_ref;
18689         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
18690         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
18691         LDKPublicKey broadcaster_delayed_payment_base_ref;
18692         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
18693         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
18694         LDKPublicKey broadcaster_htlc_base_ref;
18695         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
18696         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
18697         LDKPublicKey countersignatory_revocation_base_ref;
18698         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
18699         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
18700         LDKPublicKey countersignatory_htlc_base_ref;
18701         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
18702         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
18703         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
18704         *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);
18705         return (long)ret_conv;
18706 }
18707
18708 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) {
18709         LDKPublicKey per_commitment_point_ref;
18710         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
18711         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
18712         LDKChannelPublicKeys broadcaster_keys_conv;
18713         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
18714         broadcaster_keys_conv.is_owned = false;
18715         LDKChannelPublicKeys countersignatory_keys_conv;
18716         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
18717         countersignatory_keys_conv.is_owned = false;
18718         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
18719         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
18720         return (long)ret_conv;
18721 }
18722
18723 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) {
18724         LDKPublicKey revocation_key_ref;
18725         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
18726         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
18727         LDKPublicKey broadcaster_delayed_payment_key_ref;
18728         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
18729         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
18730         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
18731         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18732         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18733         CVec_u8Z_free(ret_var);
18734         return ret_arr;
18735 }
18736
18737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18738         LDKHTLCOutputInCommitment this_obj_conv;
18739         this_obj_conv.inner = (void*)(this_obj & (~1));
18740         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18741         HTLCOutputInCommitment_free(this_obj_conv);
18742 }
18743
18744 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
18745         LDKHTLCOutputInCommitment this_ptr_conv;
18746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18747         this_ptr_conv.is_owned = false;
18748         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
18749         return ret_val;
18750 }
18751
18752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18753         LDKHTLCOutputInCommitment this_ptr_conv;
18754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18755         this_ptr_conv.is_owned = false;
18756         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
18757 }
18758
18759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18760         LDKHTLCOutputInCommitment this_ptr_conv;
18761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18762         this_ptr_conv.is_owned = false;
18763         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
18764         return ret_val;
18765 }
18766
18767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18768         LDKHTLCOutputInCommitment this_ptr_conv;
18769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18770         this_ptr_conv.is_owned = false;
18771         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
18772 }
18773
18774 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
18775         LDKHTLCOutputInCommitment this_ptr_conv;
18776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18777         this_ptr_conv.is_owned = false;
18778         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
18779         return ret_val;
18780 }
18781
18782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18783         LDKHTLCOutputInCommitment this_ptr_conv;
18784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18785         this_ptr_conv.is_owned = false;
18786         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
18787 }
18788
18789 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18790         LDKHTLCOutputInCommitment this_ptr_conv;
18791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18792         this_ptr_conv.is_owned = false;
18793         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18794         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
18795         return ret_arr;
18796 }
18797
18798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18799         LDKHTLCOutputInCommitment this_ptr_conv;
18800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18801         this_ptr_conv.is_owned = false;
18802         LDKThirtyTwoBytes val_ref;
18803         CHECK((*env)->GetArrayLength(env, val) == 32);
18804         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18805         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
18806 }
18807
18808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
18809         LDKHTLCOutputInCommitment this_ptr_conv;
18810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18811         this_ptr_conv.is_owned = false;
18812         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
18813         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
18814         long ret_ref = (long)ret_copy;
18815         return ret_ref;
18816 }
18817
18818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18819         LDKHTLCOutputInCommitment this_ptr_conv;
18820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18821         this_ptr_conv.is_owned = false;
18822         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
18823         FREE((void*)val);
18824         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
18825 }
18826
18827 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) {
18828         LDKThirtyTwoBytes payment_hash_arg_ref;
18829         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
18830         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
18831         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
18832         FREE((void*)transaction_output_index_arg);
18833         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
18834         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18835         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18836         long ret_ref = (long)ret_var.inner;
18837         if (ret_var.is_owned) {
18838                 ret_ref |= 1;
18839         }
18840         return ret_ref;
18841 }
18842
18843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18844         LDKHTLCOutputInCommitment orig_conv;
18845         orig_conv.inner = (void*)(orig & (~1));
18846         orig_conv.is_owned = false;
18847         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
18848         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18849         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18850         long ret_ref = (long)ret_var.inner;
18851         if (ret_var.is_owned) {
18852                 ret_ref |= 1;
18853         }
18854         return ret_ref;
18855 }
18856
18857 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
18858         LDKHTLCOutputInCommitment obj_conv;
18859         obj_conv.inner = (void*)(obj & (~1));
18860         obj_conv.is_owned = false;
18861         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
18862         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18863         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18864         CVec_u8Z_free(ret_var);
18865         return ret_arr;
18866 }
18867
18868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18869         LDKu8slice ser_ref;
18870         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18871         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18872         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
18873         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
18874         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18875         return (long)ret_conv;
18876 }
18877
18878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
18879         LDKHTLCOutputInCommitment htlc_conv;
18880         htlc_conv.inner = (void*)(htlc & (~1));
18881         htlc_conv.is_owned = false;
18882         LDKTxCreationKeys keys_conv;
18883         keys_conv.inner = (void*)(keys & (~1));
18884         keys_conv.is_owned = false;
18885         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
18886         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18887         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18888         CVec_u8Z_free(ret_var);
18889         return ret_arr;
18890 }
18891
18892 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
18893         LDKPublicKey broadcaster_ref;
18894         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
18895         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
18896         LDKPublicKey countersignatory_ref;
18897         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
18898         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
18899         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
18900         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18901         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18902         CVec_u8Z_free(ret_var);
18903         return ret_arr;
18904 }
18905
18906 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) {
18907         unsigned char prev_hash_arr[32];
18908         CHECK((*env)->GetArrayLength(env, prev_hash) == 32);
18909         (*env)->GetByteArrayRegion(env, prev_hash, 0, 32, prev_hash_arr);
18910         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
18911         LDKHTLCOutputInCommitment htlc_conv;
18912         htlc_conv.inner = (void*)(htlc & (~1));
18913         htlc_conv.is_owned = false;
18914         LDKPublicKey broadcaster_delayed_payment_key_ref;
18915         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
18916         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
18917         LDKPublicKey revocation_key_ref;
18918         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
18919         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
18920         LDKTransaction ret_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
18921         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18922         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18923         Transaction_free(ret_var);
18924         return ret_arr;
18925 }
18926
18927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18928         LDKChannelTransactionParameters this_obj_conv;
18929         this_obj_conv.inner = (void*)(this_obj & (~1));
18930         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18931         ChannelTransactionParameters_free(this_obj_conv);
18932 }
18933
18934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
18935         LDKChannelTransactionParameters this_ptr_conv;
18936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18937         this_ptr_conv.is_owned = false;
18938         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
18939         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18940         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18941         long ret_ref = (long)ret_var.inner;
18942         if (ret_var.is_owned) {
18943                 ret_ref |= 1;
18944         }
18945         return ret_ref;
18946 }
18947
18948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18949         LDKChannelTransactionParameters this_ptr_conv;
18950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18951         this_ptr_conv.is_owned = false;
18952         LDKChannelPublicKeys val_conv;
18953         val_conv.inner = (void*)(val & (~1));
18954         val_conv.is_owned = (val & 1) || (val == 0);
18955         val_conv = ChannelPublicKeys_clone(&val_conv);
18956         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
18957 }
18958
18959 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
18960         LDKChannelTransactionParameters this_ptr_conv;
18961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18962         this_ptr_conv.is_owned = false;
18963         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
18964         return ret_val;
18965 }
18966
18967 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) {
18968         LDKChannelTransactionParameters this_ptr_conv;
18969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18970         this_ptr_conv.is_owned = false;
18971         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
18972 }
18973
18974 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
18975         LDKChannelTransactionParameters this_ptr_conv;
18976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18977         this_ptr_conv.is_owned = false;
18978         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
18979         return ret_val;
18980 }
18981
18982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18983         LDKChannelTransactionParameters this_ptr_conv;
18984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18985         this_ptr_conv.is_owned = false;
18986         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
18987 }
18988
18989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
18990         LDKChannelTransactionParameters this_ptr_conv;
18991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18992         this_ptr_conv.is_owned = false;
18993         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
18994         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18995         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18996         long ret_ref = (long)ret_var.inner;
18997         if (ret_var.is_owned) {
18998                 ret_ref |= 1;
18999         }
19000         return ret_ref;
19001 }
19002
19003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19004         LDKChannelTransactionParameters this_ptr_conv;
19005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19006         this_ptr_conv.is_owned = false;
19007         LDKCounterpartyChannelTransactionParameters val_conv;
19008         val_conv.inner = (void*)(val & (~1));
19009         val_conv.is_owned = (val & 1) || (val == 0);
19010         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
19011         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
19012 }
19013
19014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
19015         LDKChannelTransactionParameters this_ptr_conv;
19016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19017         this_ptr_conv.is_owned = false;
19018         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
19019         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19020         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19021         long ret_ref = (long)ret_var.inner;
19022         if (ret_var.is_owned) {
19023                 ret_ref |= 1;
19024         }
19025         return ret_ref;
19026 }
19027
19028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19029         LDKChannelTransactionParameters this_ptr_conv;
19030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19031         this_ptr_conv.is_owned = false;
19032         LDKOutPoint val_conv;
19033         val_conv.inner = (void*)(val & (~1));
19034         val_conv.is_owned = (val & 1) || (val == 0);
19035         val_conv = OutPoint_clone(&val_conv);
19036         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
19037 }
19038
19039 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) {
19040         LDKChannelPublicKeys holder_pubkeys_arg_conv;
19041         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
19042         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
19043         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
19044         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
19045         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
19046         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
19047         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
19048         LDKOutPoint funding_outpoint_arg_conv;
19049         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
19050         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
19051         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
19052         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);
19053         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19054         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19055         long ret_ref = (long)ret_var.inner;
19056         if (ret_var.is_owned) {
19057                 ret_ref |= 1;
19058         }
19059         return ret_ref;
19060 }
19061
19062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19063         LDKChannelTransactionParameters orig_conv;
19064         orig_conv.inner = (void*)(orig & (~1));
19065         orig_conv.is_owned = false;
19066         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
19067         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19068         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19069         long ret_ref = (long)ret_var.inner;
19070         if (ret_var.is_owned) {
19071                 ret_ref |= 1;
19072         }
19073         return ret_ref;
19074 }
19075
19076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19077         LDKCounterpartyChannelTransactionParameters this_obj_conv;
19078         this_obj_conv.inner = (void*)(this_obj & (~1));
19079         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19080         CounterpartyChannelTransactionParameters_free(this_obj_conv);
19081 }
19082
19083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
19084         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19086         this_ptr_conv.is_owned = false;
19087         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
19088         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19089         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19090         long ret_ref = (long)ret_var.inner;
19091         if (ret_var.is_owned) {
19092                 ret_ref |= 1;
19093         }
19094         return ret_ref;
19095 }
19096
19097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19098         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19100         this_ptr_conv.is_owned = false;
19101         LDKChannelPublicKeys val_conv;
19102         val_conv.inner = (void*)(val & (~1));
19103         val_conv.is_owned = (val & 1) || (val == 0);
19104         val_conv = ChannelPublicKeys_clone(&val_conv);
19105         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
19106 }
19107
19108 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
19109         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19111         this_ptr_conv.is_owned = false;
19112         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
19113         return ret_val;
19114 }
19115
19116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19117         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19119         this_ptr_conv.is_owned = false;
19120         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
19121 }
19122
19123 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) {
19124         LDKChannelPublicKeys pubkeys_arg_conv;
19125         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
19126         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
19127         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
19128         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
19129         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19130         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19131         long ret_ref = (long)ret_var.inner;
19132         if (ret_var.is_owned) {
19133                 ret_ref |= 1;
19134         }
19135         return ret_ref;
19136 }
19137
19138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19139         LDKCounterpartyChannelTransactionParameters orig_conv;
19140         orig_conv.inner = (void*)(orig & (~1));
19141         orig_conv.is_owned = false;
19142         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
19143         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19144         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19145         long ret_ref = (long)ret_var.inner;
19146         if (ret_var.is_owned) {
19147                 ret_ref |= 1;
19148         }
19149         return ret_ref;
19150 }
19151
19152 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
19153         LDKChannelTransactionParameters this_arg_conv;
19154         this_arg_conv.inner = (void*)(this_arg & (~1));
19155         this_arg_conv.is_owned = false;
19156         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
19157         return ret_val;
19158 }
19159
19160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
19161         LDKChannelTransactionParameters this_arg_conv;
19162         this_arg_conv.inner = (void*)(this_arg & (~1));
19163         this_arg_conv.is_owned = false;
19164         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
19165         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19166         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19167         long ret_ref = (long)ret_var.inner;
19168         if (ret_var.is_owned) {
19169                 ret_ref |= 1;
19170         }
19171         return ret_ref;
19172 }
19173
19174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
19175         LDKChannelTransactionParameters this_arg_conv;
19176         this_arg_conv.inner = (void*)(this_arg & (~1));
19177         this_arg_conv.is_owned = false;
19178         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
19179         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19180         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19181         long ret_ref = (long)ret_var.inner;
19182         if (ret_var.is_owned) {
19183                 ret_ref |= 1;
19184         }
19185         return ret_ref;
19186 }
19187
19188 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
19189         LDKCounterpartyChannelTransactionParameters obj_conv;
19190         obj_conv.inner = (void*)(obj & (~1));
19191         obj_conv.is_owned = false;
19192         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
19193         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19194         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19195         CVec_u8Z_free(ret_var);
19196         return ret_arr;
19197 }
19198
19199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19200         LDKu8slice ser_ref;
19201         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19202         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19203         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
19204         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
19205         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19206         return (long)ret_conv;
19207 }
19208
19209 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
19210         LDKChannelTransactionParameters obj_conv;
19211         obj_conv.inner = (void*)(obj & (~1));
19212         obj_conv.is_owned = false;
19213         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
19214         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19215         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19216         CVec_u8Z_free(ret_var);
19217         return ret_arr;
19218 }
19219
19220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19221         LDKu8slice ser_ref;
19222         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19223         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19224         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
19225         *ret_conv = ChannelTransactionParameters_read(ser_ref);
19226         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19227         return (long)ret_conv;
19228 }
19229
19230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19231         LDKDirectedChannelTransactionParameters this_obj_conv;
19232         this_obj_conv.inner = (void*)(this_obj & (~1));
19233         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19234         DirectedChannelTransactionParameters_free(this_obj_conv);
19235 }
19236
19237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
19238         LDKDirectedChannelTransactionParameters this_arg_conv;
19239         this_arg_conv.inner = (void*)(this_arg & (~1));
19240         this_arg_conv.is_owned = false;
19241         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
19242         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19243         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19244         long ret_ref = (long)ret_var.inner;
19245         if (ret_var.is_owned) {
19246                 ret_ref |= 1;
19247         }
19248         return ret_ref;
19249 }
19250
19251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
19252         LDKDirectedChannelTransactionParameters this_arg_conv;
19253         this_arg_conv.inner = (void*)(this_arg & (~1));
19254         this_arg_conv.is_owned = false;
19255         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
19256         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19257         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19258         long ret_ref = (long)ret_var.inner;
19259         if (ret_var.is_owned) {
19260                 ret_ref |= 1;
19261         }
19262         return ret_ref;
19263 }
19264
19265 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
19266         LDKDirectedChannelTransactionParameters this_arg_conv;
19267         this_arg_conv.inner = (void*)(this_arg & (~1));
19268         this_arg_conv.is_owned = false;
19269         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
19270         return ret_val;
19271 }
19272
19273 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
19274         LDKDirectedChannelTransactionParameters this_arg_conv;
19275         this_arg_conv.inner = (void*)(this_arg & (~1));
19276         this_arg_conv.is_owned = false;
19277         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
19278         return ret_val;
19279 }
19280
19281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
19282         LDKDirectedChannelTransactionParameters this_arg_conv;
19283         this_arg_conv.inner = (void*)(this_arg & (~1));
19284         this_arg_conv.is_owned = false;
19285         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
19286         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19287         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19288         long ret_ref = (long)ret_var.inner;
19289         if (ret_var.is_owned) {
19290                 ret_ref |= 1;
19291         }
19292         return ret_ref;
19293 }
19294
19295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19296         LDKHolderCommitmentTransaction this_obj_conv;
19297         this_obj_conv.inner = (void*)(this_obj & (~1));
19298         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19299         HolderCommitmentTransaction_free(this_obj_conv);
19300 }
19301
19302 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
19303         LDKHolderCommitmentTransaction this_ptr_conv;
19304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19305         this_ptr_conv.is_owned = false;
19306         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19307         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
19308         return ret_arr;
19309 }
19310
19311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19312         LDKHolderCommitmentTransaction this_ptr_conv;
19313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19314         this_ptr_conv.is_owned = false;
19315         LDKSignature val_ref;
19316         CHECK((*env)->GetArrayLength(env, val) == 64);
19317         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19318         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
19319 }
19320
19321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
19322         LDKHolderCommitmentTransaction this_ptr_conv;
19323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19324         this_ptr_conv.is_owned = false;
19325         LDKCVec_SignatureZ val_constr;
19326         val_constr.datalen = (*env)->GetArrayLength(env, val);
19327         if (val_constr.datalen > 0)
19328                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19329         else
19330                 val_constr.data = NULL;
19331         for (size_t i = 0; i < val_constr.datalen; i++) {
19332                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
19333                 LDKSignature val_conv_8_ref;
19334                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
19335                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
19336                 val_constr.data[i] = val_conv_8_ref;
19337         }
19338         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
19339 }
19340
19341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19342         LDKHolderCommitmentTransaction orig_conv;
19343         orig_conv.inner = (void*)(orig & (~1));
19344         orig_conv.is_owned = false;
19345         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
19346         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19347         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19348         long ret_ref = (long)ret_var.inner;
19349         if (ret_var.is_owned) {
19350                 ret_ref |= 1;
19351         }
19352         return ret_ref;
19353 }
19354
19355 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
19356         LDKHolderCommitmentTransaction obj_conv;
19357         obj_conv.inner = (void*)(obj & (~1));
19358         obj_conv.is_owned = false;
19359         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
19360         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19361         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19362         CVec_u8Z_free(ret_var);
19363         return ret_arr;
19364 }
19365
19366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19367         LDKu8slice ser_ref;
19368         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19369         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19370         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
19371         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
19372         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19373         return (long)ret_conv;
19374 }
19375
19376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_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) {
19377         LDKCommitmentTransaction commitment_tx_conv;
19378         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
19379         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
19380         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
19381         LDKSignature counterparty_sig_ref;
19382         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
19383         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
19384         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
19385         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
19386         if (counterparty_htlc_sigs_constr.datalen > 0)
19387                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19388         else
19389                 counterparty_htlc_sigs_constr.data = NULL;
19390         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
19391                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
19392                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
19393                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
19394                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
19395                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
19396         }
19397         LDKPublicKey holder_funding_key_ref;
19398         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
19399         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
19400         LDKPublicKey counterparty_funding_key_ref;
19401         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
19402         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
19403         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
19404         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19405         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19406         long ret_ref = (long)ret_var.inner;
19407         if (ret_var.is_owned) {
19408                 ret_ref |= 1;
19409         }
19410         return ret_ref;
19411 }
19412
19413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19414         LDKBuiltCommitmentTransaction this_obj_conv;
19415         this_obj_conv.inner = (void*)(this_obj & (~1));
19416         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19417         BuiltCommitmentTransaction_free(this_obj_conv);
19418 }
19419
19420 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
19421         LDKBuiltCommitmentTransaction this_ptr_conv;
19422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19423         this_ptr_conv.is_owned = false;
19424         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
19425         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19426         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19427         Transaction_free(ret_var);
19428         return ret_arr;
19429 }
19430
19431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19432         LDKBuiltCommitmentTransaction this_ptr_conv;
19433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19434         this_ptr_conv.is_owned = false;
19435         LDKTransaction val_ref;
19436         val_ref.datalen = (*env)->GetArrayLength(env, val);
19437         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
19438         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
19439         val_ref.data_is_owned = true;
19440         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
19441 }
19442
19443 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
19444         LDKBuiltCommitmentTransaction this_ptr_conv;
19445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19446         this_ptr_conv.is_owned = false;
19447         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19448         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
19449         return ret_arr;
19450 }
19451
19452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19453         LDKBuiltCommitmentTransaction this_ptr_conv;
19454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19455         this_ptr_conv.is_owned = false;
19456         LDKThirtyTwoBytes val_ref;
19457         CHECK((*env)->GetArrayLength(env, val) == 32);
19458         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19459         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
19460 }
19461
19462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
19463         LDKTransaction transaction_arg_ref;
19464         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
19465         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
19466         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
19467         transaction_arg_ref.data_is_owned = true;
19468         LDKThirtyTwoBytes txid_arg_ref;
19469         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
19470         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
19471         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
19472         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19473         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19474         long ret_ref = (long)ret_var.inner;
19475         if (ret_var.is_owned) {
19476                 ret_ref |= 1;
19477         }
19478         return ret_ref;
19479 }
19480
19481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19482         LDKBuiltCommitmentTransaction orig_conv;
19483         orig_conv.inner = (void*)(orig & (~1));
19484         orig_conv.is_owned = false;
19485         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
19486         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19487         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19488         long ret_ref = (long)ret_var.inner;
19489         if (ret_var.is_owned) {
19490                 ret_ref |= 1;
19491         }
19492         return ret_ref;
19493 }
19494
19495 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
19496         LDKBuiltCommitmentTransaction obj_conv;
19497         obj_conv.inner = (void*)(obj & (~1));
19498         obj_conv.is_owned = false;
19499         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
19500         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19501         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19502         CVec_u8Z_free(ret_var);
19503         return ret_arr;
19504 }
19505
19506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19507         LDKu8slice ser_ref;
19508         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19509         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19510         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
19511         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
19512         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19513         return (long)ret_conv;
19514 }
19515
19516 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) {
19517         LDKBuiltCommitmentTransaction this_arg_conv;
19518         this_arg_conv.inner = (void*)(this_arg & (~1));
19519         this_arg_conv.is_owned = false;
19520         LDKu8slice funding_redeemscript_ref;
19521         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
19522         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
19523         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19524         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
19525         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
19526         return ret_arr;
19527 }
19528
19529 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) {
19530         LDKBuiltCommitmentTransaction this_arg_conv;
19531         this_arg_conv.inner = (void*)(this_arg & (~1));
19532         this_arg_conv.is_owned = false;
19533         unsigned char funding_key_arr[32];
19534         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
19535         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
19536         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
19537         LDKu8slice funding_redeemscript_ref;
19538         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
19539         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
19540         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19541         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
19542         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
19543         return ret_arr;
19544 }
19545
19546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19547         LDKCommitmentTransaction this_obj_conv;
19548         this_obj_conv.inner = (void*)(this_obj & (~1));
19549         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19550         CommitmentTransaction_free(this_obj_conv);
19551 }
19552
19553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19554         LDKCommitmentTransaction orig_conv;
19555         orig_conv.inner = (void*)(orig & (~1));
19556         orig_conv.is_owned = false;
19557         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
19558         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19559         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19560         long ret_ref = (long)ret_var.inner;
19561         if (ret_var.is_owned) {
19562                 ret_ref |= 1;
19563         }
19564         return ret_ref;
19565 }
19566
19567 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
19568         LDKCommitmentTransaction obj_conv;
19569         obj_conv.inner = (void*)(obj & (~1));
19570         obj_conv.is_owned = false;
19571         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
19572         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19573         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19574         CVec_u8Z_free(ret_var);
19575         return ret_arr;
19576 }
19577
19578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19579         LDKu8slice ser_ref;
19580         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19581         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19582         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
19583         *ret_conv = CommitmentTransaction_read(ser_ref);
19584         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19585         return (long)ret_conv;
19586 }
19587
19588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
19589         LDKCommitmentTransaction this_arg_conv;
19590         this_arg_conv.inner = (void*)(this_arg & (~1));
19591         this_arg_conv.is_owned = false;
19592         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
19593         return ret_val;
19594 }
19595
19596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
19597         LDKCommitmentTransaction this_arg_conv;
19598         this_arg_conv.inner = (void*)(this_arg & (~1));
19599         this_arg_conv.is_owned = false;
19600         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
19601         return ret_val;
19602 }
19603
19604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
19605         LDKCommitmentTransaction this_arg_conv;
19606         this_arg_conv.inner = (void*)(this_arg & (~1));
19607         this_arg_conv.is_owned = false;
19608         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
19609         return ret_val;
19610 }
19611
19612 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
19613         LDKCommitmentTransaction this_arg_conv;
19614         this_arg_conv.inner = (void*)(this_arg & (~1));
19615         this_arg_conv.is_owned = false;
19616         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
19617         return ret_val;
19618 }
19619
19620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
19621         LDKCommitmentTransaction this_arg_conv;
19622         this_arg_conv.inner = (void*)(this_arg & (~1));
19623         this_arg_conv.is_owned = false;
19624         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
19625         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19626         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19627         long ret_ref = (long)ret_var.inner;
19628         if (ret_var.is_owned) {
19629                 ret_ref |= 1;
19630         }
19631         return ret_ref;
19632 }
19633
19634 JNIEXPORT 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) {
19635         LDKCommitmentTransaction this_arg_conv;
19636         this_arg_conv.inner = (void*)(this_arg & (~1));
19637         this_arg_conv.is_owned = false;
19638         LDKDirectedChannelTransactionParameters channel_parameters_conv;
19639         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
19640         channel_parameters_conv.is_owned = false;
19641         LDKChannelPublicKeys broadcaster_keys_conv;
19642         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
19643         broadcaster_keys_conv.is_owned = false;
19644         LDKChannelPublicKeys countersignatory_keys_conv;
19645         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
19646         countersignatory_keys_conv.is_owned = false;
19647         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
19648         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
19649         return (long)ret_conv;
19650 }
19651
19652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19653         LDKTrustedCommitmentTransaction this_obj_conv;
19654         this_obj_conv.inner = (void*)(this_obj & (~1));
19655         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19656         TrustedCommitmentTransaction_free(this_obj_conv);
19657 }
19658
19659 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
19660         LDKTrustedCommitmentTransaction this_arg_conv;
19661         this_arg_conv.inner = (void*)(this_arg & (~1));
19662         this_arg_conv.is_owned = false;
19663         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19664         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
19665         return ret_arr;
19666 }
19667
19668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
19669         LDKTrustedCommitmentTransaction this_arg_conv;
19670         this_arg_conv.inner = (void*)(this_arg & (~1));
19671         this_arg_conv.is_owned = false;
19672         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
19673         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19674         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19675         long ret_ref = (long)ret_var.inner;
19676         if (ret_var.is_owned) {
19677                 ret_ref |= 1;
19678         }
19679         return ret_ref;
19680 }
19681
19682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
19683         LDKTrustedCommitmentTransaction this_arg_conv;
19684         this_arg_conv.inner = (void*)(this_arg & (~1));
19685         this_arg_conv.is_owned = false;
19686         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
19687         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19688         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19689         long ret_ref = (long)ret_var.inner;
19690         if (ret_var.is_owned) {
19691                 ret_ref |= 1;
19692         }
19693         return ret_ref;
19694 }
19695
19696 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) {
19697         LDKTrustedCommitmentTransaction this_arg_conv;
19698         this_arg_conv.inner = (void*)(this_arg & (~1));
19699         this_arg_conv.is_owned = false;
19700         unsigned char htlc_base_key_arr[32];
19701         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
19702         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
19703         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
19704         LDKDirectedChannelTransactionParameters channel_parameters_conv;
19705         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
19706         channel_parameters_conv.is_owned = false;
19707         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
19708         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
19709         return (long)ret_conv;
19710 }
19711
19712 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) {
19713         LDKPublicKey broadcaster_payment_basepoint_ref;
19714         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
19715         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
19716         LDKPublicKey countersignatory_payment_basepoint_ref;
19717         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
19718         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
19719         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
19720         return ret_val;
19721 }
19722
19723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19724         LDKInitFeatures orig_conv;
19725         orig_conv.inner = (void*)(orig & (~1));
19726         orig_conv.is_owned = false;
19727         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
19728         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19729         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19730         long ret_ref = (long)ret_var.inner;
19731         if (ret_var.is_owned) {
19732                 ret_ref |= 1;
19733         }
19734         return ret_ref;
19735 }
19736
19737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19738         LDKNodeFeatures orig_conv;
19739         orig_conv.inner = (void*)(orig & (~1));
19740         orig_conv.is_owned = false;
19741         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
19742         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19743         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19744         long ret_ref = (long)ret_var.inner;
19745         if (ret_var.is_owned) {
19746                 ret_ref |= 1;
19747         }
19748         return ret_ref;
19749 }
19750
19751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19752         LDKChannelFeatures orig_conv;
19753         orig_conv.inner = (void*)(orig & (~1));
19754         orig_conv.is_owned = false;
19755         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
19756         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19757         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19758         long ret_ref = (long)ret_var.inner;
19759         if (ret_var.is_owned) {
19760                 ret_ref |= 1;
19761         }
19762         return ret_ref;
19763 }
19764
19765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19766         LDKInvoiceFeatures orig_conv;
19767         orig_conv.inner = (void*)(orig & (~1));
19768         orig_conv.is_owned = false;
19769         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
19770         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19771         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19772         long ret_ref = (long)ret_var.inner;
19773         if (ret_var.is_owned) {
19774                 ret_ref |= 1;
19775         }
19776         return ret_ref;
19777 }
19778
19779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19780         LDKInitFeatures this_obj_conv;
19781         this_obj_conv.inner = (void*)(this_obj & (~1));
19782         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19783         InitFeatures_free(this_obj_conv);
19784 }
19785
19786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19787         LDKNodeFeatures this_obj_conv;
19788         this_obj_conv.inner = (void*)(this_obj & (~1));
19789         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19790         NodeFeatures_free(this_obj_conv);
19791 }
19792
19793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19794         LDKChannelFeatures this_obj_conv;
19795         this_obj_conv.inner = (void*)(this_obj & (~1));
19796         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19797         ChannelFeatures_free(this_obj_conv);
19798 }
19799
19800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19801         LDKInvoiceFeatures this_obj_conv;
19802         this_obj_conv.inner = (void*)(this_obj & (~1));
19803         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19804         InvoiceFeatures_free(this_obj_conv);
19805 }
19806
19807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
19808         LDKInitFeatures ret_var = InitFeatures_empty();
19809         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19810         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19811         long ret_ref = (long)ret_var.inner;
19812         if (ret_var.is_owned) {
19813                 ret_ref |= 1;
19814         }
19815         return ret_ref;
19816 }
19817
19818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
19819         LDKInitFeatures ret_var = InitFeatures_known();
19820         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19821         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19822         long ret_ref = (long)ret_var.inner;
19823         if (ret_var.is_owned) {
19824                 ret_ref |= 1;
19825         }
19826         return ret_ref;
19827 }
19828
19829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
19830         LDKNodeFeatures ret_var = NodeFeatures_empty();
19831         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19832         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19833         long ret_ref = (long)ret_var.inner;
19834         if (ret_var.is_owned) {
19835                 ret_ref |= 1;
19836         }
19837         return ret_ref;
19838 }
19839
19840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
19841         LDKNodeFeatures ret_var = NodeFeatures_known();
19842         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19843         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19844         long ret_ref = (long)ret_var.inner;
19845         if (ret_var.is_owned) {
19846                 ret_ref |= 1;
19847         }
19848         return ret_ref;
19849 }
19850
19851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
19852         LDKChannelFeatures ret_var = ChannelFeatures_empty();
19853         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19854         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19855         long ret_ref = (long)ret_var.inner;
19856         if (ret_var.is_owned) {
19857                 ret_ref |= 1;
19858         }
19859         return ret_ref;
19860 }
19861
19862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
19863         LDKChannelFeatures ret_var = ChannelFeatures_known();
19864         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19865         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19866         long ret_ref = (long)ret_var.inner;
19867         if (ret_var.is_owned) {
19868                 ret_ref |= 1;
19869         }
19870         return ret_ref;
19871 }
19872
19873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
19874         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
19875         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19876         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19877         long ret_ref = (long)ret_var.inner;
19878         if (ret_var.is_owned) {
19879                 ret_ref |= 1;
19880         }
19881         return ret_ref;
19882 }
19883
19884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
19885         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
19886         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19887         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19888         long ret_ref = (long)ret_var.inner;
19889         if (ret_var.is_owned) {
19890                 ret_ref |= 1;
19891         }
19892         return ret_ref;
19893 }
19894
19895 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19896         LDKInitFeatures obj_conv;
19897         obj_conv.inner = (void*)(obj & (~1));
19898         obj_conv.is_owned = false;
19899         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
19900         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19901         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19902         CVec_u8Z_free(ret_var);
19903         return ret_arr;
19904 }
19905
19906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19907         LDKNodeFeatures obj_conv;
19908         obj_conv.inner = (void*)(obj & (~1));
19909         obj_conv.is_owned = false;
19910         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
19911         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19912         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19913         CVec_u8Z_free(ret_var);
19914         return ret_arr;
19915 }
19916
19917 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19918         LDKChannelFeatures obj_conv;
19919         obj_conv.inner = (void*)(obj & (~1));
19920         obj_conv.is_owned = false;
19921         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
19922         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19923         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19924         CVec_u8Z_free(ret_var);
19925         return ret_arr;
19926 }
19927
19928 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19929         LDKInvoiceFeatures obj_conv;
19930         obj_conv.inner = (void*)(obj & (~1));
19931         obj_conv.is_owned = false;
19932         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
19933         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19934         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19935         CVec_u8Z_free(ret_var);
19936         return ret_arr;
19937 }
19938
19939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19940         LDKu8slice ser_ref;
19941         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19942         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19943         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
19944         *ret_conv = InitFeatures_read(ser_ref);
19945         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19946         return (long)ret_conv;
19947 }
19948
19949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19950         LDKu8slice ser_ref;
19951         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19952         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19953         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
19954         *ret_conv = NodeFeatures_read(ser_ref);
19955         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19956         return (long)ret_conv;
19957 }
19958
19959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19960         LDKu8slice ser_ref;
19961         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19962         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19963         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
19964         *ret_conv = ChannelFeatures_read(ser_ref);
19965         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19966         return (long)ret_conv;
19967 }
19968
19969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19970         LDKu8slice ser_ref;
19971         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19972         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19973         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
19974         *ret_conv = InvoiceFeatures_read(ser_ref);
19975         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19976         return (long)ret_conv;
19977 }
19978
19979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19980         LDKRouteHop this_obj_conv;
19981         this_obj_conv.inner = (void*)(this_obj & (~1));
19982         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19983         RouteHop_free(this_obj_conv);
19984 }
19985
19986 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
19987         LDKRouteHop this_ptr_conv;
19988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19989         this_ptr_conv.is_owned = false;
19990         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19991         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
19992         return ret_arr;
19993 }
19994
19995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19996         LDKRouteHop this_ptr_conv;
19997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19998         this_ptr_conv.is_owned = false;
19999         LDKPublicKey val_ref;
20000         CHECK((*env)->GetArrayLength(env, val) == 33);
20001         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20002         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
20003 }
20004
20005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20006         LDKRouteHop this_ptr_conv;
20007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20008         this_ptr_conv.is_owned = false;
20009         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
20010         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20011         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20012         long ret_ref = (long)ret_var.inner;
20013         if (ret_var.is_owned) {
20014                 ret_ref |= 1;
20015         }
20016         return ret_ref;
20017 }
20018
20019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20020         LDKRouteHop this_ptr_conv;
20021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20022         this_ptr_conv.is_owned = false;
20023         LDKNodeFeatures val_conv;
20024         val_conv.inner = (void*)(val & (~1));
20025         val_conv.is_owned = (val & 1) || (val == 0);
20026         val_conv = NodeFeatures_clone(&val_conv);
20027         RouteHop_set_node_features(&this_ptr_conv, val_conv);
20028 }
20029
20030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20031         LDKRouteHop this_ptr_conv;
20032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20033         this_ptr_conv.is_owned = false;
20034         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
20035         return ret_val;
20036 }
20037
20038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20039         LDKRouteHop this_ptr_conv;
20040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20041         this_ptr_conv.is_owned = false;
20042         RouteHop_set_short_channel_id(&this_ptr_conv, val);
20043 }
20044
20045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20046         LDKRouteHop this_ptr_conv;
20047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20048         this_ptr_conv.is_owned = false;
20049         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
20050         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20051         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20052         long ret_ref = (long)ret_var.inner;
20053         if (ret_var.is_owned) {
20054                 ret_ref |= 1;
20055         }
20056         return ret_ref;
20057 }
20058
20059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20060         LDKRouteHop this_ptr_conv;
20061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20062         this_ptr_conv.is_owned = false;
20063         LDKChannelFeatures val_conv;
20064         val_conv.inner = (void*)(val & (~1));
20065         val_conv.is_owned = (val & 1) || (val == 0);
20066         val_conv = ChannelFeatures_clone(&val_conv);
20067         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
20068 }
20069
20070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20071         LDKRouteHop this_ptr_conv;
20072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20073         this_ptr_conv.is_owned = false;
20074         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
20075         return ret_val;
20076 }
20077
20078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20079         LDKRouteHop this_ptr_conv;
20080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20081         this_ptr_conv.is_owned = false;
20082         RouteHop_set_fee_msat(&this_ptr_conv, val);
20083 }
20084
20085 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
20086         LDKRouteHop this_ptr_conv;
20087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20088         this_ptr_conv.is_owned = false;
20089         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
20090         return ret_val;
20091 }
20092
20093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20094         LDKRouteHop this_ptr_conv;
20095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20096         this_ptr_conv.is_owned = false;
20097         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
20098 }
20099
20100 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) {
20101         LDKPublicKey pubkey_arg_ref;
20102         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
20103         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
20104         LDKNodeFeatures node_features_arg_conv;
20105         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
20106         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
20107         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
20108         LDKChannelFeatures channel_features_arg_conv;
20109         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
20110         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
20111         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
20112         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);
20113         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20114         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20115         long ret_ref = (long)ret_var.inner;
20116         if (ret_var.is_owned) {
20117                 ret_ref |= 1;
20118         }
20119         return ret_ref;
20120 }
20121
20122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20123         LDKRouteHop orig_conv;
20124         orig_conv.inner = (void*)(orig & (~1));
20125         orig_conv.is_owned = false;
20126         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
20127         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20128         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20129         long ret_ref = (long)ret_var.inner;
20130         if (ret_var.is_owned) {
20131                 ret_ref |= 1;
20132         }
20133         return ret_ref;
20134 }
20135
20136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20137         LDKRoute this_obj_conv;
20138         this_obj_conv.inner = (void*)(this_obj & (~1));
20139         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20140         Route_free(this_obj_conv);
20141 }
20142
20143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
20144         LDKRoute this_ptr_conv;
20145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20146         this_ptr_conv.is_owned = false;
20147         LDKCVec_CVec_RouteHopZZ val_constr;
20148         val_constr.datalen = (*env)->GetArrayLength(env, val);
20149         if (val_constr.datalen > 0)
20150                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
20151         else
20152                 val_constr.data = NULL;
20153         for (size_t m = 0; m < val_constr.datalen; m++) {
20154                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
20155                 LDKCVec_RouteHopZ val_conv_12_constr;
20156                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
20157                 if (val_conv_12_constr.datalen > 0)
20158                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20159                 else
20160                         val_conv_12_constr.data = NULL;
20161                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
20162                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
20163                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
20164                         LDKRouteHop val_conv_12_conv_10_conv;
20165                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
20166                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
20167                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
20168                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
20169                 }
20170                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
20171                 val_constr.data[m] = val_conv_12_constr;
20172         }
20173         Route_set_paths(&this_ptr_conv, val_constr);
20174 }
20175
20176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
20177         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
20178         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
20179         if (paths_arg_constr.datalen > 0)
20180                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
20181         else
20182                 paths_arg_constr.data = NULL;
20183         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
20184                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
20185                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
20186                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
20187                 if (paths_arg_conv_12_constr.datalen > 0)
20188                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20189                 else
20190                         paths_arg_conv_12_constr.data = NULL;
20191                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
20192                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
20193                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
20194                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
20195                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
20196                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
20197                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
20198                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
20199                 }
20200                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
20201                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
20202         }
20203         LDKRoute ret_var = Route_new(paths_arg_constr);
20204         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20205         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20206         long ret_ref = (long)ret_var.inner;
20207         if (ret_var.is_owned) {
20208                 ret_ref |= 1;
20209         }
20210         return ret_ref;
20211 }
20212
20213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20214         LDKRoute orig_conv;
20215         orig_conv.inner = (void*)(orig & (~1));
20216         orig_conv.is_owned = false;
20217         LDKRoute ret_var = Route_clone(&orig_conv);
20218         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20219         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20220         long ret_ref = (long)ret_var.inner;
20221         if (ret_var.is_owned) {
20222                 ret_ref |= 1;
20223         }
20224         return ret_ref;
20225 }
20226
20227 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
20228         LDKRoute obj_conv;
20229         obj_conv.inner = (void*)(obj & (~1));
20230         obj_conv.is_owned = false;
20231         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
20232         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20233         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20234         CVec_u8Z_free(ret_var);
20235         return ret_arr;
20236 }
20237
20238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20239         LDKu8slice ser_ref;
20240         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20241         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20242         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
20243         *ret_conv = Route_read(ser_ref);
20244         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20245         return (long)ret_conv;
20246 }
20247
20248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20249         LDKRouteHint this_obj_conv;
20250         this_obj_conv.inner = (void*)(this_obj & (~1));
20251         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20252         RouteHint_free(this_obj_conv);
20253 }
20254
20255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20256         LDKRouteHint this_ptr_conv;
20257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20258         this_ptr_conv.is_owned = false;
20259         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20260         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHint_get_src_node_id(&this_ptr_conv).compressed_form);
20261         return ret_arr;
20262 }
20263
20264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20265         LDKRouteHint this_ptr_conv;
20266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20267         this_ptr_conv.is_owned = false;
20268         LDKPublicKey val_ref;
20269         CHECK((*env)->GetArrayLength(env, val) == 33);
20270         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20271         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
20272 }
20273
20274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20275         LDKRouteHint this_ptr_conv;
20276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20277         this_ptr_conv.is_owned = false;
20278         int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
20279         return ret_val;
20280 }
20281
20282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20283         LDKRouteHint this_ptr_conv;
20284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20285         this_ptr_conv.is_owned = false;
20286         RouteHint_set_short_channel_id(&this_ptr_conv, val);
20287 }
20288
20289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
20290         LDKRouteHint this_ptr_conv;
20291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20292         this_ptr_conv.is_owned = false;
20293         LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
20294         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20295         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20296         long ret_ref = (long)ret_var.inner;
20297         if (ret_var.is_owned) {
20298                 ret_ref |= 1;
20299         }
20300         return ret_ref;
20301 }
20302
20303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20304         LDKRouteHint this_ptr_conv;
20305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20306         this_ptr_conv.is_owned = false;
20307         LDKRoutingFees val_conv;
20308         val_conv.inner = (void*)(val & (~1));
20309         val_conv.is_owned = (val & 1) || (val == 0);
20310         val_conv = RoutingFees_clone(&val_conv);
20311         RouteHint_set_fees(&this_ptr_conv, val_conv);
20312 }
20313
20314 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
20315         LDKRouteHint this_ptr_conv;
20316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20317         this_ptr_conv.is_owned = false;
20318         int16_t ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
20319         return ret_val;
20320 }
20321
20322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20323         LDKRouteHint this_ptr_conv;
20324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20325         this_ptr_conv.is_owned = false;
20326         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
20327 }
20328
20329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20330         LDKRouteHint this_ptr_conv;
20331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20332         this_ptr_conv.is_owned = false;
20333         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20334         *ret_copy = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
20335         long ret_ref = (long)ret_copy;
20336         return ret_ref;
20337 }
20338
20339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20340         LDKRouteHint this_ptr_conv;
20341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20342         this_ptr_conv.is_owned = false;
20343         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20344         FREE((void*)val);
20345         RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
20346 }
20347
20348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20349         LDKRouteHint this_ptr_conv;
20350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20351         this_ptr_conv.is_owned = false;
20352         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20353         *ret_copy = RouteHint_get_htlc_maximum_msat(&this_ptr_conv);
20354         long ret_ref = (long)ret_copy;
20355         return ret_ref;
20356 }
20357
20358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20359         LDKRouteHint this_ptr_conv;
20360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20361         this_ptr_conv.is_owned = false;
20362         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20363         FREE((void*)val);
20364         RouteHint_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
20365 }
20366
20367 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) {
20368         LDKPublicKey src_node_id_arg_ref;
20369         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
20370         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
20371         LDKRoutingFees fees_arg_conv;
20372         fees_arg_conv.inner = (void*)(fees_arg & (~1));
20373         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
20374         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
20375         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
20376         FREE((void*)htlc_minimum_msat_arg);
20377         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
20378         FREE((void*)htlc_maximum_msat_arg);
20379         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);
20380         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20381         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20382         long ret_ref = (long)ret_var.inner;
20383         if (ret_var.is_owned) {
20384                 ret_ref |= 1;
20385         }
20386         return ret_ref;
20387 }
20388
20389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20390         LDKRouteHint orig_conv;
20391         orig_conv.inner = (void*)(orig & (~1));
20392         orig_conv.is_owned = false;
20393         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
20394         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20395         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20396         long ret_ref = (long)ret_var.inner;
20397         if (ret_var.is_owned) {
20398                 ret_ref |= 1;
20399         }
20400         return ret_ref;
20401 }
20402
20403 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) {
20404         LDKPublicKey our_node_id_ref;
20405         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
20406         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
20407         LDKNetworkGraph network_conv;
20408         network_conv.inner = (void*)(network & (~1));
20409         network_conv.is_owned = false;
20410         LDKPublicKey payee_ref;
20411         CHECK((*env)->GetArrayLength(env, payee) == 33);
20412         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
20413         LDKInvoiceFeatures payee_features_conv;
20414         payee_features_conv.inner = (void*)(payee_features & (~1));
20415         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
20416         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
20417         LDKCVec_ChannelDetailsZ first_hops_constr;
20418         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
20419         if (first_hops_constr.datalen > 0)
20420                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
20421         else
20422                 first_hops_constr.data = NULL;
20423         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
20424         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
20425                 int64_t first_hops_conv_16 = first_hops_vals[q];
20426                 LDKChannelDetails first_hops_conv_16_conv;
20427                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
20428                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
20429                 first_hops_constr.data[q] = first_hops_conv_16_conv;
20430         }
20431         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
20432         LDKCVec_RouteHintZ last_hops_constr;
20433         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
20434         if (last_hops_constr.datalen > 0)
20435                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
20436         else
20437                 last_hops_constr.data = NULL;
20438         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
20439         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
20440                 int64_t last_hops_conv_11 = last_hops_vals[l];
20441                 LDKRouteHint last_hops_conv_11_conv;
20442                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
20443                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
20444                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
20445                 last_hops_constr.data[l] = last_hops_conv_11_conv;
20446         }
20447         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
20448         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20449         if (logger_conv.free == LDKLogger_JCalls_free) {
20450                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20451                 LDKLogger_JCalls_clone(logger_conv.this_arg);
20452         }
20453         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
20454         *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);
20455         FREE(first_hops_constr.data);
20456         return (long)ret_conv;
20457 }
20458
20459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20460         LDKNetworkGraph this_obj_conv;
20461         this_obj_conv.inner = (void*)(this_obj & (~1));
20462         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20463         NetworkGraph_free(this_obj_conv);
20464 }
20465
20466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20467         LDKNetworkGraph orig_conv;
20468         orig_conv.inner = (void*)(orig & (~1));
20469         orig_conv.is_owned = false;
20470         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
20471         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20472         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20473         long ret_ref = (long)ret_var.inner;
20474         if (ret_var.is_owned) {
20475                 ret_ref |= 1;
20476         }
20477         return ret_ref;
20478 }
20479
20480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20481         LDKLockedNetworkGraph this_obj_conv;
20482         this_obj_conv.inner = (void*)(this_obj & (~1));
20483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20484         LockedNetworkGraph_free(this_obj_conv);
20485 }
20486
20487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20488         LDKNetGraphMsgHandler this_obj_conv;
20489         this_obj_conv.inner = (void*)(this_obj & (~1));
20490         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20491         NetGraphMsgHandler_free(this_obj_conv);
20492 }
20493
20494 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) {
20495         LDKThirtyTwoBytes genesis_hash_ref;
20496         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
20497         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
20498         LDKAccess *chain_access_conv_ptr = NULL;
20499         if (chain_access != 0) {
20500                 LDKAccess chain_access_conv;
20501                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20502                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
20503                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20504                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
20505                 }
20506                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20507                 *chain_access_conv_ptr = chain_access_conv;
20508         }
20509         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20510         if (logger_conv.free == LDKLogger_JCalls_free) {
20511                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20512                 LDKLogger_JCalls_clone(logger_conv.this_arg);
20513         }
20514         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
20515         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20516         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20517         long ret_ref = (long)ret_var.inner;
20518         if (ret_var.is_owned) {
20519                 ret_ref |= 1;
20520         }
20521         return ret_ref;
20522 }
20523
20524 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) {
20525         LDKAccess *chain_access_conv_ptr = NULL;
20526         if (chain_access != 0) {
20527                 LDKAccess chain_access_conv;
20528                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20529                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
20530                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20531                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
20532                 }
20533                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20534                 *chain_access_conv_ptr = chain_access_conv;
20535         }
20536         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20537         if (logger_conv.free == LDKLogger_JCalls_free) {
20538                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20539                 LDKLogger_JCalls_clone(logger_conv.this_arg);
20540         }
20541         LDKNetworkGraph network_graph_conv;
20542         network_graph_conv.inner = (void*)(network_graph & (~1));
20543         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
20544         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
20545         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
20546         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20547         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20548         long ret_ref = (long)ret_var.inner;
20549         if (ret_var.is_owned) {
20550                 ret_ref |= 1;
20551         }
20552         return ret_ref;
20553 }
20554
20555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
20556         LDKNetGraphMsgHandler this_arg_conv;
20557         this_arg_conv.inner = (void*)(this_arg & (~1));
20558         this_arg_conv.is_owned = false;
20559         LDKAccess *chain_access_conv_ptr = NULL;
20560         if (chain_access != 0) {
20561                 LDKAccess chain_access_conv;
20562                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20563                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
20564                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20565                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
20566                 }
20567                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20568                 *chain_access_conv_ptr = chain_access_conv;
20569         }
20570         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
20571 }
20572
20573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
20574         LDKNetGraphMsgHandler this_arg_conv;
20575         this_arg_conv.inner = (void*)(this_arg & (~1));
20576         this_arg_conv.is_owned = false;
20577         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
20578         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20579         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20580         long ret_ref = (long)ret_var.inner;
20581         if (ret_var.is_owned) {
20582                 ret_ref |= 1;
20583         }
20584         return ret_ref;
20585 }
20586
20587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
20588         LDKLockedNetworkGraph this_arg_conv;
20589         this_arg_conv.inner = (void*)(this_arg & (~1));
20590         this_arg_conv.is_owned = false;
20591         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
20592         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20593         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20594         long ret_ref = (long)ret_var.inner;
20595         if (ret_var.is_owned) {
20596                 ret_ref |= 1;
20597         }
20598         return ret_ref;
20599 }
20600
20601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
20602         LDKNetGraphMsgHandler this_arg_conv;
20603         this_arg_conv.inner = (void*)(this_arg & (~1));
20604         this_arg_conv.is_owned = false;
20605         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
20606         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
20607         return (long)ret;
20608 }
20609
20610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
20611         LDKNetGraphMsgHandler this_arg_conv;
20612         this_arg_conv.inner = (void*)(this_arg & (~1));
20613         this_arg_conv.is_owned = false;
20614         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20615         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
20616         return (long)ret;
20617 }
20618
20619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20620         LDKDirectionalChannelInfo this_obj_conv;
20621         this_obj_conv.inner = (void*)(this_obj & (~1));
20622         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20623         DirectionalChannelInfo_free(this_obj_conv);
20624 }
20625
20626 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
20627         LDKDirectionalChannelInfo this_ptr_conv;
20628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20629         this_ptr_conv.is_owned = false;
20630         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
20631         return ret_val;
20632 }
20633
20634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20635         LDKDirectionalChannelInfo this_ptr_conv;
20636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20637         this_ptr_conv.is_owned = false;
20638         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
20639 }
20640
20641 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
20642         LDKDirectionalChannelInfo this_ptr_conv;
20643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20644         this_ptr_conv.is_owned = false;
20645         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
20646         return ret_val;
20647 }
20648
20649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20650         LDKDirectionalChannelInfo this_ptr_conv;
20651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20652         this_ptr_conv.is_owned = false;
20653         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
20654 }
20655
20656 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
20657         LDKDirectionalChannelInfo this_ptr_conv;
20658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20659         this_ptr_conv.is_owned = false;
20660         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
20661         return ret_val;
20662 }
20663
20664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20665         LDKDirectionalChannelInfo this_ptr_conv;
20666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20667         this_ptr_conv.is_owned = false;
20668         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
20669 }
20670
20671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20672         LDKDirectionalChannelInfo this_ptr_conv;
20673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20674         this_ptr_conv.is_owned = false;
20675         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
20676         return ret_val;
20677 }
20678
20679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20680         LDKDirectionalChannelInfo this_ptr_conv;
20681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20682         this_ptr_conv.is_owned = false;
20683         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
20684 }
20685
20686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20687         LDKDirectionalChannelInfo this_ptr_conv;
20688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20689         this_ptr_conv.is_owned = false;
20690         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20691         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
20692         long ret_ref = (long)ret_copy;
20693         return ret_ref;
20694 }
20695
20696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20697         LDKDirectionalChannelInfo this_ptr_conv;
20698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20699         this_ptr_conv.is_owned = false;
20700         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20701         FREE((void*)val);
20702         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
20703 }
20704
20705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
20706         LDKDirectionalChannelInfo this_ptr_conv;
20707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20708         this_ptr_conv.is_owned = false;
20709         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
20710         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20711         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20712         long ret_ref = (long)ret_var.inner;
20713         if (ret_var.is_owned) {
20714                 ret_ref |= 1;
20715         }
20716         return ret_ref;
20717 }
20718
20719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20720         LDKDirectionalChannelInfo this_ptr_conv;
20721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20722         this_ptr_conv.is_owned = false;
20723         LDKRoutingFees val_conv;
20724         val_conv.inner = (void*)(val & (~1));
20725         val_conv.is_owned = (val & 1) || (val == 0);
20726         val_conv = RoutingFees_clone(&val_conv);
20727         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
20728 }
20729
20730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
20731         LDKDirectionalChannelInfo this_ptr_conv;
20732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20733         this_ptr_conv.is_owned = false;
20734         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
20735         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20736         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20737         long ret_ref = (long)ret_var.inner;
20738         if (ret_var.is_owned) {
20739                 ret_ref |= 1;
20740         }
20741         return ret_ref;
20742 }
20743
20744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20745         LDKDirectionalChannelInfo this_ptr_conv;
20746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20747         this_ptr_conv.is_owned = false;
20748         LDKChannelUpdate val_conv;
20749         val_conv.inner = (void*)(val & (~1));
20750         val_conv.is_owned = (val & 1) || (val == 0);
20751         val_conv = ChannelUpdate_clone(&val_conv);
20752         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
20753 }
20754
20755 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) {
20756         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
20757         FREE((void*)htlc_maximum_msat_arg);
20758         LDKRoutingFees fees_arg_conv;
20759         fees_arg_conv.inner = (void*)(fees_arg & (~1));
20760         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
20761         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
20762         LDKChannelUpdate last_update_message_arg_conv;
20763         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
20764         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
20765         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
20766         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);
20767         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20768         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20769         long ret_ref = (long)ret_var.inner;
20770         if (ret_var.is_owned) {
20771                 ret_ref |= 1;
20772         }
20773         return ret_ref;
20774 }
20775
20776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20777         LDKDirectionalChannelInfo orig_conv;
20778         orig_conv.inner = (void*)(orig & (~1));
20779         orig_conv.is_owned = false;
20780         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
20781         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20782         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20783         long ret_ref = (long)ret_var.inner;
20784         if (ret_var.is_owned) {
20785                 ret_ref |= 1;
20786         }
20787         return ret_ref;
20788 }
20789
20790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
20791         LDKDirectionalChannelInfo obj_conv;
20792         obj_conv.inner = (void*)(obj & (~1));
20793         obj_conv.is_owned = false;
20794         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
20795         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20796         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20797         CVec_u8Z_free(ret_var);
20798         return ret_arr;
20799 }
20800
20801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20802         LDKu8slice ser_ref;
20803         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20804         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20805         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
20806         *ret_conv = DirectionalChannelInfo_read(ser_ref);
20807         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20808         return (long)ret_conv;
20809 }
20810
20811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20812         LDKChannelInfo this_obj_conv;
20813         this_obj_conv.inner = (void*)(this_obj & (~1));
20814         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20815         ChannelInfo_free(this_obj_conv);
20816 }
20817
20818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20819         LDKChannelInfo this_ptr_conv;
20820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20821         this_ptr_conv.is_owned = false;
20822         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
20823         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20824         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20825         long ret_ref = (long)ret_var.inner;
20826         if (ret_var.is_owned) {
20827                 ret_ref |= 1;
20828         }
20829         return ret_ref;
20830 }
20831
20832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20833         LDKChannelInfo this_ptr_conv;
20834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20835         this_ptr_conv.is_owned = false;
20836         LDKChannelFeatures val_conv;
20837         val_conv.inner = (void*)(val & (~1));
20838         val_conv.is_owned = (val & 1) || (val == 0);
20839         val_conv = ChannelFeatures_clone(&val_conv);
20840         ChannelInfo_set_features(&this_ptr_conv, val_conv);
20841 }
20842
20843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
20844         LDKChannelInfo this_ptr_conv;
20845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20846         this_ptr_conv.is_owned = false;
20847         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20848         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
20849         return ret_arr;
20850 }
20851
20852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20853         LDKChannelInfo this_ptr_conv;
20854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20855         this_ptr_conv.is_owned = false;
20856         LDKPublicKey val_ref;
20857         CHECK((*env)->GetArrayLength(env, val) == 33);
20858         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20859         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
20860 }
20861
20862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
20863         LDKChannelInfo this_ptr_conv;
20864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20865         this_ptr_conv.is_owned = false;
20866         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
20867         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20868         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20869         long ret_ref = (long)ret_var.inner;
20870         if (ret_var.is_owned) {
20871                 ret_ref |= 1;
20872         }
20873         return ret_ref;
20874 }
20875
20876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20877         LDKChannelInfo this_ptr_conv;
20878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20879         this_ptr_conv.is_owned = false;
20880         LDKDirectionalChannelInfo val_conv;
20881         val_conv.inner = (void*)(val & (~1));
20882         val_conv.is_owned = (val & 1) || (val == 0);
20883         val_conv = DirectionalChannelInfo_clone(&val_conv);
20884         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
20885 }
20886
20887 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
20888         LDKChannelInfo this_ptr_conv;
20889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20890         this_ptr_conv.is_owned = false;
20891         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20892         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
20893         return ret_arr;
20894 }
20895
20896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20897         LDKChannelInfo this_ptr_conv;
20898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20899         this_ptr_conv.is_owned = false;
20900         LDKPublicKey val_ref;
20901         CHECK((*env)->GetArrayLength(env, val) == 33);
20902         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20903         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
20904 }
20905
20906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
20907         LDKChannelInfo this_ptr_conv;
20908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20909         this_ptr_conv.is_owned = false;
20910         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
20911         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20912         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20913         long ret_ref = (long)ret_var.inner;
20914         if (ret_var.is_owned) {
20915                 ret_ref |= 1;
20916         }
20917         return ret_ref;
20918 }
20919
20920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20921         LDKChannelInfo this_ptr_conv;
20922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20923         this_ptr_conv.is_owned = false;
20924         LDKDirectionalChannelInfo val_conv;
20925         val_conv.inner = (void*)(val & (~1));
20926         val_conv.is_owned = (val & 1) || (val == 0);
20927         val_conv = DirectionalChannelInfo_clone(&val_conv);
20928         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
20929 }
20930
20931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
20932         LDKChannelInfo this_ptr_conv;
20933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20934         this_ptr_conv.is_owned = false;
20935         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20936         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
20937         long ret_ref = (long)ret_copy;
20938         return ret_ref;
20939 }
20940
20941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20942         LDKChannelInfo this_ptr_conv;
20943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20944         this_ptr_conv.is_owned = false;
20945         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20946         FREE((void*)val);
20947         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
20948 }
20949
20950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
20951         LDKChannelInfo this_ptr_conv;
20952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20953         this_ptr_conv.is_owned = false;
20954         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
20955         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20956         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20957         long ret_ref = (long)ret_var.inner;
20958         if (ret_var.is_owned) {
20959                 ret_ref |= 1;
20960         }
20961         return ret_ref;
20962 }
20963
20964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20965         LDKChannelInfo this_ptr_conv;
20966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20967         this_ptr_conv.is_owned = false;
20968         LDKChannelAnnouncement val_conv;
20969         val_conv.inner = (void*)(val & (~1));
20970         val_conv.is_owned = (val & 1) || (val == 0);
20971         val_conv = ChannelAnnouncement_clone(&val_conv);
20972         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
20973 }
20974
20975 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) {
20976         LDKChannelFeatures features_arg_conv;
20977         features_arg_conv.inner = (void*)(features_arg & (~1));
20978         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
20979         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
20980         LDKPublicKey node_one_arg_ref;
20981         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
20982         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
20983         LDKDirectionalChannelInfo one_to_two_arg_conv;
20984         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
20985         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
20986         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
20987         LDKPublicKey node_two_arg_ref;
20988         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
20989         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
20990         LDKDirectionalChannelInfo two_to_one_arg_conv;
20991         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
20992         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
20993         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
20994         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
20995         FREE((void*)capacity_sats_arg);
20996         LDKChannelAnnouncement announcement_message_arg_conv;
20997         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
20998         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
20999         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
21000         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);
21001         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21002         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21003         long ret_ref = (long)ret_var.inner;
21004         if (ret_var.is_owned) {
21005                 ret_ref |= 1;
21006         }
21007         return ret_ref;
21008 }
21009
21010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21011         LDKChannelInfo orig_conv;
21012         orig_conv.inner = (void*)(orig & (~1));
21013         orig_conv.is_owned = false;
21014         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
21015         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21016         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21017         long ret_ref = (long)ret_var.inner;
21018         if (ret_var.is_owned) {
21019                 ret_ref |= 1;
21020         }
21021         return ret_ref;
21022 }
21023
21024 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
21025         LDKChannelInfo obj_conv;
21026         obj_conv.inner = (void*)(obj & (~1));
21027         obj_conv.is_owned = false;
21028         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
21029         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21030         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21031         CVec_u8Z_free(ret_var);
21032         return ret_arr;
21033 }
21034
21035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21036         LDKu8slice ser_ref;
21037         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21038         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21039         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
21040         *ret_conv = ChannelInfo_read(ser_ref);
21041         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21042         return (long)ret_conv;
21043 }
21044
21045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21046         LDKRoutingFees this_obj_conv;
21047         this_obj_conv.inner = (void*)(this_obj & (~1));
21048         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21049         RoutingFees_free(this_obj_conv);
21050 }
21051
21052 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21053         LDKRoutingFees this_ptr_conv;
21054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21055         this_ptr_conv.is_owned = false;
21056         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
21057         return ret_val;
21058 }
21059
21060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21061         LDKRoutingFees this_ptr_conv;
21062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21063         this_ptr_conv.is_owned = false;
21064         RoutingFees_set_base_msat(&this_ptr_conv, val);
21065 }
21066
21067 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
21068         LDKRoutingFees this_ptr_conv;
21069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21070         this_ptr_conv.is_owned = false;
21071         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
21072         return ret_val;
21073 }
21074
21075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21076         LDKRoutingFees this_ptr_conv;
21077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21078         this_ptr_conv.is_owned = false;
21079         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
21080 }
21081
21082 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) {
21083         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
21084         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21085         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21086         long ret_ref = (long)ret_var.inner;
21087         if (ret_var.is_owned) {
21088                 ret_ref |= 1;
21089         }
21090         return ret_ref;
21091 }
21092
21093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21094         LDKRoutingFees orig_conv;
21095         orig_conv.inner = (void*)(orig & (~1));
21096         orig_conv.is_owned = false;
21097         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
21098         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21099         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21100         long ret_ref = (long)ret_var.inner;
21101         if (ret_var.is_owned) {
21102                 ret_ref |= 1;
21103         }
21104         return ret_ref;
21105 }
21106
21107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21108         LDKu8slice ser_ref;
21109         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21110         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21111         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
21112         *ret_conv = RoutingFees_read(ser_ref);
21113         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21114         return (long)ret_conv;
21115 }
21116
21117 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
21118         LDKRoutingFees obj_conv;
21119         obj_conv.inner = (void*)(obj & (~1));
21120         obj_conv.is_owned = false;
21121         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
21122         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21123         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21124         CVec_u8Z_free(ret_var);
21125         return ret_arr;
21126 }
21127
21128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21129         LDKNodeAnnouncementInfo this_obj_conv;
21130         this_obj_conv.inner = (void*)(this_obj & (~1));
21131         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21132         NodeAnnouncementInfo_free(this_obj_conv);
21133 }
21134
21135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
21136         LDKNodeAnnouncementInfo this_ptr_conv;
21137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21138         this_ptr_conv.is_owned = false;
21139         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
21140         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21141         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21142         long ret_ref = (long)ret_var.inner;
21143         if (ret_var.is_owned) {
21144                 ret_ref |= 1;
21145         }
21146         return ret_ref;
21147 }
21148
21149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21150         LDKNodeAnnouncementInfo this_ptr_conv;
21151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21152         this_ptr_conv.is_owned = false;
21153         LDKNodeFeatures val_conv;
21154         val_conv.inner = (void*)(val & (~1));
21155         val_conv.is_owned = (val & 1) || (val == 0);
21156         val_conv = NodeFeatures_clone(&val_conv);
21157         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
21158 }
21159
21160 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
21161         LDKNodeAnnouncementInfo this_ptr_conv;
21162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21163         this_ptr_conv.is_owned = false;
21164         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
21165         return ret_val;
21166 }
21167
21168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21169         LDKNodeAnnouncementInfo this_ptr_conv;
21170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21171         this_ptr_conv.is_owned = false;
21172         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
21173 }
21174
21175 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
21176         LDKNodeAnnouncementInfo this_ptr_conv;
21177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21178         this_ptr_conv.is_owned = false;
21179         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
21180         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
21181         return ret_arr;
21182 }
21183
21184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21185         LDKNodeAnnouncementInfo this_ptr_conv;
21186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21187         this_ptr_conv.is_owned = false;
21188         LDKThreeBytes val_ref;
21189         CHECK((*env)->GetArrayLength(env, val) == 3);
21190         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
21191         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
21192 }
21193
21194 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
21195         LDKNodeAnnouncementInfo this_ptr_conv;
21196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21197         this_ptr_conv.is_owned = false;
21198         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21199         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
21200         return ret_arr;
21201 }
21202
21203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21204         LDKNodeAnnouncementInfo this_ptr_conv;
21205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21206         this_ptr_conv.is_owned = false;
21207         LDKThirtyTwoBytes val_ref;
21208         CHECK((*env)->GetArrayLength(env, val) == 32);
21209         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21210         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
21211 }
21212
21213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
21214         LDKNodeAnnouncementInfo this_ptr_conv;
21215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21216         this_ptr_conv.is_owned = false;
21217         LDKCVec_NetAddressZ val_constr;
21218         val_constr.datalen = (*env)->GetArrayLength(env, val);
21219         if (val_constr.datalen > 0)
21220                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21221         else
21222                 val_constr.data = NULL;
21223         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
21224         for (size_t m = 0; m < val_constr.datalen; m++) {
21225                 int64_t val_conv_12 = val_vals[m];
21226                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
21227                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
21228                 val_constr.data[m] = val_conv_12_conv;
21229         }
21230         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
21231         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
21232 }
21233
21234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
21235         LDKNodeAnnouncementInfo this_ptr_conv;
21236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21237         this_ptr_conv.is_owned = false;
21238         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
21239         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21240         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21241         long ret_ref = (long)ret_var.inner;
21242         if (ret_var.is_owned) {
21243                 ret_ref |= 1;
21244         }
21245         return ret_ref;
21246 }
21247
21248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21249         LDKNodeAnnouncementInfo this_ptr_conv;
21250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21251         this_ptr_conv.is_owned = false;
21252         LDKNodeAnnouncement val_conv;
21253         val_conv.inner = (void*)(val & (~1));
21254         val_conv.is_owned = (val & 1) || (val == 0);
21255         val_conv = NodeAnnouncement_clone(&val_conv);
21256         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
21257 }
21258
21259 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) {
21260         LDKNodeFeatures features_arg_conv;
21261         features_arg_conv.inner = (void*)(features_arg & (~1));
21262         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
21263         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
21264         LDKThreeBytes rgb_arg_ref;
21265         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
21266         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
21267         LDKThirtyTwoBytes alias_arg_ref;
21268         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
21269         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
21270         LDKCVec_NetAddressZ addresses_arg_constr;
21271         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
21272         if (addresses_arg_constr.datalen > 0)
21273                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21274         else
21275                 addresses_arg_constr.data = NULL;
21276         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
21277         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
21278                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
21279                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
21280                 FREE((void*)addresses_arg_conv_12);
21281                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
21282         }
21283         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
21284         LDKNodeAnnouncement announcement_message_arg_conv;
21285         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
21286         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
21287         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
21288         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
21289         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21290         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21291         long ret_ref = (long)ret_var.inner;
21292         if (ret_var.is_owned) {
21293                 ret_ref |= 1;
21294         }
21295         return ret_ref;
21296 }
21297
21298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21299         LDKNodeAnnouncementInfo orig_conv;
21300         orig_conv.inner = (void*)(orig & (~1));
21301         orig_conv.is_owned = false;
21302         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
21303         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21304         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21305         long ret_ref = (long)ret_var.inner;
21306         if (ret_var.is_owned) {
21307                 ret_ref |= 1;
21308         }
21309         return ret_ref;
21310 }
21311
21312 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
21313         LDKNodeAnnouncementInfo obj_conv;
21314         obj_conv.inner = (void*)(obj & (~1));
21315         obj_conv.is_owned = false;
21316         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
21317         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21318         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21319         CVec_u8Z_free(ret_var);
21320         return ret_arr;
21321 }
21322
21323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21324         LDKu8slice ser_ref;
21325         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21326         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21327         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
21328         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
21329         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21330         return (long)ret_conv;
21331 }
21332
21333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21334         LDKNodeInfo this_obj_conv;
21335         this_obj_conv.inner = (void*)(this_obj & (~1));
21336         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21337         NodeInfo_free(this_obj_conv);
21338 }
21339
21340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
21341         LDKNodeInfo this_ptr_conv;
21342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21343         this_ptr_conv.is_owned = false;
21344         LDKCVec_u64Z val_constr;
21345         val_constr.datalen = (*env)->GetArrayLength(env, val);
21346         if (val_constr.datalen > 0)
21347                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21348         else
21349                 val_constr.data = NULL;
21350         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
21351         for (size_t g = 0; g < val_constr.datalen; g++) {
21352                 int64_t val_conv_6 = val_vals[g];
21353                 val_constr.data[g] = val_conv_6;
21354         }
21355         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
21356         NodeInfo_set_channels(&this_ptr_conv, val_constr);
21357 }
21358
21359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
21360         LDKNodeInfo this_ptr_conv;
21361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21362         this_ptr_conv.is_owned = false;
21363         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
21364         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21365         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21366         long ret_ref = (long)ret_var.inner;
21367         if (ret_var.is_owned) {
21368                 ret_ref |= 1;
21369         }
21370         return ret_ref;
21371 }
21372
21373 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) {
21374         LDKNodeInfo this_ptr_conv;
21375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21376         this_ptr_conv.is_owned = false;
21377         LDKRoutingFees val_conv;
21378         val_conv.inner = (void*)(val & (~1));
21379         val_conv.is_owned = (val & 1) || (val == 0);
21380         val_conv = RoutingFees_clone(&val_conv);
21381         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
21382 }
21383
21384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
21385         LDKNodeInfo this_ptr_conv;
21386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21387         this_ptr_conv.is_owned = false;
21388         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
21389         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21390         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21391         long ret_ref = (long)ret_var.inner;
21392         if (ret_var.is_owned) {
21393                 ret_ref |= 1;
21394         }
21395         return ret_ref;
21396 }
21397
21398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21399         LDKNodeInfo this_ptr_conv;
21400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21401         this_ptr_conv.is_owned = false;
21402         LDKNodeAnnouncementInfo val_conv;
21403         val_conv.inner = (void*)(val & (~1));
21404         val_conv.is_owned = (val & 1) || (val == 0);
21405         val_conv = NodeAnnouncementInfo_clone(&val_conv);
21406         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
21407 }
21408
21409 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) {
21410         LDKCVec_u64Z channels_arg_constr;
21411         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
21412         if (channels_arg_constr.datalen > 0)
21413                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21414         else
21415                 channels_arg_constr.data = NULL;
21416         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
21417         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
21418                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
21419                 channels_arg_constr.data[g] = channels_arg_conv_6;
21420         }
21421         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
21422         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
21423         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
21424         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
21425         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
21426         LDKNodeAnnouncementInfo announcement_info_arg_conv;
21427         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
21428         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
21429         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
21430         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
21431         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21432         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21433         long ret_ref = (long)ret_var.inner;
21434         if (ret_var.is_owned) {
21435                 ret_ref |= 1;
21436         }
21437         return ret_ref;
21438 }
21439
21440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21441         LDKNodeInfo orig_conv;
21442         orig_conv.inner = (void*)(orig & (~1));
21443         orig_conv.is_owned = false;
21444         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
21445         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21446         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21447         long ret_ref = (long)ret_var.inner;
21448         if (ret_var.is_owned) {
21449                 ret_ref |= 1;
21450         }
21451         return ret_ref;
21452 }
21453
21454 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
21455         LDKNodeInfo obj_conv;
21456         obj_conv.inner = (void*)(obj & (~1));
21457         obj_conv.is_owned = false;
21458         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
21459         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21460         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21461         CVec_u8Z_free(ret_var);
21462         return ret_arr;
21463 }
21464
21465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21466         LDKu8slice ser_ref;
21467         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21468         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21469         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
21470         *ret_conv = NodeInfo_read(ser_ref);
21471         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21472         return (long)ret_conv;
21473 }
21474
21475 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
21476         LDKNetworkGraph obj_conv;
21477         obj_conv.inner = (void*)(obj & (~1));
21478         obj_conv.is_owned = false;
21479         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
21480         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21481         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21482         CVec_u8Z_free(ret_var);
21483         return ret_arr;
21484 }
21485
21486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21487         LDKu8slice ser_ref;
21488         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21489         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21490         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
21491         *ret_conv = NetworkGraph_read(ser_ref);
21492         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21493         return (long)ret_conv;
21494 }
21495
21496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
21497         LDKThirtyTwoBytes genesis_hash_ref;
21498         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
21499         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
21500         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
21501         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21502         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21503         long ret_ref = (long)ret_var.inner;
21504         if (ret_var.is_owned) {
21505                 ret_ref |= 1;
21506         }
21507         return ret_ref;
21508 }
21509
21510 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) {
21511         LDKNetworkGraph this_arg_conv;
21512         this_arg_conv.inner = (void*)(this_arg & (~1));
21513         this_arg_conv.is_owned = false;
21514         LDKNodeAnnouncement msg_conv;
21515         msg_conv.inner = (void*)(msg & (~1));
21516         msg_conv.is_owned = false;
21517         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21518         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
21519         return (long)ret_conv;
21520 }
21521
21522 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) {
21523         LDKNetworkGraph this_arg_conv;
21524         this_arg_conv.inner = (void*)(this_arg & (~1));
21525         this_arg_conv.is_owned = false;
21526         LDKUnsignedNodeAnnouncement msg_conv;
21527         msg_conv.inner = (void*)(msg & (~1));
21528         msg_conv.is_owned = false;
21529         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21530         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
21531         return (long)ret_conv;
21532 }
21533
21534 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) {
21535         LDKNetworkGraph this_arg_conv;
21536         this_arg_conv.inner = (void*)(this_arg & (~1));
21537         this_arg_conv.is_owned = false;
21538         LDKChannelAnnouncement msg_conv;
21539         msg_conv.inner = (void*)(msg & (~1));
21540         msg_conv.is_owned = false;
21541         LDKAccess *chain_access_conv_ptr = NULL;
21542         if (chain_access != 0) {
21543                 LDKAccess chain_access_conv;
21544                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
21545                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
21546                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21547                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
21548                 }
21549                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
21550                 *chain_access_conv_ptr = chain_access_conv;
21551         }
21552         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21553         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
21554         return (long)ret_conv;
21555 }
21556
21557 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) {
21558         LDKNetworkGraph this_arg_conv;
21559         this_arg_conv.inner = (void*)(this_arg & (~1));
21560         this_arg_conv.is_owned = false;
21561         LDKUnsignedChannelAnnouncement msg_conv;
21562         msg_conv.inner = (void*)(msg & (~1));
21563         msg_conv.is_owned = false;
21564         LDKAccess *chain_access_conv_ptr = NULL;
21565         if (chain_access != 0) {
21566                 LDKAccess chain_access_conv;
21567                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
21568                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
21569                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21570                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
21571                 }
21572                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
21573                 *chain_access_conv_ptr = chain_access_conv;
21574         }
21575         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21576         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
21577         return (long)ret_conv;
21578 }
21579
21580 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) {
21581         LDKNetworkGraph this_arg_conv;
21582         this_arg_conv.inner = (void*)(this_arg & (~1));
21583         this_arg_conv.is_owned = false;
21584         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
21585 }
21586
21587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
21588         LDKNetworkGraph this_arg_conv;
21589         this_arg_conv.inner = (void*)(this_arg & (~1));
21590         this_arg_conv.is_owned = false;
21591         LDKChannelUpdate msg_conv;
21592         msg_conv.inner = (void*)(msg & (~1));
21593         msg_conv.is_owned = false;
21594         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21595         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
21596         return (long)ret_conv;
21597 }
21598
21599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
21600         LDKNetworkGraph this_arg_conv;
21601         this_arg_conv.inner = (void*)(this_arg & (~1));
21602         this_arg_conv.is_owned = false;
21603         LDKUnsignedChannelUpdate msg_conv;
21604         msg_conv.inner = (void*)(msg & (~1));
21605         msg_conv.is_owned = false;
21606         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21607         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
21608         return (long)ret_conv;
21609 }
21610
21611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21612         LDKFilesystemPersister this_obj_conv;
21613         this_obj_conv.inner = (void*)(this_obj & (~1));
21614         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21615         FilesystemPersister_free(this_obj_conv);
21616 }
21617
21618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, int8_tArray path_to_channel_data) {
21619         LDKCVec_u8Z path_to_channel_data_ref;
21620         path_to_channel_data_ref.datalen = (*env)->GetArrayLength(env, path_to_channel_data);
21621         path_to_channel_data_ref.data = MALLOC(path_to_channel_data_ref.datalen, "LDKCVec_u8Z Bytes");
21622         (*env)->GetByteArrayRegion(env, path_to_channel_data, 0, path_to_channel_data_ref.datalen, path_to_channel_data_ref.data);
21623         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_ref);
21624         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21625         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21626         long ret_ref = (long)ret_var.inner;
21627         if (ret_var.is_owned) {
21628                 ret_ref |= 1;
21629         }
21630         return ret_ref;
21631 }
21632
21633 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
21634         LDKFilesystemPersister this_arg_conv;
21635         this_arg_conv.inner = (void*)(this_arg & (~1));
21636         this_arg_conv.is_owned = false;
21637         LDKCVec_u8Z ret_var = FilesystemPersister_get_data_dir(&this_arg_conv);
21638         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21639         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21640         CVec_u8Z_free(ret_var);
21641         return ret_arr;
21642 }
21643
21644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, int8_tArray data_dir, int64_t manager) {
21645         LDKCVec_u8Z data_dir_ref;
21646         data_dir_ref.datalen = (*env)->GetArrayLength(env, data_dir);
21647         data_dir_ref.data = MALLOC(data_dir_ref.datalen, "LDKCVec_u8Z Bytes");
21648         (*env)->GetByteArrayRegion(env, data_dir, 0, data_dir_ref.datalen, data_dir_ref.data);
21649         LDKChannelManager manager_conv;
21650         manager_conv.inner = (void*)(manager & (~1));
21651         manager_conv.is_owned = false;
21652         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
21653         *ret_conv = FilesystemPersister_persist_manager(data_dir_ref, &manager_conv);
21654         return (long)ret_conv;
21655 }
21656
21657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
21658         LDKFilesystemPersister this_arg_conv;
21659         this_arg_conv.inner = (void*)(this_arg & (~1));
21660         this_arg_conv.is_owned = false;
21661         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
21662         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
21663                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21664                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
21665         }
21666         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21667         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
21668         return (long)ret_conv;
21669 }
21670
21671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
21672         LDKFilesystemPersister this_arg_conv;
21673         this_arg_conv.inner = (void*)(this_arg & (~1));
21674         this_arg_conv.is_owned = false;
21675         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
21676         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
21677         return (long)ret;
21678 }
21679