Update auto-generated bindings
[ldk-java] / src / main / jni / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include "org_ldk_impl_bindings.h"
4 #include <rust_types.h>
5 #include <lightning.h>
6 #include <string.h>
7 #include <stdatomic.h>
8 #include <stdlib.h>
9
10 #define MALLOC(a, _) malloc(a)
11 #define FREE(p) if ((long)(p) > 1024) { free(p); }
12 #define DO_ASSERT(a) (void)(a)
13 #define CHECK(a)
14
15 static jmethodID ordinal_meth = NULL;
16 static jmethodID slicedef_meth = NULL;
17 static jclass slicedef_cls = NULL;
18 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
19         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
20         CHECK(ordinal_meth != NULL);
21         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
22         CHECK(slicedef_meth != NULL);
23         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
24         CHECK(slicedef_cls != NULL);
25 }
26
27 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
28         return *((bool*)ptr);
29 }
30 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
31         return *((long*)ptr);
32 }
33 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
34         FREE((void*)ptr);
35 }
36 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
37         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
38         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
39         return ret_arr;
40 }
41 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
42         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
43         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
44         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
45         return ret_arr;
46 }
47 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
48         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
49         vec->datalen = (*env)->GetArrayLength(env, bytes);
50         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
51         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
52         return (long)vec;
53 }
54 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
55         LDKTransaction *txdata = (LDKTransaction*)ptr;
56         LDKu8slice slice;
57         slice.data = txdata->data;
58         slice.datalen = txdata->datalen;
59         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (long)&slice);
60 }
61 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
62         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
63         txdata->datalen = (*env)->GetArrayLength(env, bytes);
64         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
65         txdata->data_is_owned = false;
66         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
67         return (long)txdata;
68 }
69 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
70         LDKTransaction *tx = (LDKTransaction*)ptr;
71         tx->data_is_owned = true;
72         Transaction_free(*tx);
73         FREE((void*)ptr);
74 }
75 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
76         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
77         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
78         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
79         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
80         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
81         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
82         return (long)vec->datalen;
83 }
84 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
85         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
86         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
87         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
88         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
89         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
90         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
91         vec->data = NULL;
92         vec->datalen = 0;
93         return (long)vec;
94 }
95
96 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
97 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
98 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
99 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
100
101 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
102 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
103 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
104
105 typedef jlongArray int64_tArray;
106 typedef jbyteArray int8_tArray;
107
108 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
109         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
110         char* err_buf = MALLOC(len + 1, "str conv buf");
111         memcpy(err_buf, chars, len);
112         err_buf[len] = 0;
113         jstring err_conv = (*env)->NewStringUTF(env, chars);
114         FREE(err_buf);
115         return err_conv;
116 }
117 static jclass arr_of_B_clz = NULL;
118 static jclass arr_of_J_clz = NULL;
119 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
120         arr_of_B_clz = (*env)->FindClass(env, "[B");
121         CHECK(arr_of_B_clz != NULL);
122         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
123         arr_of_J_clz = (*env)->FindClass(env, "[J");
124         CHECK(arr_of_J_clz != NULL);
125         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
126 }
127 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
128 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
129         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
130                 case 0: return LDKAccessError_UnknownChain;
131                 case 1: return LDKAccessError_UnknownTx;
132         }
133         abort();
134 }
135 static jclass LDKAccessError_class = NULL;
136 static jfieldID LDKAccessError_LDKAccessError_UnknownChain = NULL;
137 static jfieldID LDKAccessError_LDKAccessError_UnknownTx = NULL;
138 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKAccessError_init (JNIEnv *env, jclass clz) {
139         LDKAccessError_class = (*env)->NewGlobalRef(env, clz);
140         CHECK(LDKAccessError_class != NULL);
141         LDKAccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, LDKAccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/LDKAccessError;");
142         CHECK(LDKAccessError_LDKAccessError_UnknownChain != NULL);
143         LDKAccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, LDKAccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/LDKAccessError;");
144         CHECK(LDKAccessError_LDKAccessError_UnknownTx != NULL);
145 }
146 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
147         switch (val) {
148                 case LDKAccessError_UnknownChain:
149                         return (*env)->GetStaticObjectField(env, LDKAccessError_class, LDKAccessError_LDKAccessError_UnknownChain);
150                 case LDKAccessError_UnknownTx:
151                         return (*env)->GetStaticObjectField(env, LDKAccessError_class, LDKAccessError_LDKAccessError_UnknownTx);
152                 default: abort();
153         }
154 }
155
156 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
157         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
158                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
159                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
160         }
161         abort();
162 }
163 static jclass LDKChannelMonitorUpdateErr_class = NULL;
164 static jfieldID LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
165 static jfieldID LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
166 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
167         LDKChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
168         CHECK(LDKChannelMonitorUpdateErr_class != NULL);
169         LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, LDKChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
170         CHECK(LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
171         LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, LDKChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
172         CHECK(LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
173 }
174 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
175         switch (val) {
176                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
177                         return (*env)->GetStaticObjectField(env, LDKChannelMonitorUpdateErr_class, LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
178                 case LDKChannelMonitorUpdateErr_PermanentFailure:
179                         return (*env)->GetStaticObjectField(env, LDKChannelMonitorUpdateErr_class, LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
180                 default: abort();
181         }
182 }
183
184 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
185         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
186                 case 0: return LDKConfirmationTarget_Background;
187                 case 1: return LDKConfirmationTarget_Normal;
188                 case 2: return LDKConfirmationTarget_HighPriority;
189         }
190         abort();
191 }
192 static jclass LDKConfirmationTarget_class = NULL;
193 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_Background = NULL;
194 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
195 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
196 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKConfirmationTarget_init (JNIEnv *env, jclass clz) {
197         LDKConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
198         CHECK(LDKConfirmationTarget_class != NULL);
199         LDKConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/LDKConfirmationTarget;");
200         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_Background != NULL);
201         LDKConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/LDKConfirmationTarget;");
202         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
203         LDKConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/LDKConfirmationTarget;");
204         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
205 }
206 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
207         switch (val) {
208                 case LDKConfirmationTarget_Background:
209                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_Background);
210                 case LDKConfirmationTarget_Normal:
211                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_Normal);
212                 case LDKConfirmationTarget_HighPriority:
213                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_HighPriority);
214                 default: abort();
215         }
216 }
217
218 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
219         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
220                 case 0: return LDKIOError_NotFound;
221                 case 1: return LDKIOError_PermissionDenied;
222                 case 2: return LDKIOError_ConnectionRefused;
223                 case 3: return LDKIOError_ConnectionReset;
224                 case 4: return LDKIOError_ConnectionAborted;
225                 case 5: return LDKIOError_NotConnected;
226                 case 6: return LDKIOError_AddrInUse;
227                 case 7: return LDKIOError_AddrNotAvailable;
228                 case 8: return LDKIOError_BrokenPipe;
229                 case 9: return LDKIOError_AlreadyExists;
230                 case 10: return LDKIOError_WouldBlock;
231                 case 11: return LDKIOError_InvalidInput;
232                 case 12: return LDKIOError_InvalidData;
233                 case 13: return LDKIOError_TimedOut;
234                 case 14: return LDKIOError_WriteZero;
235                 case 15: return LDKIOError_Interrupted;
236                 case 16: return LDKIOError_Other;
237                 case 17: return LDKIOError_UnexpectedEof;
238         }
239         abort();
240 }
241 static jclass LDKIOError_class = NULL;
242 static jfieldID LDKIOError_LDKIOError_NotFound = NULL;
243 static jfieldID LDKIOError_LDKIOError_PermissionDenied = NULL;
244 static jfieldID LDKIOError_LDKIOError_ConnectionRefused = NULL;
245 static jfieldID LDKIOError_LDKIOError_ConnectionReset = NULL;
246 static jfieldID LDKIOError_LDKIOError_ConnectionAborted = NULL;
247 static jfieldID LDKIOError_LDKIOError_NotConnected = NULL;
248 static jfieldID LDKIOError_LDKIOError_AddrInUse = NULL;
249 static jfieldID LDKIOError_LDKIOError_AddrNotAvailable = NULL;
250 static jfieldID LDKIOError_LDKIOError_BrokenPipe = NULL;
251 static jfieldID LDKIOError_LDKIOError_AlreadyExists = NULL;
252 static jfieldID LDKIOError_LDKIOError_WouldBlock = NULL;
253 static jfieldID LDKIOError_LDKIOError_InvalidInput = NULL;
254 static jfieldID LDKIOError_LDKIOError_InvalidData = NULL;
255 static jfieldID LDKIOError_LDKIOError_TimedOut = NULL;
256 static jfieldID LDKIOError_LDKIOError_WriteZero = NULL;
257 static jfieldID LDKIOError_LDKIOError_Interrupted = NULL;
258 static jfieldID LDKIOError_LDKIOError_Other = NULL;
259 static jfieldID LDKIOError_LDKIOError_UnexpectedEof = NULL;
260 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKIOError_init (JNIEnv *env, jclass clz) {
261         LDKIOError_class = (*env)->NewGlobalRef(env, clz);
262         CHECK(LDKIOError_class != NULL);
263         LDKIOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/LDKIOError;");
264         CHECK(LDKIOError_LDKIOError_NotFound != NULL);
265         LDKIOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/LDKIOError;");
266         CHECK(LDKIOError_LDKIOError_PermissionDenied != NULL);
267         LDKIOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/LDKIOError;");
268         CHECK(LDKIOError_LDKIOError_ConnectionRefused != NULL);
269         LDKIOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/LDKIOError;");
270         CHECK(LDKIOError_LDKIOError_ConnectionReset != NULL);
271         LDKIOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/LDKIOError;");
272         CHECK(LDKIOError_LDKIOError_ConnectionAborted != NULL);
273         LDKIOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/LDKIOError;");
274         CHECK(LDKIOError_LDKIOError_NotConnected != NULL);
275         LDKIOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/LDKIOError;");
276         CHECK(LDKIOError_LDKIOError_AddrInUse != NULL);
277         LDKIOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/LDKIOError;");
278         CHECK(LDKIOError_LDKIOError_AddrNotAvailable != NULL);
279         LDKIOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/LDKIOError;");
280         CHECK(LDKIOError_LDKIOError_BrokenPipe != NULL);
281         LDKIOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/LDKIOError;");
282         CHECK(LDKIOError_LDKIOError_AlreadyExists != NULL);
283         LDKIOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/LDKIOError;");
284         CHECK(LDKIOError_LDKIOError_WouldBlock != NULL);
285         LDKIOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/LDKIOError;");
286         CHECK(LDKIOError_LDKIOError_InvalidInput != NULL);
287         LDKIOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/LDKIOError;");
288         CHECK(LDKIOError_LDKIOError_InvalidData != NULL);
289         LDKIOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/LDKIOError;");
290         CHECK(LDKIOError_LDKIOError_TimedOut != NULL);
291         LDKIOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/LDKIOError;");
292         CHECK(LDKIOError_LDKIOError_WriteZero != NULL);
293         LDKIOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/LDKIOError;");
294         CHECK(LDKIOError_LDKIOError_Interrupted != NULL);
295         LDKIOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_Other", "Lorg/ldk/enums/LDKIOError;");
296         CHECK(LDKIOError_LDKIOError_Other != NULL);
297         LDKIOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, LDKIOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/LDKIOError;");
298         CHECK(LDKIOError_LDKIOError_UnexpectedEof != NULL);
299 }
300 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
301         switch (val) {
302                 case LDKIOError_NotFound:
303                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_NotFound);
304                 case LDKIOError_PermissionDenied:
305                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_PermissionDenied);
306                 case LDKIOError_ConnectionRefused:
307                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_ConnectionRefused);
308                 case LDKIOError_ConnectionReset:
309                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_ConnectionReset);
310                 case LDKIOError_ConnectionAborted:
311                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_ConnectionAborted);
312                 case LDKIOError_NotConnected:
313                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_NotConnected);
314                 case LDKIOError_AddrInUse:
315                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_AddrInUse);
316                 case LDKIOError_AddrNotAvailable:
317                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_AddrNotAvailable);
318                 case LDKIOError_BrokenPipe:
319                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_BrokenPipe);
320                 case LDKIOError_AlreadyExists:
321                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_AlreadyExists);
322                 case LDKIOError_WouldBlock:
323                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_WouldBlock);
324                 case LDKIOError_InvalidInput:
325                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_InvalidInput);
326                 case LDKIOError_InvalidData:
327                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_InvalidData);
328                 case LDKIOError_TimedOut:
329                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_TimedOut);
330                 case LDKIOError_WriteZero:
331                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_WriteZero);
332                 case LDKIOError_Interrupted:
333                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_Interrupted);
334                 case LDKIOError_Other:
335                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_Other);
336                 case LDKIOError_UnexpectedEof:
337                         return (*env)->GetStaticObjectField(env, LDKIOError_class, LDKIOError_LDKIOError_UnexpectedEof);
338                 default: abort();
339         }
340 }
341
342 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
343         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
344                 case 0: return LDKLevel_Off;
345                 case 1: return LDKLevel_Error;
346                 case 2: return LDKLevel_Warn;
347                 case 3: return LDKLevel_Info;
348                 case 4: return LDKLevel_Debug;
349                 case 5: return LDKLevel_Trace;
350         }
351         abort();
352 }
353 static jclass LDKLevel_class = NULL;
354 static jfieldID LDKLevel_LDKLevel_Off = NULL;
355 static jfieldID LDKLevel_LDKLevel_Error = NULL;
356 static jfieldID LDKLevel_LDKLevel_Warn = NULL;
357 static jfieldID LDKLevel_LDKLevel_Info = NULL;
358 static jfieldID LDKLevel_LDKLevel_Debug = NULL;
359 static jfieldID LDKLevel_LDKLevel_Trace = NULL;
360 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKLevel_init (JNIEnv *env, jclass clz) {
361         LDKLevel_class = (*env)->NewGlobalRef(env, clz);
362         CHECK(LDKLevel_class != NULL);
363         LDKLevel_LDKLevel_Off = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Off", "Lorg/ldk/enums/LDKLevel;");
364         CHECK(LDKLevel_LDKLevel_Off != NULL);
365         LDKLevel_LDKLevel_Error = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Error", "Lorg/ldk/enums/LDKLevel;");
366         CHECK(LDKLevel_LDKLevel_Error != NULL);
367         LDKLevel_LDKLevel_Warn = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Warn", "Lorg/ldk/enums/LDKLevel;");
368         CHECK(LDKLevel_LDKLevel_Warn != NULL);
369         LDKLevel_LDKLevel_Info = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Info", "Lorg/ldk/enums/LDKLevel;");
370         CHECK(LDKLevel_LDKLevel_Info != NULL);
371         LDKLevel_LDKLevel_Debug = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Debug", "Lorg/ldk/enums/LDKLevel;");
372         CHECK(LDKLevel_LDKLevel_Debug != NULL);
373         LDKLevel_LDKLevel_Trace = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Trace", "Lorg/ldk/enums/LDKLevel;");
374         CHECK(LDKLevel_LDKLevel_Trace != NULL);
375 }
376 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
377         switch (val) {
378                 case LDKLevel_Off:
379                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Off);
380                 case LDKLevel_Error:
381                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Error);
382                 case LDKLevel_Warn:
383                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Warn);
384                 case LDKLevel_Info:
385                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Info);
386                 case LDKLevel_Debug:
387                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Debug);
388                 case LDKLevel_Trace:
389                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Trace);
390                 default: abort();
391         }
392 }
393
394 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
395         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
396                 case 0: return LDKNetwork_Bitcoin;
397                 case 1: return LDKNetwork_Testnet;
398                 case 2: return LDKNetwork_Regtest;
399                 case 3: return LDKNetwork_Signet;
400         }
401         abort();
402 }
403 static jclass LDKNetwork_class = NULL;
404 static jfieldID LDKNetwork_LDKNetwork_Bitcoin = NULL;
405 static jfieldID LDKNetwork_LDKNetwork_Testnet = NULL;
406 static jfieldID LDKNetwork_LDKNetwork_Regtest = NULL;
407 static jfieldID LDKNetwork_LDKNetwork_Signet = NULL;
408 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKNetwork_init (JNIEnv *env, jclass clz) {
409         LDKNetwork_class = (*env)->NewGlobalRef(env, clz);
410         CHECK(LDKNetwork_class != NULL);
411         LDKNetwork_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/LDKNetwork;");
412         CHECK(LDKNetwork_LDKNetwork_Bitcoin != NULL);
413         LDKNetwork_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/LDKNetwork;");
414         CHECK(LDKNetwork_LDKNetwork_Testnet != NULL);
415         LDKNetwork_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/LDKNetwork;");
416         CHECK(LDKNetwork_LDKNetwork_Regtest != NULL);
417         LDKNetwork_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Signet", "Lorg/ldk/enums/LDKNetwork;");
418         CHECK(LDKNetwork_LDKNetwork_Signet != NULL);
419 }
420 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
421         switch (val) {
422                 case LDKNetwork_Bitcoin:
423                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Bitcoin);
424                 case LDKNetwork_Testnet:
425                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Testnet);
426                 case LDKNetwork_Regtest:
427                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Regtest);
428                 case LDKNetwork_Signet:
429                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Signet);
430                 default: abort();
431         }
432 }
433
434 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
435         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
436                 case 0: return LDKSecp256k1Error_IncorrectSignature;
437                 case 1: return LDKSecp256k1Error_InvalidMessage;
438                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
439                 case 3: return LDKSecp256k1Error_InvalidSignature;
440                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
441                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
442                 case 6: return LDKSecp256k1Error_InvalidTweak;
443                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
444                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
445         }
446         abort();
447 }
448 static jclass LDKSecp256k1Error_class = NULL;
449 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
450 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
451 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
452 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
453 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
454 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
455 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
456 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
457 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
458 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKSecp256k1Error_init (JNIEnv *env, jclass clz) {
459         LDKSecp256k1Error_class = (*env)->NewGlobalRef(env, clz);
460         CHECK(LDKSecp256k1Error_class != NULL);
461         LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
462         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
463         LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/LDKSecp256k1Error;");
464         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
465         LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
466         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
467         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
468         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
469         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
470         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
471         LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/LDKSecp256k1Error;");
472         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
473         LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/LDKSecp256k1Error;");
474         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
475         LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/LDKSecp256k1Error;");
476         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
477         LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/LDKSecp256k1Error;");
478         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
479 }
480 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
481         switch (val) {
482                 case LDKSecp256k1Error_IncorrectSignature:
483                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature);
484                 case LDKSecp256k1Error_InvalidMessage:
485                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage);
486                 case LDKSecp256k1Error_InvalidPublicKey:
487                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
488                 case LDKSecp256k1Error_InvalidSignature:
489                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature);
490                 case LDKSecp256k1Error_InvalidSecretKey:
491                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
492                 case LDKSecp256k1Error_InvalidRecoveryId:
493                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
494                 case LDKSecp256k1Error_InvalidTweak:
495                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak);
496                 case LDKSecp256k1Error_TweakCheckFailed:
497                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
498                 case LDKSecp256k1Error_NotEnoughMemory:
499                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
500                 default: abort();
501         }
502 }
503
504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
505         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
506         ret->datalen = (*env)->GetArrayLength(env, elems);
507         if (ret->datalen == 0) {
508                 ret->data = NULL;
509         } else {
510                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
511                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
512                 for (size_t i = 0; i < ret->datalen; i++) {
513                         ret->data[i] = java_elems[i];
514                 }
515                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
516         }
517         return (long)ret;
518 }
519 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
520         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
521         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
522         return ret;
523 }
524 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
525         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
526 }
527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
528         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
529         CHECK(val->result_ok);
530         LDKChannelConfig res_var = (*val->contents.result);
531         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
532         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
533         long res_ref = (long)res_var.inner & ~1;
534         return res_ref;
535 }
536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
537         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
538         CHECK(!val->result_ok);
539         LDKDecodeError err_var = (*val->contents.err);
540         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
541         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
542         long err_ref = (long)err_var.inner & ~1;
543         return err_ref;
544 }
545 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
546         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
547 }
548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
549         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
550         CHECK(val->result_ok);
551         LDKOutPoint res_var = (*val->contents.result);
552         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
553         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
554         long res_ref = (long)res_var.inner & ~1;
555         return res_ref;
556 }
557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
558         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
559         CHECK(!val->result_ok);
560         LDKDecodeError err_var = (*val->contents.err);
561         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
562         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
563         long err_ref = (long)err_var.inner & ~1;
564         return err_ref;
565 }
566 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
567         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
568 }
569 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
570         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
571         CHECK(val->result_ok);
572         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
573         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
574         return res_arr;
575 }
576 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
577         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
578         CHECK(!val->result_ok);
579         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
580         return err_conv;
581 }
582 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
583         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
584 }
585 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
586         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
587         CHECK(val->result_ok);
588         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
589         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
590         return res_arr;
591 }
592 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
593         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
594         CHECK(!val->result_ok);
595         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
596         return err_conv;
597 }
598 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
599         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
600 }
601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
602         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
603         CHECK(val->result_ok);
604         LDKTxCreationKeys res_var = (*val->contents.result);
605         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
606         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
607         long res_ref = (long)res_var.inner & ~1;
608         return res_ref;
609 }
610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
611         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
612         CHECK(!val->result_ok);
613         LDKDecodeError err_var = (*val->contents.err);
614         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
615         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
616         long err_ref = (long)err_var.inner & ~1;
617         return err_ref;
618 }
619 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
620         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
621 }
622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
623         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
624         CHECK(val->result_ok);
625         LDKChannelPublicKeys res_var = (*val->contents.result);
626         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
627         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
628         long res_ref = (long)res_var.inner & ~1;
629         return res_ref;
630 }
631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
632         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
633         CHECK(!val->result_ok);
634         LDKDecodeError err_var = (*val->contents.err);
635         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
636         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
637         long err_ref = (long)err_var.inner & ~1;
638         return err_ref;
639 }
640 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
641         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
642 }
643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
644         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
645         CHECK(val->result_ok);
646         LDKTxCreationKeys res_var = (*val->contents.result);
647         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
648         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
649         long res_ref = (long)res_var.inner & ~1;
650         return res_ref;
651 }
652 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
653         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
654         CHECK(!val->result_ok);
655         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
656         return err_conv;
657 }
658 static jclass LDKCOption_u32Z_Some_class = NULL;
659 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
660 static jclass LDKCOption_u32Z_None_class = NULL;
661 static jmethodID LDKCOption_u32Z_None_meth = NULL;
662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
663         LDKCOption_u32Z_Some_class =
664                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
665         CHECK(LDKCOption_u32Z_Some_class != NULL);
666         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
667         CHECK(LDKCOption_u32Z_Some_meth != NULL);
668         LDKCOption_u32Z_None_class =
669                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
670         CHECK(LDKCOption_u32Z_None_class != NULL);
671         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
672         CHECK(LDKCOption_u32Z_None_meth != NULL);
673 }
674 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
675         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
676         switch(obj->tag) {
677                 case LDKCOption_u32Z_Some: {
678                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
679                 }
680                 case LDKCOption_u32Z_None: {
681                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
682                 }
683                 default: abort();
684         }
685 }
686 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
687         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
688 }
689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
690         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
691         CHECK(val->result_ok);
692         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
693         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
694         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
695         long res_ref = (long)res_var.inner & ~1;
696         return res_ref;
697 }
698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
699         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
700         CHECK(!val->result_ok);
701         LDKDecodeError err_var = (*val->contents.err);
702         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
703         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
704         long err_ref = (long)err_var.inner & ~1;
705         return err_ref;
706 }
707 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
708         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
709 }
710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
711         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
712         CHECK(val->result_ok);
713         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
714         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
715         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
716         long res_ref = (long)res_var.inner & ~1;
717         return res_ref;
718 }
719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
720         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
721         CHECK(!val->result_ok);
722         LDKDecodeError err_var = (*val->contents.err);
723         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
724         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
725         long err_ref = (long)err_var.inner & ~1;
726         return err_ref;
727 }
728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
729         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
730 }
731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
732         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
733         CHECK(val->result_ok);
734         LDKChannelTransactionParameters res_var = (*val->contents.result);
735         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
736         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
737         long res_ref = (long)res_var.inner & ~1;
738         return res_ref;
739 }
740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
741         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
742         CHECK(!val->result_ok);
743         LDKDecodeError err_var = (*val->contents.err);
744         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
745         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
746         long err_ref = (long)err_var.inner & ~1;
747         return err_ref;
748 }
749 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
750         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
751 }
752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
753         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
754         CHECK(val->result_ok);
755         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
756         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
757         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
758         long res_ref = (long)res_var.inner & ~1;
759         return res_ref;
760 }
761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
762         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
763         CHECK(!val->result_ok);
764         LDKDecodeError err_var = (*val->contents.err);
765         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
766         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
767         long err_ref = (long)err_var.inner & ~1;
768         return err_ref;
769 }
770 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
771         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
772 }
773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
774         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
775         CHECK(val->result_ok);
776         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
777         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
778         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
779         long res_ref = (long)res_var.inner & ~1;
780         return res_ref;
781 }
782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
783         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
784         CHECK(!val->result_ok);
785         LDKDecodeError err_var = (*val->contents.err);
786         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
787         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
788         long err_ref = (long)err_var.inner & ~1;
789         return err_ref;
790 }
791 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
792         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
793 }
794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
795         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
796         CHECK(val->result_ok);
797         LDKCommitmentTransaction res_var = (*val->contents.result);
798         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
799         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
800         long res_ref = (long)res_var.inner & ~1;
801         return res_ref;
802 }
803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
804         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
805         CHECK(!val->result_ok);
806         LDKDecodeError err_var = (*val->contents.err);
807         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
808         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
809         long err_ref = (long)err_var.inner & ~1;
810         return err_ref;
811 }
812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
813         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
814 }
815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
816         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
817         CHECK(val->result_ok);
818         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
819         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
820         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
821         long res_ref = (long)res_var.inner & ~1;
822         return res_ref;
823 }
824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
825         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
826         CHECK(!val->result_ok);
827         return *val->contents.err;
828 }
829 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
830         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
831 }
832 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
833         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
834         CHECK(val->result_ok);
835         LDKCVec_SignatureZ res_var = (*val->contents.result);
836         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
837         ;
838         for (size_t i = 0; i < res_var.datalen; i++) {
839                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
840                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
841                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
842         }
843         return res_arr;
844 }
845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
846         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
847         CHECK(!val->result_ok);
848         return *val->contents.err;
849 }
850 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
851         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
852 }
853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
854         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
855         CHECK(val->result_ok);
856         LDKChannelMonitorUpdate res_var = (*val->contents.result);
857         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
858         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
859         long res_ref = (long)res_var.inner & ~1;
860         return res_ref;
861 }
862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
863         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
864         CHECK(!val->result_ok);
865         LDKDecodeError err_var = (*val->contents.err);
866         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
867         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
868         long err_ref = (long)err_var.inner & ~1;
869         return err_ref;
870 }
871 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
872         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
873 }
874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
875         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
876         CHECK(val->result_ok);
877         LDKHTLCUpdate res_var = (*val->contents.result);
878         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
879         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
880         long res_ref = (long)res_var.inner & ~1;
881         return res_ref;
882 }
883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
884         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
885         CHECK(!val->result_ok);
886         LDKDecodeError err_var = (*val->contents.err);
887         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
888         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
889         long err_ref = (long)err_var.inner & ~1;
890         return err_ref;
891 }
892 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
893         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
894 }
895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
896         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
897         CHECK(val->result_ok);
898         return *val->contents.result;
899 }
900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
901         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
902         CHECK(!val->result_ok);
903         LDKMonitorUpdateError err_var = (*val->contents.err);
904         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
905         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
906         long err_ref = (long)err_var.inner & ~1;
907         return err_ref;
908 }
909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
910         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
911         LDKOutPoint a_conv;
912         a_conv.inner = (void*)(a & (~1));
913         a_conv.is_owned = (a & 1) || (a == 0);
914         a_conv = OutPoint_clone(&a_conv);
915         ret->a = a_conv;
916         LDKCVec_u8Z b_ref;
917         b_ref.datalen = (*env)->GetArrayLength(env, b);
918         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
919         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
920         ret->b = b_ref;
921         return (long)ret;
922 }
923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
924         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
925         LDKOutPoint a_var = tuple->a;
926         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
927         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
928         long a_ref = (long)a_var.inner & ~1;
929         return a_ref;
930 }
931 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
932         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
933         LDKCVec_u8Z b_var = tuple->b;
934         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
935         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
936         return b_arr;
937 }
938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
939         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
940         ret->a = a;
941         LDKCVec_u8Z b_ref;
942         b_ref.datalen = (*env)->GetArrayLength(env, b);
943         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
944         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
945         ret->b = b_ref;
946         return (long)ret;
947 }
948 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
949         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
950         return tuple->a;
951 }
952 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
953         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
954         LDKCVec_u8Z b_var = tuple->b;
955         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
956         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
957         return b_arr;
958 }
959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
960         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
961         ret->datalen = (*env)->GetArrayLength(env, elems);
962         if (ret->datalen == 0) {
963                 ret->data = NULL;
964         } else {
965                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
966                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
967                 for (size_t i = 0; i < ret->datalen; i++) {
968                         int64_t arr_elem = java_elems[i];
969                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
970                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_u32ScriptZ
971                         ret->data[i] = arr_elem_conv;
972                 }
973                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
974         }
975         return (long)ret;
976 }
977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
978         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
979         LDKThirtyTwoBytes a_ref;
980         CHECK((*env)->GetArrayLength(env, a) == 32);
981         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
982         ret->a = a_ref;
983         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
984         b_constr.datalen = (*env)->GetArrayLength(env, b);
985         if (b_constr.datalen > 0)
986                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
987         else
988                 b_constr.data = NULL;
989         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
990         for (size_t b = 0; b < b_constr.datalen; b++) {
991                 int64_t b_conv_27 = b_vals[b];
992                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
993                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_u32ScriptZ
994                 b_constr.data[b] = b_conv_27_conv;
995         }
996         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
997         ret->b = b_constr;
998         return (long)ret;
999 }
1000 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1001         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
1002         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
1003         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
1004         return a_arr;
1005 }
1006 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1007         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
1008         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
1009         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
1010         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
1011         for (size_t b = 0; b < b_var.datalen; b++) {
1012                 long b_conv_27_ref = (long)(&b_var.data[b]) | 1;
1013                 b_arr_ptr[b] = b_conv_27_ref;
1014         }
1015         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
1016         return b_arr;
1017 }
1018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1019         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
1020         ret->datalen = (*env)->GetArrayLength(env, elems);
1021         if (ret->datalen == 0) {
1022                 ret->data = NULL;
1023         } else {
1024                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
1025                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1026                 for (size_t i = 0; i < ret->datalen; i++) {
1027                         int64_t arr_elem = java_elems[i];
1028                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
1029                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ
1030                         ret->data[i] = arr_elem_conv;
1031                 }
1032                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1033         }
1034         return (long)ret;
1035 }
1036 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1037 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1038 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1039 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1041         LDKMonitorEvent_HTLCEvent_class =
1042                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1043         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1044         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1045         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1046         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1047                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1048         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1049         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "(J)V");
1050         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1051 }
1052 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1053         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1054         switch(obj->tag) {
1055                 case LDKMonitorEvent_HTLCEvent: {
1056                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1057                         CHECK((((long)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1058                         CHECK((((long)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1059                         long htlc_event_ref = (long)htlc_event_var.inner & ~1;
1060                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1061                 }
1062                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1063                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
1064                         CHECK((((long)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1065                         CHECK((((long)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1066                         long commitment_tx_broadcasted_ref = (long)commitment_tx_broadcasted_var.inner & ~1;
1067                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref);
1068                 }
1069                 default: abort();
1070         }
1071 }
1072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1073         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1074         ret->datalen = (*env)->GetArrayLength(env, elems);
1075         if (ret->datalen == 0) {
1076                 ret->data = NULL;
1077         } else {
1078                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1079                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1080                 for (size_t i = 0; i < ret->datalen; i++) {
1081                         int64_t arr_elem = java_elems[i];
1082                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1083                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1084                         ret->data[i] = arr_elem_conv;
1085                 }
1086                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1087         }
1088         return (long)ret;
1089 }
1090 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1091         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1092         for (size_t i = 0; i < ret.datalen; i++) {
1093                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1094         }
1095         return ret;
1096 }
1097 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1098 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1099 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1100 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1101 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1102 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1104         LDKSpendableOutputDescriptor_StaticOutput_class =
1105                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1106         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1107         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1108         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1109         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1110                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1111         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1112         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1113         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1114         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1115                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1116         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1117         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1118         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1119 }
1120 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1121         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1122         switch(obj->tag) {
1123                 case LDKSpendableOutputDescriptor_StaticOutput: {
1124                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1125                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1126                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1127                         long outpoint_ref = (long)outpoint_var.inner & ~1;
1128                         long output_ref = ((long)&obj->static_output.output) | 1;
1129                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (long)output_ref);
1130                 }
1131                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1132                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1133                         CHECK((((long)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1134                         CHECK((((long)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1135                         long delayed_payment_output_ref = (long)delayed_payment_output_var.inner & ~1;
1136                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1137                 }
1138                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1139                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1140                         CHECK((((long)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1141                         CHECK((((long)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1142                         long static_payment_output_ref = (long)static_payment_output_var.inner & ~1;
1143                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1144                 }
1145                 default: abort();
1146         }
1147 }
1148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1149         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1150         ret->datalen = (*env)->GetArrayLength(env, elems);
1151         if (ret->datalen == 0) {
1152                 ret->data = NULL;
1153         } else {
1154                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1155                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1156                 for (size_t i = 0; i < ret->datalen; i++) {
1157                         int64_t arr_elem = java_elems[i];
1158                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1159                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1160                         ret->data[i] = arr_elem_conv;
1161                 }
1162                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1163         }
1164         return (long)ret;
1165 }
1166 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1167         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1168         for (size_t i = 0; i < ret.datalen; i++) {
1169                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1170         }
1171         return ret;
1172 }
1173 static jclass LDKEvent_FundingGenerationReady_class = NULL;
1174 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
1175 static jclass LDKEvent_PaymentReceived_class = NULL;
1176 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
1177 static jclass LDKEvent_PaymentSent_class = NULL;
1178 static jmethodID LDKEvent_PaymentSent_meth = NULL;
1179 static jclass LDKEvent_PaymentFailed_class = NULL;
1180 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
1181 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
1182 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
1183 static jclass LDKEvent_SpendableOutputs_class = NULL;
1184 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
1185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
1186         LDKEvent_FundingGenerationReady_class =
1187                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
1188         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
1189         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
1190         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
1191         LDKEvent_PaymentReceived_class =
1192                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
1193         CHECK(LDKEvent_PaymentReceived_class != NULL);
1194         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[BJ)V");
1195         CHECK(LDKEvent_PaymentReceived_meth != NULL);
1196         LDKEvent_PaymentSent_class =
1197                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
1198         CHECK(LDKEvent_PaymentSent_class != NULL);
1199         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
1200         CHECK(LDKEvent_PaymentSent_meth != NULL);
1201         LDKEvent_PaymentFailed_class =
1202                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
1203         CHECK(LDKEvent_PaymentFailed_class != NULL);
1204         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
1205         CHECK(LDKEvent_PaymentFailed_meth != NULL);
1206         LDKEvent_PendingHTLCsForwardable_class =
1207                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
1208         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
1209         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
1210         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
1211         LDKEvent_SpendableOutputs_class =
1212                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
1213         CHECK(LDKEvent_SpendableOutputs_class != NULL);
1214         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
1215         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
1216 }
1217 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1218         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1219         switch(obj->tag) {
1220                 case LDKEvent_FundingGenerationReady: {
1221                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
1222                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
1223                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1224                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
1225                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
1226                         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);
1227                 }
1228                 case LDKEvent_PaymentReceived: {
1229                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1230                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
1231                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1232                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
1233                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_secret_arr, obj->payment_received.amt);
1234                 }
1235                 case LDKEvent_PaymentSent: {
1236                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1237                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
1238                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
1239                 }
1240                 case LDKEvent_PaymentFailed: {
1241                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1242                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
1243                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
1244                 }
1245                 case LDKEvent_PendingHTLCsForwardable: {
1246                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
1247                 }
1248                 case LDKEvent_SpendableOutputs: {
1249                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1250                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
1251                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
1252                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1253                                 long outputs_conv_27_ref = ((long)&outputs_var.data[b]) | 1;
1254                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1255                         }
1256                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
1257                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
1258                 }
1259                 default: abort();
1260         }
1261 }
1262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1263         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
1264         ret->datalen = (*env)->GetArrayLength(env, elems);
1265         if (ret->datalen == 0) {
1266                 ret->data = NULL;
1267         } else {
1268                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
1269                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1270                 for (size_t i = 0; i < ret->datalen; i++) {
1271                         int64_t arr_elem = java_elems[i];
1272                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
1273                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
1274                         ret->data[i] = arr_elem_conv;
1275                 }
1276                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1277         }
1278         return (long)ret;
1279 }
1280 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
1281         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
1282         for (size_t i = 0; i < ret.datalen; i++) {
1283                 ret.data[i] = Event_clone(&orig->data[i]);
1284         }
1285         return ret;
1286 }
1287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1288         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1289         ret->a = a;
1290         LDKTransaction b_ref;
1291         b_ref.datalen = (*env)->GetArrayLength(env, b);
1292         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1293         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1294         b_ref.data_is_owned = false;
1295         ret->b = b_ref;
1296         return (long)ret;
1297 }
1298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1299         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1300         return tuple->a;
1301 }
1302 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1303         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1304         LDKTransaction b_var = tuple->b;
1305         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1306         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1307         return b_arr;
1308 }
1309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1310         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1311         ret->datalen = (*env)->GetArrayLength(env, elems);
1312         if (ret->datalen == 0) {
1313                 ret->data = NULL;
1314         } else {
1315                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1316                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1317                 for (size_t i = 0; i < ret->datalen; i++) {
1318                         int64_t arr_elem = java_elems[i];
1319                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1320                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
1321                         ret->data[i] = arr_elem_conv;
1322                 }
1323                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1324         }
1325         return (long)ret;
1326 }
1327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
1328         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
1329         ret->a = a;
1330         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
1331         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
1332         ret->b = b_conv;
1333         return (long)ret;
1334 }
1335 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1336         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
1337         return tuple->a;
1338 }
1339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1340         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
1341         long b_ref = ((long)&tuple->b) | 1;
1342         return (long)b_ref;
1343 }
1344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1345         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
1346         ret->datalen = (*env)->GetArrayLength(env, elems);
1347         if (ret->datalen == 0) {
1348                 ret->data = NULL;
1349         } else {
1350                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
1351                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1352                 for (size_t i = 0; i < ret->datalen; i++) {
1353                         int64_t arr_elem = java_elems[i];
1354                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
1355                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
1356                         ret->data[i] = arr_elem_conv;
1357                 }
1358                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1359         }
1360         return (long)ret;
1361 }
1362 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
1363         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
1364         for (size_t i = 0; i < ret.datalen; i++) {
1365                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
1366         }
1367         return ret;
1368 }
1369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
1370         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
1371         LDKThirtyTwoBytes a_ref;
1372         CHECK((*env)->GetArrayLength(env, a) == 32);
1373         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
1374         ret->a = a_ref;
1375         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
1376         b_constr.datalen = (*env)->GetArrayLength(env, b);
1377         if (b_constr.datalen > 0)
1378                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
1379         else
1380                 b_constr.data = NULL;
1381         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
1382         for (size_t a = 0; a < b_constr.datalen; a++) {
1383                 int64_t b_conv_26 = b_vals[a];
1384                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
1385                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
1386                 b_constr.data[a] = b_conv_26_conv;
1387         }
1388         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
1389         ret->b = b_constr;
1390         return (long)ret;
1391 }
1392 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1393         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
1394         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
1395         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
1396         return a_arr;
1397 }
1398 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1399         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
1400         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
1401         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
1402         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
1403         for (size_t a = 0; a < b_var.datalen; a++) {
1404                 long b_conv_26_ref = (long)(&b_var.data[a]) | 1;
1405                 b_arr_ptr[a] = b_conv_26_ref;
1406         }
1407         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
1408         return b_arr;
1409 }
1410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1411         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
1412         ret->datalen = (*env)->GetArrayLength(env, elems);
1413         if (ret->datalen == 0) {
1414                 ret->data = NULL;
1415         } else {
1416                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
1417                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1418                 for (size_t i = 0; i < ret->datalen; i++) {
1419                         int64_t arr_elem = java_elems[i];
1420                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
1421                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ
1422                         ret->data[i] = arr_elem_conv;
1423                 }
1424                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1425         }
1426         return (long)ret;
1427 }
1428 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1429         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1430         for (size_t i = 0; i < ret.datalen; i++) {
1431                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1432         }
1433         return ret;
1434 }
1435 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1436         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1437 }
1438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1439         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1440         CHECK(val->result_ok);
1441         return *val->contents.result;
1442 }
1443 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1444         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1445         CHECK(!val->result_ok);
1446         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1447         return err_conv;
1448 }
1449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
1450         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1451         LDKSignature a_ref;
1452         CHECK((*env)->GetArrayLength(env, a) == 64);
1453         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
1454         ret->a = a_ref;
1455         LDKCVec_SignatureZ b_constr;
1456         b_constr.datalen = (*env)->GetArrayLength(env, b);
1457         if (b_constr.datalen > 0)
1458                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
1459         else
1460                 b_constr.data = NULL;
1461         for (size_t i = 0; i < b_constr.datalen; i++) {
1462                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
1463                 LDKSignature b_conv_8_ref;
1464                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
1465                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
1466                 b_constr.data[i] = b_conv_8_ref;
1467         }
1468         ret->b = b_constr;
1469         return (long)ret;
1470 }
1471 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1472         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1473         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
1474         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
1475         return a_arr;
1476 }
1477 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1478         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1479         LDKCVec_SignatureZ b_var = tuple->b;
1480         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
1481         ;
1482         for (size_t i = 0; i < b_var.datalen; i++) {
1483                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
1484                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
1485                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
1486         }
1487         return b_arr;
1488 }
1489 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1490         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
1491 }
1492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1493         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1494         CHECK(val->result_ok);
1495         long res_ref = (long)(&(*val->contents.result)) | 1;
1496         return res_ref;
1497 }
1498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1499         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1500         CHECK(!val->result_ok);
1501         return *val->contents.err;
1502 }
1503 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1504         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
1505 }
1506 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1507         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1508         CHECK(val->result_ok);
1509         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
1510         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
1511         return res_arr;
1512 }
1513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1514         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1515         CHECK(!val->result_ok);
1516         return *val->contents.err;
1517 }
1518 typedef struct LDKBaseSign_JCalls {
1519         atomic_size_t refcnt;
1520         JavaVM *vm;
1521         jweak o;
1522         jmethodID get_per_commitment_point_meth;
1523         jmethodID release_commitment_secret_meth;
1524         jmethodID channel_keys_id_meth;
1525         jmethodID sign_counterparty_commitment_meth;
1526         jmethodID sign_holder_commitment_and_htlcs_meth;
1527         jmethodID sign_justice_transaction_meth;
1528         jmethodID sign_counterparty_htlc_transaction_meth;
1529         jmethodID sign_closing_transaction_meth;
1530         jmethodID sign_channel_announcement_meth;
1531         jmethodID ready_channel_meth;
1532 } LDKBaseSign_JCalls;
1533 static void LDKBaseSign_JCalls_free(void* this_arg) {
1534         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1535         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1536                 JNIEnv *env;
1537                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1538                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1539                 FREE(j_calls);
1540         }
1541 }
1542 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1543         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1544         JNIEnv *env;
1545         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1546         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1547         CHECK(obj != NULL);
1548         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
1549         LDKPublicKey ret_ref;
1550         CHECK((*env)->GetArrayLength(env, ret) == 33);
1551         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
1552         return ret_ref;
1553 }
1554 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1555         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1556         JNIEnv *env;
1557         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1558         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1559         CHECK(obj != NULL);
1560         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
1561         LDKThirtyTwoBytes ret_ref;
1562         CHECK((*env)->GetArrayLength(env, ret) == 32);
1563         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
1564         return ret_ref;
1565 }
1566 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1567         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1568         JNIEnv *env;
1569         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1570         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1571         CHECK(obj != NULL);
1572         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
1573         LDKThirtyTwoBytes ret_ref;
1574         CHECK((*env)->GetArrayLength(env, ret) == 32);
1575         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
1576         return ret_ref;
1577 }
1578 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1579         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1580         JNIEnv *env;
1581         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1582         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1583         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1584         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1585         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1586         long commitment_tx_ref = (long)commitment_tx_var.inner;
1587         if (commitment_tx_var.is_owned) {
1588                 commitment_tx_ref |= 1;
1589         }
1590         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1591         CHECK(obj != NULL);
1592         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1593         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1594         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1595         return ret_conv;
1596 }
1597 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1598         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1599         JNIEnv *env;
1600         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1601         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1602         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1603         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1604         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1605         long commitment_tx_ref = (long)commitment_tx_var.inner;
1606         if (commitment_tx_var.is_owned) {
1607                 commitment_tx_ref |= 1;
1608         }
1609         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1610         CHECK(obj != NULL);
1611         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1612         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1613         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1614         return ret_conv;
1615 }
1616 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) {
1617         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1618         JNIEnv *env;
1619         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1620         LDKTransaction justice_tx_var = justice_tx;
1621         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
1622         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
1623         Transaction_free(justice_tx_var);
1624         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
1625         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
1626         LDKHTLCOutputInCommitment htlc_var = *htlc;
1627         htlc_var = HTLCOutputInCommitment_clone(htlc);
1628         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1629         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1630         long htlc_ref = (long)htlc_var.inner;
1631         if (htlc_var.is_owned) {
1632                 htlc_ref |= 1;
1633         }
1634         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1635         CHECK(obj != NULL);
1636         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);
1637         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1638         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1639         return ret_conv;
1640 }
1641 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) {
1642         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1643         JNIEnv *env;
1644         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1645         LDKTransaction htlc_tx_var = htlc_tx;
1646         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
1647         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
1648         Transaction_free(htlc_tx_var);
1649         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
1650         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
1651         LDKHTLCOutputInCommitment htlc_var = *htlc;
1652         htlc_var = HTLCOutputInCommitment_clone(htlc);
1653         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1654         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1655         long htlc_ref = (long)htlc_var.inner;
1656         if (htlc_var.is_owned) {
1657                 htlc_ref |= 1;
1658         }
1659         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1660         CHECK(obj != NULL);
1661         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);
1662         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1663         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1664         return ret_conv;
1665 }
1666 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
1667         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1668         JNIEnv *env;
1669         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1670         LDKTransaction closing_tx_var = closing_tx;
1671         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
1672         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
1673         Transaction_free(closing_tx_var);
1674         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1675         CHECK(obj != NULL);
1676         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
1677         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1678         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1679         return ret_conv;
1680 }
1681 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1682         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1683         JNIEnv *env;
1684         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1685         LDKUnsignedChannelAnnouncement msg_var = *msg;
1686         msg_var = UnsignedChannelAnnouncement_clone(msg);
1687         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1688         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1689         long msg_ref = (long)msg_var.inner;
1690         if (msg_var.is_owned) {
1691                 msg_ref |= 1;
1692         }
1693         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1694         CHECK(obj != NULL);
1695         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
1696         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1697         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1698         return ret_conv;
1699 }
1700 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1701         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1702         JNIEnv *env;
1703         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1704         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1705         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1706         CHECK((((long)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1707         CHECK((((long)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1708         long channel_parameters_ref = (long)channel_parameters_var.inner;
1709         if (channel_parameters_var.is_owned) {
1710                 channel_parameters_ref |= 1;
1711         }
1712         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1713         CHECK(obj != NULL);
1714         return (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
1715 }
1716 static void* LDKBaseSign_JCalls_clone(const void* this_arg) {
1717         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1718         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1719         return (void*) this_arg;
1720 }
1721 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
1722         jclass c = (*env)->GetObjectClass(env, o);
1723         CHECK(c != NULL);
1724         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
1725         atomic_init(&calls->refcnt, 1);
1726         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1727         calls->o = (*env)->NewWeakGlobalRef(env, o);
1728         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
1729         CHECK(calls->get_per_commitment_point_meth != NULL);
1730         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
1731         CHECK(calls->release_commitment_secret_meth != NULL);
1732         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
1733         CHECK(calls->channel_keys_id_meth != NULL);
1734         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
1735         CHECK(calls->sign_counterparty_commitment_meth != NULL);
1736         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
1737         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
1738         calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "([BJJ[BJ)J");
1739         CHECK(calls->sign_justice_transaction_meth != NULL);
1740         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
1741         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
1742         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
1743         CHECK(calls->sign_closing_transaction_meth != NULL);
1744         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
1745         CHECK(calls->sign_channel_announcement_meth != NULL);
1746         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
1747         CHECK(calls->ready_channel_meth != NULL);
1748
1749         LDKChannelPublicKeys pubkeys_conv;
1750         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1751         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1752         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1753
1754         LDKBaseSign ret = {
1755                 .this_arg = (void*) calls,
1756                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
1757                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
1758                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
1759                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
1760                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
1761                 .sign_justice_transaction = sign_justice_transaction_LDKBaseSign_jcall,
1762                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
1763                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
1764                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
1765                 .ready_channel = ready_channel_LDKBaseSign_jcall,
1766                 .free = LDKBaseSign_JCalls_free,
1767                 .pubkeys = pubkeys_conv,
1768                 .set_pubkeys = NULL,
1769         };
1770         return ret;
1771 }
1772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
1773         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
1774         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
1775         return (long)res_ptr;
1776 }
1777 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) {
1778         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1779         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
1780         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
1781         return ret_arr;
1782 }
1783
1784 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
1785         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1786         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1787         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
1788         return ret_arr;
1789 }
1790
1791 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
1792         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1793         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1794         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
1795         return ret_arr;
1796 }
1797
1798 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) {
1799         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1800         LDKCommitmentTransaction commitment_tx_conv;
1801         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1802         commitment_tx_conv.is_owned = false;
1803         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1804         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1805         return (long)ret_conv;
1806 }
1807
1808 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) {
1809         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1810         LDKHolderCommitmentTransaction commitment_tx_conv;
1811         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1812         commitment_tx_conv.is_owned = false;
1813         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1814         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
1815         return (long)ret_conv;
1816 }
1817
1818 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) {
1819         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1820         LDKTransaction justice_tx_ref;
1821         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
1822         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1823         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
1824         justice_tx_ref.data_is_owned = true;
1825         unsigned char per_commitment_key_arr[32];
1826         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
1827         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
1828         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1829         LDKHTLCOutputInCommitment htlc_conv;
1830         htlc_conv.inner = (void*)(htlc & (~1));
1831         htlc_conv.is_owned = false;
1832         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1833         *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
1834         return (long)ret_conv;
1835 }
1836
1837 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) {
1838         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1839         LDKTransaction htlc_tx_ref;
1840         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
1841         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1842         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
1843         htlc_tx_ref.data_is_owned = true;
1844         LDKPublicKey per_commitment_point_ref;
1845         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
1846         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
1847         LDKHTLCOutputInCommitment htlc_conv;
1848         htlc_conv.inner = (void*)(htlc & (~1));
1849         htlc_conv.is_owned = false;
1850         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1851         *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);
1852         return (long)ret_conv;
1853 }
1854
1855 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) {
1856         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1857         LDKTransaction closing_tx_ref;
1858         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
1859         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
1860         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
1861         closing_tx_ref.data_is_owned = true;
1862         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1863         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
1864         return (long)ret_conv;
1865 }
1866
1867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
1868         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1869         LDKUnsignedChannelAnnouncement msg_conv;
1870         msg_conv.inner = (void*)(msg & (~1));
1871         msg_conv.is_owned = false;
1872         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1873         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1874         return (long)ret_conv;
1875 }
1876
1877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
1878         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1879         LDKChannelTransactionParameters channel_parameters_conv;
1880         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
1881         channel_parameters_conv.is_owned = false;
1882         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
1883 }
1884
1885 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
1886         if (this_arg->set_pubkeys != NULL)
1887                 this_arg->set_pubkeys(this_arg);
1888         return this_arg->pubkeys;
1889 }
1890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
1891         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1892         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
1893         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1894         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1895         long ret_ref = (long)ret_var.inner;
1896         if (ret_var.is_owned) {
1897                 ret_ref |= 1;
1898         }
1899         return ret_ref;
1900 }
1901
1902 typedef struct LDKSign_JCalls {
1903         atomic_size_t refcnt;
1904         JavaVM *vm;
1905         jweak o;
1906         LDKBaseSign_JCalls* BaseSign;
1907         jmethodID write_meth;
1908 } LDKSign_JCalls;
1909 static void LDKSign_JCalls_free(void* this_arg) {
1910         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1911         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1912                 JNIEnv *env;
1913                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1914                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1915                 FREE(j_calls);
1916         }
1917 }
1918 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
1919         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1920         JNIEnv *env;
1921         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
1922         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1923         CHECK(obj != NULL);
1924         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
1925         LDKCVec_u8Z ret_ref;
1926         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
1927         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1928         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
1929         return ret_ref;
1930 }
1931 static void* LDKSign_JCalls_clone(const void* this_arg) {
1932         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1933         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1934         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
1935         return (void*) this_arg;
1936 }
1937 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
1938         jclass c = (*env)->GetObjectClass(env, o);
1939         CHECK(c != NULL);
1940         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
1941         atomic_init(&calls->refcnt, 1);
1942         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1943         calls->o = (*env)->NewWeakGlobalRef(env, o);
1944         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
1945         CHECK(calls->write_meth != NULL);
1946
1947         LDKChannelPublicKeys pubkeys_conv;
1948         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1949         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1950         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1951
1952         LDKSign ret = {
1953                 .this_arg = (void*) calls,
1954                 .write = write_LDKSign_jcall,
1955                 .clone = LDKSign_JCalls_clone,
1956                 .free = LDKSign_JCalls_free,
1957                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
1958         };
1959         calls->BaseSign = ret.BaseSign.this_arg;
1960         return ret;
1961 }
1962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
1963         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
1964         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
1965         return (long)res_ptr;
1966 }
1967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
1968         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1969         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
1970         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1971         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1972         CVec_u8Z_free(ret_var);
1973         return ret_arr;
1974 }
1975
1976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
1977         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
1978         LDKThirtyTwoBytes a_ref;
1979         CHECK((*env)->GetArrayLength(env, a) == 32);
1980         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
1981         ret->a = a_ref;
1982         LDKChannelMonitor b_conv;
1983         b_conv.inner = (void*)(b & (~1));
1984         b_conv.is_owned = (b & 1) || (b == 0);
1985         b_conv = ChannelMonitor_clone(&b_conv);
1986         ret->b = b_conv;
1987         return (long)ret;
1988 }
1989 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1990         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1991         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
1992         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
1993         return a_arr;
1994 }
1995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1996         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1997         LDKChannelMonitor b_var = tuple->b;
1998         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1999         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2000         long b_ref = (long)b_var.inner & ~1;
2001         return b_ref;
2002 }
2003 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2004         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
2005 }
2006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2007         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2008         CHECK(val->result_ok);
2009         long res_ref = (long)(&(*val->contents.result)) | 1;
2010         return res_ref;
2011 }
2012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2013         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2014         CHECK(!val->result_ok);
2015         LDKDecodeError err_var = (*val->contents.err);
2016         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2017         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2018         long err_ref = (long)err_var.inner & ~1;
2019         return err_ref;
2020 }
2021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2022         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
2023         ret->datalen = (*env)->GetArrayLength(env, elems);
2024         if (ret->datalen == 0) {
2025                 ret->data = NULL;
2026         } else {
2027                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
2028                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2029                 for (size_t i = 0; i < ret->datalen; i++) {
2030                         int64_t arr_elem = java_elems[i];
2031                         LDKRouteHop arr_elem_conv;
2032                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2033                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2034                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
2035                         ret->data[i] = arr_elem_conv;
2036                 }
2037                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2038         }
2039         return (long)ret;
2040 }
2041 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
2042         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
2043         for (size_t i = 0; i < ret.datalen; i++) {
2044                 ret.data[i] = RouteHop_clone(&orig->data[i]);
2045         }
2046         return ret;
2047 }
2048 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2049         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2050         for (size_t i = 0; i < ret.datalen; i++) {
2051                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2052         }
2053         return ret;
2054 }
2055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2056         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
2057 }
2058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2059         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
2060         CHECK(val->result_ok);
2061         LDKRoute res_var = (*val->contents.result);
2062         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2063         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2064         long res_ref = (long)res_var.inner & ~1;
2065         return res_ref;
2066 }
2067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2068         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
2069         CHECK(!val->result_ok);
2070         LDKDecodeError err_var = (*val->contents.err);
2071         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2072         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2073         long err_ref = (long)err_var.inner & ~1;
2074         return err_ref;
2075 }
2076 static jclass LDKCOption_u64Z_Some_class = NULL;
2077 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
2078 static jclass LDKCOption_u64Z_None_class = NULL;
2079 static jmethodID LDKCOption_u64Z_None_meth = NULL;
2080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
2081         LDKCOption_u64Z_Some_class =
2082                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
2083         CHECK(LDKCOption_u64Z_Some_class != NULL);
2084         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
2085         CHECK(LDKCOption_u64Z_Some_meth != NULL);
2086         LDKCOption_u64Z_None_class =
2087                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
2088         CHECK(LDKCOption_u64Z_None_class != NULL);
2089         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
2090         CHECK(LDKCOption_u64Z_None_meth != NULL);
2091 }
2092 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2093         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
2094         switch(obj->tag) {
2095                 case LDKCOption_u64Z_Some: {
2096                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
2097                 }
2098                 case LDKCOption_u64Z_None: {
2099                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
2100                 }
2101                 default: abort();
2102         }
2103 }
2104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2105         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
2106         ret->datalen = (*env)->GetArrayLength(env, elems);
2107         if (ret->datalen == 0) {
2108                 ret->data = NULL;
2109         } else {
2110                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
2111                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2112                 for (size_t i = 0; i < ret->datalen; i++) {
2113                         int64_t arr_elem = java_elems[i];
2114                         LDKChannelDetails arr_elem_conv;
2115                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2116                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2117                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
2118                         ret->data[i] = arr_elem_conv;
2119                 }
2120                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2121         }
2122         return (long)ret;
2123 }
2124 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2125         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2126         for (size_t i = 0; i < ret.datalen; i++) {
2127                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2128         }
2129         return ret;
2130 }
2131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2132         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
2133         ret->datalen = (*env)->GetArrayLength(env, elems);
2134         if (ret->datalen == 0) {
2135                 ret->data = NULL;
2136         } else {
2137                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
2138                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2139                 for (size_t i = 0; i < ret->datalen; i++) {
2140                         int64_t arr_elem = java_elems[i];
2141                         LDKRouteHint arr_elem_conv;
2142                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2143                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2144                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
2145                         ret->data[i] = arr_elem_conv;
2146                 }
2147                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2148         }
2149         return (long)ret;
2150 }
2151 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2152         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2153         for (size_t i = 0; i < ret.datalen; i++) {
2154                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2155         }
2156         return ret;
2157 }
2158 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2159         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
2160 }
2161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2162         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
2163         CHECK(val->result_ok);
2164         LDKRoute res_var = (*val->contents.result);
2165         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2166         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2167         long res_ref = (long)res_var.inner & ~1;
2168         return res_ref;
2169 }
2170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2171         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
2172         CHECK(!val->result_ok);
2173         LDKLightningError err_var = (*val->contents.err);
2174         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2175         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2176         long err_ref = (long)err_var.inner & ~1;
2177         return err_ref;
2178 }
2179 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2180 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2181 static jclass LDKErrorAction_IgnoreError_class = NULL;
2182 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2183 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2184 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2186         LDKErrorAction_DisconnectPeer_class =
2187                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
2188         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2189         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2190         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2191         LDKErrorAction_IgnoreError_class =
2192                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
2193         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2194         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2195         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2196         LDKErrorAction_SendErrorMessage_class =
2197                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
2198         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2199         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2200         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2201 }
2202 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2203         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2204         switch(obj->tag) {
2205                 case LDKErrorAction_DisconnectPeer: {
2206                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2207                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2208                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2209                         long msg_ref = (long)msg_var.inner & ~1;
2210                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2211                 }
2212                 case LDKErrorAction_IgnoreError: {
2213                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2214                 }
2215                 case LDKErrorAction_SendErrorMessage: {
2216                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2217                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2218                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2219                         long msg_ref = (long)msg_var.inner & ~1;
2220                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2221                 }
2222                 default: abort();
2223         }
2224 }
2225 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
2226 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
2227 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
2228 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
2229 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
2230 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
2231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
2232         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
2233                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
2234         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
2235         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2236         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
2237         LDKHTLCFailChannelUpdate_ChannelClosed_class =
2238                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
2239         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
2240         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
2241         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
2242         LDKHTLCFailChannelUpdate_NodeFailure_class =
2243                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
2244         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
2245         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
2246         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
2247 }
2248 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2249         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
2250         switch(obj->tag) {
2251                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
2252                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2253                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2254                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2255                         long msg_ref = (long)msg_var.inner & ~1;
2256                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
2257                 }
2258                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
2259                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
2260                 }
2261                 case LDKHTLCFailChannelUpdate_NodeFailure: {
2262                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2263                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2264                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
2265                 }
2266                 default: abort();
2267         }
2268 }
2269 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2270 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2271 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2272 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2273 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2274 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2275 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2276 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2277 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
2278 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
2279 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2280 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2281 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2282 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2283 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2284 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2285 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2286 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2287 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2288 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2289 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2290 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2291 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2292 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2293 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2294 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2295 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2296 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2297 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2298 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2299 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
2300 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
2301 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2302 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2303 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2304 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2305 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2306 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2308         LDKMessageSendEvent_SendAcceptChannel_class =
2309                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
2310         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2311         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2312         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2313         LDKMessageSendEvent_SendOpenChannel_class =
2314                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
2315         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2316         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2317         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2318         LDKMessageSendEvent_SendFundingCreated_class =
2319                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
2320         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2321         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2322         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2323         LDKMessageSendEvent_SendFundingSigned_class =
2324                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
2325         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2326         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2327         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2328         LDKMessageSendEvent_SendFundingLocked_class =
2329                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
2330         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
2331         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
2332         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
2333         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2334                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
2335         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2336         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2337         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2338         LDKMessageSendEvent_UpdateHTLCs_class =
2339                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
2340         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2341         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2342         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2343         LDKMessageSendEvent_SendRevokeAndACK_class =
2344                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
2345         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2346         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2347         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2348         LDKMessageSendEvent_SendClosingSigned_class =
2349                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
2350         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2351         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2352         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2353         LDKMessageSendEvent_SendShutdown_class =
2354                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
2355         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2356         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2357         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2358         LDKMessageSendEvent_SendChannelReestablish_class =
2359                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
2360         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2361         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2362         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2363         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2364                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
2365         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2366         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2367         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2368         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2369                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
2370         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2371         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2372         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2373         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2374                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
2375         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2376         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2377         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2378         LDKMessageSendEvent_HandleError_class =
2379                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
2380         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2381         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2382         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2383         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
2384                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
2385         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
2386         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
2387         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
2388         LDKMessageSendEvent_SendChannelRangeQuery_class =
2389                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
2390         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2391         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2392         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2393         LDKMessageSendEvent_SendShortIdsQuery_class =
2394                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
2395         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2396         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2397         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2398         LDKMessageSendEvent_SendReplyChannelRange_class =
2399                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
2400         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2401         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2402         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2403 }
2404 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2405         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2406         switch(obj->tag) {
2407                 case LDKMessageSendEvent_SendAcceptChannel: {
2408                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2409                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2410                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2411                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2412                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2413                         long msg_ref = (long)msg_var.inner & ~1;
2414                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2415                 }
2416                 case LDKMessageSendEvent_SendOpenChannel: {
2417                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2418                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2419                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2420                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2421                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2422                         long msg_ref = (long)msg_var.inner & ~1;
2423                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2424                 }
2425                 case LDKMessageSendEvent_SendFundingCreated: {
2426                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2427                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2428                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2429                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2430                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2431                         long msg_ref = (long)msg_var.inner & ~1;
2432                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2433                 }
2434                 case LDKMessageSendEvent_SendFundingSigned: {
2435                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2436                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2437                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2438                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2439                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2440                         long msg_ref = (long)msg_var.inner & ~1;
2441                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2442                 }
2443                 case LDKMessageSendEvent_SendFundingLocked: {
2444                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2445                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
2446                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2447                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2448                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2449                         long msg_ref = (long)msg_var.inner & ~1;
2450                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
2451                 }
2452                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2453                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2454                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2455                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2456                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2457                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2458                         long msg_ref = (long)msg_var.inner & ~1;
2459                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
2460                 }
2461                 case LDKMessageSendEvent_UpdateHTLCs: {
2462                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2463                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
2464                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2465                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2466                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2467                         long updates_ref = (long)updates_var.inner & ~1;
2468                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
2469                 }
2470                 case LDKMessageSendEvent_SendRevokeAndACK: {
2471                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2472                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
2473                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2474                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2475                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2476                         long msg_ref = (long)msg_var.inner & ~1;
2477                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
2478                 }
2479                 case LDKMessageSendEvent_SendClosingSigned: {
2480                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2481                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
2482                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2483                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2484                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2485                         long msg_ref = (long)msg_var.inner & ~1;
2486                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
2487                 }
2488                 case LDKMessageSendEvent_SendShutdown: {
2489                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2490                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
2491                         LDKShutdown msg_var = obj->send_shutdown.msg;
2492                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2493                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2494                         long msg_ref = (long)msg_var.inner & ~1;
2495                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
2496                 }
2497                 case LDKMessageSendEvent_SendChannelReestablish: {
2498                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2499                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
2500                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2501                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2502                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2503                         long msg_ref = (long)msg_var.inner & ~1;
2504                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
2505                 }
2506                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
2507                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2508                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2509                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2510                         long msg_ref = (long)msg_var.inner & ~1;
2511                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2512                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2513                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2514                         long update_msg_ref = (long)update_msg_var.inner & ~1;
2515                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
2516                 }
2517                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
2518                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2519                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2520                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2521                         long msg_ref = (long)msg_var.inner & ~1;
2522                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
2523                 }
2524                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
2525                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2526                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2527                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2528                         long msg_ref = (long)msg_var.inner & ~1;
2529                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
2530                 }
2531                 case LDKMessageSendEvent_HandleError: {
2532                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2533                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
2534                         long action_ref = ((long)&obj->handle_error.action) | 1;
2535                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
2536                 }
2537                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
2538                         long update_ref = ((long)&obj->payment_failure_network_update.update) | 1;
2539                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
2540                 }
2541                 case LDKMessageSendEvent_SendChannelRangeQuery: {
2542                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2543                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
2544                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2545                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2546                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2547                         long msg_ref = (long)msg_var.inner & ~1;
2548                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
2549                 }
2550                 case LDKMessageSendEvent_SendShortIdsQuery: {
2551                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2552                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
2553                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2554                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2555                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2556                         long msg_ref = (long)msg_var.inner & ~1;
2557                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
2558                 }
2559                 case LDKMessageSendEvent_SendReplyChannelRange: {
2560                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2561                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
2562                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2563                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2564                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2565                         long msg_ref = (long)msg_var.inner & ~1;
2566                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
2567                 }
2568                 default: abort();
2569         }
2570 }
2571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2572         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
2573         ret->datalen = (*env)->GetArrayLength(env, elems);
2574         if (ret->datalen == 0) {
2575                 ret->data = NULL;
2576         } else {
2577                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
2578                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2579                 for (size_t i = 0; i < ret->datalen; i++) {
2580                         int64_t arr_elem = java_elems[i];
2581                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
2582                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
2583                         ret->data[i] = arr_elem_conv;
2584                 }
2585                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2586         }
2587         return (long)ret;
2588 }
2589 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2590         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2591         for (size_t i = 0; i < ret.datalen; i++) {
2592                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2593         }
2594         return ret;
2595 }
2596 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2597         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
2598 }
2599 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2600         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
2601         CHECK(val->result_ok);
2602         return *val->contents.result;
2603 }
2604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2605         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
2606         CHECK(!val->result_ok);
2607         LDKLightningError err_var = (*val->contents.err);
2608         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2609         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2610         long err_ref = (long)err_var.inner & ~1;
2611         return err_ref;
2612 }
2613 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) {
2614         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
2615         LDKChannelAnnouncement a_conv;
2616         a_conv.inner = (void*)(a & (~1));
2617         a_conv.is_owned = (a & 1) || (a == 0);
2618         a_conv = ChannelAnnouncement_clone(&a_conv);
2619         ret->a = a_conv;
2620         LDKChannelUpdate b_conv;
2621         b_conv.inner = (void*)(b & (~1));
2622         b_conv.is_owned = (b & 1) || (b == 0);
2623         b_conv = ChannelUpdate_clone(&b_conv);
2624         ret->b = b_conv;
2625         LDKChannelUpdate c_conv;
2626         c_conv.inner = (void*)(c & (~1));
2627         c_conv.is_owned = (c & 1) || (c == 0);
2628         c_conv = ChannelUpdate_clone(&c_conv);
2629         ret->c = c_conv;
2630         return (long)ret;
2631 }
2632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2633         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
2634         LDKChannelAnnouncement a_var = tuple->a;
2635         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2636         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2637         long a_ref = (long)a_var.inner & ~1;
2638         return a_ref;
2639 }
2640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2641         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
2642         LDKChannelUpdate b_var = tuple->b;
2643         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2644         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2645         long b_ref = (long)b_var.inner & ~1;
2646         return b_ref;
2647 }
2648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
2649         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
2650         LDKChannelUpdate c_var = tuple->c;
2651         CHECK((((long)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2652         CHECK((((long)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2653         long c_ref = (long)c_var.inner & ~1;
2654         return c_ref;
2655 }
2656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2657         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
2658         ret->datalen = (*env)->GetArrayLength(env, elems);
2659         if (ret->datalen == 0) {
2660                 ret->data = NULL;
2661         } else {
2662                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
2663                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2664                 for (size_t i = 0; i < ret->datalen; i++) {
2665                         int64_t arr_elem = java_elems[i];
2666                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
2667                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
2668                         ret->data[i] = arr_elem_conv;
2669                 }
2670                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2671         }
2672         return (long)ret;
2673 }
2674 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
2675         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
2676         for (size_t i = 0; i < ret.datalen; i++) {
2677                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
2678         }
2679         return ret;
2680 }
2681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2682         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
2683         ret->datalen = (*env)->GetArrayLength(env, elems);
2684         if (ret->datalen == 0) {
2685                 ret->data = NULL;
2686         } else {
2687                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
2688                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2689                 for (size_t i = 0; i < ret->datalen; i++) {
2690                         int64_t arr_elem = java_elems[i];
2691                         LDKNodeAnnouncement arr_elem_conv;
2692                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2693                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2694                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
2695                         ret->data[i] = arr_elem_conv;
2696                 }
2697                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2698         }
2699         return (long)ret;
2700 }
2701 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
2702         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
2703         for (size_t i = 0; i < ret.datalen; i++) {
2704                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
2705         }
2706         return ret;
2707 }
2708 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2709         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
2710 }
2711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2712         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
2713         CHECK(val->result_ok);
2714         return *val->contents.result;
2715 }
2716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2717         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
2718         CHECK(!val->result_ok);
2719         LDKLightningError err_var = (*val->contents.err);
2720         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2721         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2722         long err_ref = (long)err_var.inner & ~1;
2723         return err_ref;
2724 }
2725 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2726         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
2727 }
2728 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2729         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
2730         CHECK(val->result_ok);
2731         LDKCVec_u8Z res_var = (*val->contents.result);
2732         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
2733         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
2734         return res_arr;
2735 }
2736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2737         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
2738         CHECK(!val->result_ok);
2739         LDKPeerHandleError err_var = (*val->contents.err);
2740         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2741         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2742         long err_ref = (long)err_var.inner & ~1;
2743         return err_ref;
2744 }
2745 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2746         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
2747 }
2748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2749         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
2750         CHECK(val->result_ok);
2751         return *val->contents.result;
2752 }
2753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2754         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
2755         CHECK(!val->result_ok);
2756         LDKPeerHandleError err_var = (*val->contents.err);
2757         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2758         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2759         long err_ref = (long)err_var.inner & ~1;
2760         return err_ref;
2761 }
2762 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2763         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
2764 }
2765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2766         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
2767         CHECK(val->result_ok);
2768         return *val->contents.result;
2769 }
2770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2771         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
2772         CHECK(!val->result_ok);
2773         LDKPeerHandleError err_var = (*val->contents.err);
2774         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2775         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2776         long err_ref = (long)err_var.inner & ~1;
2777         return err_ref;
2778 }
2779 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2780         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
2781 }
2782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2783         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2784         CHECK(val->result_ok);
2785         long res_ref = ((long)&(*val->contents.result)) | 1;
2786         return (long)res_ref;
2787 }
2788 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2789         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2790         CHECK(!val->result_ok);
2791         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
2792         return err_conv;
2793 }
2794 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
2795 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
2796 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
2797 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
2798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
2799         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
2800                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
2801         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
2802         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
2803         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
2804         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
2805                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
2806         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
2807         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
2808         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
2809 }
2810 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2811         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2812         switch(obj->tag) {
2813                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
2814                         long some_ref = (long)(&obj->some) | 1;
2815                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, some_ref);
2816                 }
2817                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
2818                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
2819                 }
2820                 default: abort();
2821         }
2822 }
2823 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2824         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
2825 }
2826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2827         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
2828         CHECK(val->result_ok);
2829         LDKDirectionalChannelInfo res_var = (*val->contents.result);
2830         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2831         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2832         long res_ref = (long)res_var.inner & ~1;
2833         return res_ref;
2834 }
2835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2836         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
2837         CHECK(!val->result_ok);
2838         LDKDecodeError err_var = (*val->contents.err);
2839         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2840         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2841         long err_ref = (long)err_var.inner & ~1;
2842         return err_ref;
2843 }
2844 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2845         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
2846 }
2847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2848         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
2849         CHECK(val->result_ok);
2850         LDKChannelInfo res_var = (*val->contents.result);
2851         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2852         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2853         long res_ref = (long)res_var.inner & ~1;
2854         return res_ref;
2855 }
2856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2857         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
2858         CHECK(!val->result_ok);
2859         LDKDecodeError err_var = (*val->contents.err);
2860         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2861         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2862         long err_ref = (long)err_var.inner & ~1;
2863         return err_ref;
2864 }
2865 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2866         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
2867 }
2868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2869         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
2870         CHECK(val->result_ok);
2871         LDKRoutingFees res_var = (*val->contents.result);
2872         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2873         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2874         long res_ref = (long)res_var.inner & ~1;
2875         return res_ref;
2876 }
2877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2878         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
2879         CHECK(!val->result_ok);
2880         LDKDecodeError err_var = (*val->contents.err);
2881         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2882         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2883         long err_ref = (long)err_var.inner & ~1;
2884         return err_ref;
2885 }
2886 static jclass LDKNetAddress_IPv4_class = NULL;
2887 static jmethodID LDKNetAddress_IPv4_meth = NULL;
2888 static jclass LDKNetAddress_IPv6_class = NULL;
2889 static jmethodID LDKNetAddress_IPv6_meth = NULL;
2890 static jclass LDKNetAddress_OnionV2_class = NULL;
2891 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
2892 static jclass LDKNetAddress_OnionV3_class = NULL;
2893 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
2894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
2895         LDKNetAddress_IPv4_class =
2896                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
2897         CHECK(LDKNetAddress_IPv4_class != NULL);
2898         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
2899         CHECK(LDKNetAddress_IPv4_meth != NULL);
2900         LDKNetAddress_IPv6_class =
2901                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
2902         CHECK(LDKNetAddress_IPv6_class != NULL);
2903         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
2904         CHECK(LDKNetAddress_IPv6_meth != NULL);
2905         LDKNetAddress_OnionV2_class =
2906                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
2907         CHECK(LDKNetAddress_OnionV2_class != NULL);
2908         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
2909         CHECK(LDKNetAddress_OnionV2_meth != NULL);
2910         LDKNetAddress_OnionV3_class =
2911                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
2912         CHECK(LDKNetAddress_OnionV3_class != NULL);
2913         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
2914         CHECK(LDKNetAddress_OnionV3_meth != NULL);
2915 }
2916 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2917         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
2918         switch(obj->tag) {
2919                 case LDKNetAddress_IPv4: {
2920                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
2921                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
2922                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
2923                 }
2924                 case LDKNetAddress_IPv6: {
2925                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
2926                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
2927                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
2928                 }
2929                 case LDKNetAddress_OnionV2: {
2930                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
2931                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
2932                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
2933                 }
2934                 case LDKNetAddress_OnionV3: {
2935                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
2936                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
2937                         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);
2938                 }
2939                 default: abort();
2940         }
2941 }
2942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2943         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
2944         ret->datalen = (*env)->GetArrayLength(env, elems);
2945         if (ret->datalen == 0) {
2946                 ret->data = NULL;
2947         } else {
2948                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
2949                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2950                 for (size_t i = 0; i < ret->datalen; i++) {
2951                         int64_t arr_elem = java_elems[i];
2952                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
2953                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
2954                         ret->data[i] = arr_elem_conv;
2955                 }
2956                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2957         }
2958         return (long)ret;
2959 }
2960 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
2961         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
2962         for (size_t i = 0; i < ret.datalen; i++) {
2963                 ret.data[i] = NetAddress_clone(&orig->data[i]);
2964         }
2965         return ret;
2966 }
2967 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2968         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
2969 }
2970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2971         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
2972         CHECK(val->result_ok);
2973         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
2974         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2975         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2976         long res_ref = (long)res_var.inner & ~1;
2977         return res_ref;
2978 }
2979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2980         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
2981         CHECK(!val->result_ok);
2982         LDKDecodeError err_var = (*val->contents.err);
2983         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2984         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2985         long err_ref = (long)err_var.inner & ~1;
2986         return err_ref;
2987 }
2988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2989         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
2990         ret->datalen = (*env)->GetArrayLength(env, elems);
2991         if (ret->datalen == 0) {
2992                 ret->data = NULL;
2993         } else {
2994                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
2995                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2996                 for (size_t i = 0; i < ret->datalen; i++) {
2997                         ret->data[i] = java_elems[i];
2998                 }
2999                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3000         }
3001         return (long)ret;
3002 }
3003 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
3004         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
3005         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
3006         return ret;
3007 }
3008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3009         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
3010 }
3011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3012         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
3013         CHECK(val->result_ok);
3014         LDKNodeInfo res_var = (*val->contents.result);
3015         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3016         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3017         long res_ref = (long)res_var.inner & ~1;
3018         return res_ref;
3019 }
3020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3021         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
3022         CHECK(!val->result_ok);
3023         LDKDecodeError err_var = (*val->contents.err);
3024         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3025         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3026         long err_ref = (long)err_var.inner & ~1;
3027         return err_ref;
3028 }
3029 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3030         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
3031 }
3032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3033         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
3034         CHECK(val->result_ok);
3035         LDKNetworkGraph res_var = (*val->contents.result);
3036         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3037         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3038         long res_ref = (long)res_var.inner & ~1;
3039         return res_ref;
3040 }
3041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3042         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
3043         CHECK(!val->result_ok);
3044         LDKDecodeError err_var = (*val->contents.err);
3045         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3046         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3047         long err_ref = (long)err_var.inner & ~1;
3048         return err_ref;
3049 }
3050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3051         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
3052 }
3053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3054         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
3055         CHECK(val->result_ok);
3056         LDKInitFeatures res_var = (*val->contents.result);
3057         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3058         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3059         long res_ref = (long)res_var.inner & ~1;
3060         return res_ref;
3061 }
3062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3063         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
3064         CHECK(!val->result_ok);
3065         LDKDecodeError err_var = (*val->contents.err);
3066         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3067         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3068         long err_ref = (long)err_var.inner & ~1;
3069         return err_ref;
3070 }
3071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3072         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
3073 }
3074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3075         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
3076         CHECK(val->result_ok);
3077         LDKNodeFeatures res_var = (*val->contents.result);
3078         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3079         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3080         long res_ref = (long)res_var.inner & ~1;
3081         return res_ref;
3082 }
3083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3084         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
3085         CHECK(!val->result_ok);
3086         LDKDecodeError err_var = (*val->contents.err);
3087         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3088         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3089         long err_ref = (long)err_var.inner & ~1;
3090         return err_ref;
3091 }
3092 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3093         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
3094 }
3095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3096         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
3097         CHECK(val->result_ok);
3098         LDKChannelFeatures res_var = (*val->contents.result);
3099         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3100         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3101         long res_ref = (long)res_var.inner & ~1;
3102         return res_ref;
3103 }
3104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3105         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
3106         CHECK(!val->result_ok);
3107         LDKDecodeError err_var = (*val->contents.err);
3108         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3109         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3110         long err_ref = (long)err_var.inner & ~1;
3111         return err_ref;
3112 }
3113 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3114         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
3115 }
3116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3117         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
3118         CHECK(val->result_ok);
3119         LDKInvoiceFeatures res_var = (*val->contents.result);
3120         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3121         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3122         long res_ref = (long)res_var.inner & ~1;
3123         return res_ref;
3124 }
3125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3126         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
3127         CHECK(!val->result_ok);
3128         LDKDecodeError err_var = (*val->contents.err);
3129         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3130         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3131         long err_ref = (long)err_var.inner & ~1;
3132         return err_ref;
3133 }
3134 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3135         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
3136 }
3137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3138         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3139         CHECK(val->result_ok);
3140         long res_ref = ((long)&(*val->contents.result)) | 1;
3141         return res_ref;
3142 }
3143 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3144         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3145         CHECK(!val->result_ok);
3146         return *val->contents.err;
3147 }
3148 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3149         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
3150 }
3151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3152         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3153         CHECK(val->result_ok);
3154         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3155         *res_conv = (*val->contents.result);
3156         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
3157         return (long)res_conv;
3158 }
3159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3160         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3161         CHECK(!val->result_ok);
3162         LDKDecodeError err_var = (*val->contents.err);
3163         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3164         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3165         long err_ref = (long)err_var.inner & ~1;
3166         return err_ref;
3167 }
3168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3169         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
3170         ret->datalen = (*env)->GetArrayLength(env, elems);
3171         if (ret->datalen == 0) {
3172                 ret->data = NULL;
3173         } else {
3174                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
3175                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3176                 for (size_t i = 0; i < ret->datalen; i++) {
3177                         int64_t arr_elem = java_elems[i];
3178                         LDKUpdateAddHTLC arr_elem_conv;
3179                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3180                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3181                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3182                         ret->data[i] = arr_elem_conv;
3183                 }
3184                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3185         }
3186         return (long)ret;
3187 }
3188 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
3189         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
3190         for (size_t i = 0; i < ret.datalen; i++) {
3191                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
3192         }
3193         return ret;
3194 }
3195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3196         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
3197         ret->datalen = (*env)->GetArrayLength(env, elems);
3198         if (ret->datalen == 0) {
3199                 ret->data = NULL;
3200         } else {
3201                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
3202                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3203                 for (size_t i = 0; i < ret->datalen; i++) {
3204                         int64_t arr_elem = java_elems[i];
3205                         LDKUpdateFulfillHTLC arr_elem_conv;
3206                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3207                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3208                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3209                         ret->data[i] = arr_elem_conv;
3210                 }
3211                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3212         }
3213         return (long)ret;
3214 }
3215 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
3216         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
3217         for (size_t i = 0; i < ret.datalen; i++) {
3218                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
3219         }
3220         return ret;
3221 }
3222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3223         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
3224         ret->datalen = (*env)->GetArrayLength(env, elems);
3225         if (ret->datalen == 0) {
3226                 ret->data = NULL;
3227         } else {
3228                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
3229                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3230                 for (size_t i = 0; i < ret->datalen; i++) {
3231                         int64_t arr_elem = java_elems[i];
3232                         LDKUpdateFailHTLC arr_elem_conv;
3233                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3234                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3235                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
3236                         ret->data[i] = arr_elem_conv;
3237                 }
3238                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3239         }
3240         return (long)ret;
3241 }
3242 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
3243         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
3244         for (size_t i = 0; i < ret.datalen; i++) {
3245                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
3246         }
3247         return ret;
3248 }
3249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3250         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
3251         ret->datalen = (*env)->GetArrayLength(env, elems);
3252         if (ret->datalen == 0) {
3253                 ret->data = NULL;
3254         } else {
3255                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
3256                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3257                 for (size_t i = 0; i < ret->datalen; i++) {
3258                         int64_t arr_elem = java_elems[i];
3259                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3260                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3261                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3262                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3263                         ret->data[i] = arr_elem_conv;
3264                 }
3265                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3266         }
3267         return (long)ret;
3268 }
3269 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
3270         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
3271         for (size_t i = 0; i < ret.datalen; i++) {
3272                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
3273         }
3274         return ret;
3275 }
3276 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3277         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
3278 }
3279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3280         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3281         CHECK(val->result_ok);
3282         LDKAcceptChannel res_var = (*val->contents.result);
3283         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3284         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3285         long res_ref = (long)res_var.inner & ~1;
3286         return res_ref;
3287 }
3288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3289         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3290         CHECK(!val->result_ok);
3291         LDKDecodeError err_var = (*val->contents.err);
3292         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3293         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3294         long err_ref = (long)err_var.inner & ~1;
3295         return err_ref;
3296 }
3297 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3298         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
3299 }
3300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3301         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3302         CHECK(val->result_ok);
3303         LDKAnnouncementSignatures res_var = (*val->contents.result);
3304         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3305         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3306         long res_ref = (long)res_var.inner & ~1;
3307         return res_ref;
3308 }
3309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3310         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3311         CHECK(!val->result_ok);
3312         LDKDecodeError err_var = (*val->contents.err);
3313         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3314         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3315         long err_ref = (long)err_var.inner & ~1;
3316         return err_ref;
3317 }
3318 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3319         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
3320 }
3321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3322         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3323         CHECK(val->result_ok);
3324         LDKChannelReestablish res_var = (*val->contents.result);
3325         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3326         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3327         long res_ref = (long)res_var.inner & ~1;
3328         return res_ref;
3329 }
3330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3331         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3332         CHECK(!val->result_ok);
3333         LDKDecodeError err_var = (*val->contents.err);
3334         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3335         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3336         long err_ref = (long)err_var.inner & ~1;
3337         return err_ref;
3338 }
3339 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3340         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
3341 }
3342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3343         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
3344         CHECK(val->result_ok);
3345         LDKClosingSigned res_var = (*val->contents.result);
3346         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3347         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3348         long res_ref = (long)res_var.inner & ~1;
3349         return res_ref;
3350 }
3351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3352         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
3353         CHECK(!val->result_ok);
3354         LDKDecodeError err_var = (*val->contents.err);
3355         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3356         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3357         long err_ref = (long)err_var.inner & ~1;
3358         return err_ref;
3359 }
3360 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3361         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
3362 }
3363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3364         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
3365         CHECK(val->result_ok);
3366         LDKCommitmentSigned res_var = (*val->contents.result);
3367         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3368         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3369         long res_ref = (long)res_var.inner & ~1;
3370         return res_ref;
3371 }
3372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3373         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
3374         CHECK(!val->result_ok);
3375         LDKDecodeError err_var = (*val->contents.err);
3376         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3377         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3378         long err_ref = (long)err_var.inner & ~1;
3379         return err_ref;
3380 }
3381 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3382         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
3383 }
3384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3385         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
3386         CHECK(val->result_ok);
3387         LDKFundingCreated res_var = (*val->contents.result);
3388         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3389         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3390         long res_ref = (long)res_var.inner & ~1;
3391         return res_ref;
3392 }
3393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3394         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
3395         CHECK(!val->result_ok);
3396         LDKDecodeError err_var = (*val->contents.err);
3397         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3398         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3399         long err_ref = (long)err_var.inner & ~1;
3400         return err_ref;
3401 }
3402 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3403         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
3404 }
3405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3406         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
3407         CHECK(val->result_ok);
3408         LDKFundingSigned res_var = (*val->contents.result);
3409         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3410         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3411         long res_ref = (long)res_var.inner & ~1;
3412         return res_ref;
3413 }
3414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3415         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
3416         CHECK(!val->result_ok);
3417         LDKDecodeError err_var = (*val->contents.err);
3418         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3419         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3420         long err_ref = (long)err_var.inner & ~1;
3421         return err_ref;
3422 }
3423 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3424         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
3425 }
3426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3427         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
3428         CHECK(val->result_ok);
3429         LDKFundingLocked res_var = (*val->contents.result);
3430         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3431         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3432         long res_ref = (long)res_var.inner & ~1;
3433         return res_ref;
3434 }
3435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3436         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
3437         CHECK(!val->result_ok);
3438         LDKDecodeError err_var = (*val->contents.err);
3439         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3440         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3441         long err_ref = (long)err_var.inner & ~1;
3442         return err_ref;
3443 }
3444 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3445         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
3446 }
3447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3448         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
3449         CHECK(val->result_ok);
3450         LDKInit res_var = (*val->contents.result);
3451         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3452         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3453         long res_ref = (long)res_var.inner & ~1;
3454         return res_ref;
3455 }
3456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3457         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
3458         CHECK(!val->result_ok);
3459         LDKDecodeError err_var = (*val->contents.err);
3460         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3461         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3462         long err_ref = (long)err_var.inner & ~1;
3463         return err_ref;
3464 }
3465 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3466         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
3467 }
3468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3469         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
3470         CHECK(val->result_ok);
3471         LDKOpenChannel res_var = (*val->contents.result);
3472         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3473         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3474         long res_ref = (long)res_var.inner & ~1;
3475         return res_ref;
3476 }
3477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3478         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
3479         CHECK(!val->result_ok);
3480         LDKDecodeError err_var = (*val->contents.err);
3481         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3482         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3483         long err_ref = (long)err_var.inner & ~1;
3484         return err_ref;
3485 }
3486 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3487         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
3488 }
3489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3490         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
3491         CHECK(val->result_ok);
3492         LDKRevokeAndACK res_var = (*val->contents.result);
3493         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3494         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3495         long res_ref = (long)res_var.inner & ~1;
3496         return res_ref;
3497 }
3498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3499         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
3500         CHECK(!val->result_ok);
3501         LDKDecodeError err_var = (*val->contents.err);
3502         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3503         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3504         long err_ref = (long)err_var.inner & ~1;
3505         return err_ref;
3506 }
3507 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3508         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
3509 }
3510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3511         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
3512         CHECK(val->result_ok);
3513         LDKShutdown res_var = (*val->contents.result);
3514         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3515         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3516         long res_ref = (long)res_var.inner & ~1;
3517         return res_ref;
3518 }
3519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3520         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
3521         CHECK(!val->result_ok);
3522         LDKDecodeError err_var = (*val->contents.err);
3523         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3524         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3525         long err_ref = (long)err_var.inner & ~1;
3526         return err_ref;
3527 }
3528 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3529         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
3530 }
3531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3532         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
3533         CHECK(val->result_ok);
3534         LDKUpdateFailHTLC res_var = (*val->contents.result);
3535         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3536         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3537         long res_ref = (long)res_var.inner & ~1;
3538         return res_ref;
3539 }
3540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3541         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
3542         CHECK(!val->result_ok);
3543         LDKDecodeError err_var = (*val->contents.err);
3544         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3545         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3546         long err_ref = (long)err_var.inner & ~1;
3547         return err_ref;
3548 }
3549 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3550         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
3551 }
3552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3553         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
3554         CHECK(val->result_ok);
3555         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
3556         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3557         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3558         long res_ref = (long)res_var.inner & ~1;
3559         return res_ref;
3560 }
3561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3562         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
3563         CHECK(!val->result_ok);
3564         LDKDecodeError err_var = (*val->contents.err);
3565         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3566         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3567         long err_ref = (long)err_var.inner & ~1;
3568         return err_ref;
3569 }
3570 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3571         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
3572 }
3573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3574         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
3575         CHECK(val->result_ok);
3576         LDKUpdateFee res_var = (*val->contents.result);
3577         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3578         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3579         long res_ref = (long)res_var.inner & ~1;
3580         return res_ref;
3581 }
3582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3583         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
3584         CHECK(!val->result_ok);
3585         LDKDecodeError err_var = (*val->contents.err);
3586         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3587         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3588         long err_ref = (long)err_var.inner & ~1;
3589         return err_ref;
3590 }
3591 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3592         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
3593 }
3594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3595         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
3596         CHECK(val->result_ok);
3597         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
3598         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3599         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3600         long res_ref = (long)res_var.inner & ~1;
3601         return res_ref;
3602 }
3603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3604         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
3605         CHECK(!val->result_ok);
3606         LDKDecodeError err_var = (*val->contents.err);
3607         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3608         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3609         long err_ref = (long)err_var.inner & ~1;
3610         return err_ref;
3611 }
3612 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3613         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
3614 }
3615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3616         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
3617         CHECK(val->result_ok);
3618         LDKUpdateAddHTLC res_var = (*val->contents.result);
3619         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3620         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3621         long res_ref = (long)res_var.inner & ~1;
3622         return res_ref;
3623 }
3624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3625         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
3626         CHECK(!val->result_ok);
3627         LDKDecodeError err_var = (*val->contents.err);
3628         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3629         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3630         long err_ref = (long)err_var.inner & ~1;
3631         return err_ref;
3632 }
3633 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3634         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
3635 }
3636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3637         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
3638         CHECK(val->result_ok);
3639         LDKPing res_var = (*val->contents.result);
3640         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3641         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3642         long res_ref = (long)res_var.inner & ~1;
3643         return res_ref;
3644 }
3645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3646         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
3647         CHECK(!val->result_ok);
3648         LDKDecodeError err_var = (*val->contents.err);
3649         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3650         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3651         long err_ref = (long)err_var.inner & ~1;
3652         return err_ref;
3653 }
3654 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3655         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
3656 }
3657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3658         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
3659         CHECK(val->result_ok);
3660         LDKPong res_var = (*val->contents.result);
3661         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3662         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3663         long res_ref = (long)res_var.inner & ~1;
3664         return res_ref;
3665 }
3666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3667         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
3668         CHECK(!val->result_ok);
3669         LDKDecodeError err_var = (*val->contents.err);
3670         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3671         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3672         long err_ref = (long)err_var.inner & ~1;
3673         return err_ref;
3674 }
3675 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3676         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
3677 }
3678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3679         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3680         CHECK(val->result_ok);
3681         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
3682         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3683         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3684         long res_ref = (long)res_var.inner & ~1;
3685         return res_ref;
3686 }
3687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3688         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3689         CHECK(!val->result_ok);
3690         LDKDecodeError err_var = (*val->contents.err);
3691         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3692         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3693         long err_ref = (long)err_var.inner & ~1;
3694         return err_ref;
3695 }
3696 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3697         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
3698 }
3699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3700         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3701         CHECK(val->result_ok);
3702         LDKChannelAnnouncement res_var = (*val->contents.result);
3703         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3704         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3705         long res_ref = (long)res_var.inner & ~1;
3706         return res_ref;
3707 }
3708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3709         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3710         CHECK(!val->result_ok);
3711         LDKDecodeError err_var = (*val->contents.err);
3712         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3713         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3714         long err_ref = (long)err_var.inner & ~1;
3715         return err_ref;
3716 }
3717 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3718         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
3719 }
3720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3721         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
3722         CHECK(val->result_ok);
3723         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
3724         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3725         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3726         long res_ref = (long)res_var.inner & ~1;
3727         return res_ref;
3728 }
3729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3730         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
3731         CHECK(!val->result_ok);
3732         LDKDecodeError err_var = (*val->contents.err);
3733         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3734         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3735         long err_ref = (long)err_var.inner & ~1;
3736         return err_ref;
3737 }
3738 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3739         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
3740 }
3741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3742         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
3743         CHECK(val->result_ok);
3744         LDKChannelUpdate res_var = (*val->contents.result);
3745         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3746         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3747         long res_ref = (long)res_var.inner & ~1;
3748         return res_ref;
3749 }
3750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3751         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
3752         CHECK(!val->result_ok);
3753         LDKDecodeError err_var = (*val->contents.err);
3754         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3755         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3756         long err_ref = (long)err_var.inner & ~1;
3757         return err_ref;
3758 }
3759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3760         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
3761 }
3762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3763         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
3764         CHECK(val->result_ok);
3765         LDKErrorMessage res_var = (*val->contents.result);
3766         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3767         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3768         long res_ref = (long)res_var.inner & ~1;
3769         return res_ref;
3770 }
3771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3772         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
3773         CHECK(!val->result_ok);
3774         LDKDecodeError err_var = (*val->contents.err);
3775         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3776         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3777         long err_ref = (long)err_var.inner & ~1;
3778         return err_ref;
3779 }
3780 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3781         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
3782 }
3783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3784         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
3785         CHECK(val->result_ok);
3786         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
3787         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3788         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3789         long res_ref = (long)res_var.inner & ~1;
3790         return res_ref;
3791 }
3792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3793         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
3794         CHECK(!val->result_ok);
3795         LDKDecodeError err_var = (*val->contents.err);
3796         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3797         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3798         long err_ref = (long)err_var.inner & ~1;
3799         return err_ref;
3800 }
3801 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3802         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
3803 }
3804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3805         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
3806         CHECK(val->result_ok);
3807         LDKNodeAnnouncement res_var = (*val->contents.result);
3808         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3809         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3810         long res_ref = (long)res_var.inner & ~1;
3811         return res_ref;
3812 }
3813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3814         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
3815         CHECK(!val->result_ok);
3816         LDKDecodeError err_var = (*val->contents.err);
3817         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3818         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3819         long err_ref = (long)err_var.inner & ~1;
3820         return err_ref;
3821 }
3822 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3823         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
3824 }
3825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3826         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
3827         CHECK(val->result_ok);
3828         LDKQueryShortChannelIds res_var = (*val->contents.result);
3829         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3830         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3831         long res_ref = (long)res_var.inner & ~1;
3832         return res_ref;
3833 }
3834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3835         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
3836         CHECK(!val->result_ok);
3837         LDKDecodeError err_var = (*val->contents.err);
3838         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3839         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3840         long err_ref = (long)err_var.inner & ~1;
3841         return err_ref;
3842 }
3843 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3844         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
3845 }
3846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3847         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
3848         CHECK(val->result_ok);
3849         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
3850         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3851         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3852         long res_ref = (long)res_var.inner & ~1;
3853         return res_ref;
3854 }
3855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3856         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
3857         CHECK(!val->result_ok);
3858         LDKDecodeError err_var = (*val->contents.err);
3859         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3860         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3861         long err_ref = (long)err_var.inner & ~1;
3862         return err_ref;
3863 }
3864 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3865         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
3866 }
3867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3868         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
3869         CHECK(val->result_ok);
3870         LDKQueryChannelRange res_var = (*val->contents.result);
3871         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3872         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3873         long res_ref = (long)res_var.inner & ~1;
3874         return res_ref;
3875 }
3876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3877         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
3878         CHECK(!val->result_ok);
3879         LDKDecodeError err_var = (*val->contents.err);
3880         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3881         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3882         long err_ref = (long)err_var.inner & ~1;
3883         return err_ref;
3884 }
3885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3886         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
3887 }
3888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3889         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
3890         CHECK(val->result_ok);
3891         LDKReplyChannelRange res_var = (*val->contents.result);
3892         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3893         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3894         long res_ref = (long)res_var.inner & ~1;
3895         return res_ref;
3896 }
3897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3898         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
3899         CHECK(!val->result_ok);
3900         LDKDecodeError err_var = (*val->contents.err);
3901         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3902         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3903         long err_ref = (long)err_var.inner & ~1;
3904         return err_ref;
3905 }
3906 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3907         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
3908 }
3909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3910         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
3911         CHECK(val->result_ok);
3912         LDKGossipTimestampFilter res_var = (*val->contents.result);
3913         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3914         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3915         long res_ref = (long)res_var.inner & ~1;
3916         return res_ref;
3917 }
3918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3919         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
3920         CHECK(!val->result_ok);
3921         LDKDecodeError err_var = (*val->contents.err);
3922         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3923         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3924         long err_ref = (long)err_var.inner & ~1;
3925         return err_ref;
3926 }
3927 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3928         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
3929 }
3930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3931         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
3932         CHECK(val->result_ok);
3933         long res_ref = ((long)&(*val->contents.result)) | 1;
3934         return res_ref;
3935 }
3936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3937         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
3938         CHECK(!val->result_ok);
3939         LDKDecodeError err_var = (*val->contents.err);
3940         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3941         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3942         long err_ref = (long)err_var.inner & ~1;
3943         return err_ref;
3944 }
3945 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3946         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
3947 }
3948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3949         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3950         CHECK(val->result_ok);
3951         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3952         *ret = Sign_clone(&(*val->contents.result));
3953         return (long)ret;
3954 }
3955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3956         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3957         CHECK(!val->result_ok);
3958         LDKDecodeError err_var = (*val->contents.err);
3959         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3960         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3961         long err_ref = (long)err_var.inner & ~1;
3962         return err_ref;
3963 }
3964 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3965         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3966         for (size_t i = 0; i < ret.datalen; i++) {
3967                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3968         }
3969         return ret;
3970 }
3971 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3972         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
3973 }
3974 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3975         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3976         CHECK(val->result_ok);
3977         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
3978         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
3979         ;
3980         for (size_t i = 0; i < res_var.datalen; i++) {
3981                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
3982                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
3983                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
3984                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
3985         }
3986         return res_arr;
3987 }
3988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3989         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3990         CHECK(!val->result_ok);
3991         return *val->contents.err;
3992 }
3993 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3994         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
3995 }
3996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3997         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3998         CHECK(val->result_ok);
3999         LDKInMemorySigner res_var = (*val->contents.result);
4000         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4001         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4002         long res_ref = (long)res_var.inner & ~1;
4003         return res_ref;
4004 }
4005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4006         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
4007         CHECK(!val->result_ok);
4008         LDKDecodeError err_var = (*val->contents.err);
4009         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4010         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4011         long err_ref = (long)err_var.inner & ~1;
4012         return err_ref;
4013 }
4014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4015         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
4016         ret->datalen = (*env)->GetArrayLength(env, elems);
4017         if (ret->datalen == 0) {
4018                 ret->data = NULL;
4019         } else {
4020                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
4021                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4022                 for (size_t i = 0; i < ret->datalen; i++) {
4023                         int64_t arr_elem = java_elems[i];
4024                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
4025                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
4026                         ret->data[i] = arr_elem_conv;
4027                 }
4028                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4029         }
4030         return (long)ret;
4031 }
4032 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
4033         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
4034         for (size_t i = 0; i < ret.datalen; i++) {
4035                 ret.data[i] = TxOut_clone(&orig->data[i]);
4036         }
4037         return ret;
4038 }
4039 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4040         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
4041 }
4042 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4043         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
4044         CHECK(val->result_ok);
4045         LDKTransaction res_var = (*val->contents.result);
4046         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
4047         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
4048         return res_arr;
4049 }
4050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4051         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
4052         CHECK(!val->result_ok);
4053         return *val->contents.err;
4054 }
4055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4056         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
4057 }
4058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4059         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
4060         CHECK(val->result_ok);
4061         return *val->contents.result;
4062 }
4063 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4064         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
4065         CHECK(!val->result_ok);
4066         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
4067         return err_conv;
4068 }
4069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4070         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
4071         ret->datalen = (*env)->GetArrayLength(env, elems);
4072         if (ret->datalen == 0) {
4073                 ret->data = NULL;
4074         } else {
4075                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
4076                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4077                 for (size_t i = 0; i < ret->datalen; i++) {
4078                         int64_t arr_elem = java_elems[i];
4079                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
4080                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
4081                         ret->data[i] = arr_elem_conv;
4082                 }
4083                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4084         }
4085         return (long)ret;
4086 }
4087 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4088         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
4089 }
4090 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4091         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
4092         CHECK(val->result_ok);
4093         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
4094         int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
4095         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
4096         for (size_t i = 0; i < res_var.datalen; i++) {
4097                 long res_conv_34_ref = (long)(&res_var.data[i]) | 1;
4098                 res_arr_ptr[i] = res_conv_34_ref;
4099         }
4100         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
4101         return res_arr;
4102 }
4103 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4104         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
4105         CHECK(!val->result_ok);
4106         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
4107         return err_conv;
4108 }
4109 static jclass LDKAPIError_APIMisuseError_class = NULL;
4110 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
4111 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
4112 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
4113 static jclass LDKAPIError_RouteError_class = NULL;
4114 static jmethodID LDKAPIError_RouteError_meth = NULL;
4115 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
4116 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
4117 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
4118 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
4119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
4120         LDKAPIError_APIMisuseError_class =
4121                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
4122         CHECK(LDKAPIError_APIMisuseError_class != NULL);
4123         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "([B)V");
4124         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
4125         LDKAPIError_FeeRateTooHigh_class =
4126                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
4127         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
4128         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "([BI)V");
4129         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
4130         LDKAPIError_RouteError_class =
4131                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
4132         CHECK(LDKAPIError_RouteError_class != NULL);
4133         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
4134         CHECK(LDKAPIError_RouteError_meth != NULL);
4135         LDKAPIError_ChannelUnavailable_class =
4136                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
4137         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
4138         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "([B)V");
4139         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
4140         LDKAPIError_MonitorUpdateFailed_class =
4141                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
4142         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
4143         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
4144         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
4145 }
4146 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4147         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4148         switch(obj->tag) {
4149                 case LDKAPIError_APIMisuseError: {
4150                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
4151                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
4152                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
4153                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_arr);
4154                 }
4155                 case LDKAPIError_FeeRateTooHigh: {
4156                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
4157                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
4158                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
4159                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_arr, obj->fee_rate_too_high.feerate);
4160                 }
4161                 case LDKAPIError_RouteError: {
4162                         LDKStr err_str = obj->route_error.err;
4163                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4164                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
4165                 }
4166                 case LDKAPIError_ChannelUnavailable: {
4167                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
4168                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
4169                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
4170                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_arr);
4171                 }
4172                 case LDKAPIError_MonitorUpdateFailed: {
4173                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
4174                 }
4175                 default: abort();
4176         }
4177 }
4178 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4179         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
4180 }
4181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4182         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
4183         CHECK(val->result_ok);
4184         return *val->contents.result;
4185 }
4186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4187         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
4188         CHECK(!val->result_ok);
4189         long err_ref = ((long)&(*val->contents.err)) | 1;
4190         return err_ref;
4191 }
4192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4193         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
4194         ret->datalen = (*env)->GetArrayLength(env, elems);
4195         if (ret->datalen == 0) {
4196                 ret->data = NULL;
4197         } else {
4198                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
4199                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4200                 for (size_t i = 0; i < ret->datalen; i++) {
4201                         int64_t arr_elem = java_elems[i];
4202                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
4203                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
4204                         ret->data[i] = arr_elem_conv;
4205                 }
4206                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4207         }
4208         return (long)ret;
4209 }
4210 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
4211         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
4212         for (size_t i = 0; i < ret.datalen; i++) {
4213                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
4214         }
4215         return ret;
4216 }
4217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4218         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
4219         ret->datalen = (*env)->GetArrayLength(env, elems);
4220         if (ret->datalen == 0) {
4221                 ret->data = NULL;
4222         } else {
4223                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
4224                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4225                 for (size_t i = 0; i < ret->datalen; i++) {
4226                         int64_t arr_elem = java_elems[i];
4227                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
4228                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
4229                         ret->data[i] = arr_elem_conv;
4230                 }
4231                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4232         }
4233         return (long)ret;
4234 }
4235 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
4236         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
4237         for (size_t i = 0; i < ret.datalen; i++) {
4238                 ret.data[i] = APIError_clone(&orig->data[i]);
4239         }
4240         return ret;
4241 }
4242 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
4243 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
4244 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
4245 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
4246 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
4247 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
4248 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
4249 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
4250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
4251         LDKPaymentSendFailure_ParameterError_class =
4252                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
4253         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
4254         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
4255         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
4256         LDKPaymentSendFailure_PathParameterError_class =
4257                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
4258         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
4259         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
4260         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
4261         LDKPaymentSendFailure_AllFailedRetrySafe_class =
4262                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
4263         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
4264         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
4265         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
4266         LDKPaymentSendFailure_PartialFailure_class =
4267                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
4268         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
4269         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
4270         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
4271 }
4272 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4273         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4274         switch(obj->tag) {
4275                 case LDKPaymentSendFailure_ParameterError: {
4276                         long parameter_error_ref = ((long)&obj->parameter_error) | 1;
4277                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
4278                 }
4279                 case LDKPaymentSendFailure_PathParameterError: {
4280                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
4281                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
4282                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
4283                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
4284                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4285                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
4286                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
4287                                 path_parameter_error_arr_ptr[w] = (long)path_parameter_error_conv_22_conv;
4288                         }
4289                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
4290                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
4291                 }
4292                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
4293                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
4294                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
4295                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
4296                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
4297                                 long all_failed_retry_safe_conv_10_ref = ((long)&all_failed_retry_safe_var.data[k]) | 1;
4298                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
4299                         }
4300                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
4301                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
4302                 }
4303                 case LDKPaymentSendFailure_PartialFailure: {
4304                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
4305                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
4306                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
4307                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
4308                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4309                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
4310                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
4311                                 partial_failure_arr_ptr[w] = (long)partial_failure_conv_22_conv;
4312                         }
4313                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
4314                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
4315                 }
4316                 default: abort();
4317         }
4318 }
4319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4320         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
4321 }
4322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4323         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
4324         CHECK(val->result_ok);
4325         return *val->contents.result;
4326 }
4327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4328         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
4329         CHECK(!val->result_ok);
4330         long err_ref = ((long)&(*val->contents.err)) | 1;
4331         return err_ref;
4332 }
4333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4334         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
4335         ret->datalen = (*env)->GetArrayLength(env, elems);
4336         if (ret->datalen == 0) {
4337                 ret->data = NULL;
4338         } else {
4339                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
4340                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4341                 for (size_t i = 0; i < ret->datalen; i++) {
4342                         int64_t arr_elem = java_elems[i];
4343                         LDKChannelMonitor arr_elem_conv;
4344                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4345                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4346                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
4347                         ret->data[i] = arr_elem_conv;
4348                 }
4349                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4350         }
4351         return (long)ret;
4352 }
4353 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
4354         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
4355         for (size_t i = 0; i < ret.datalen; i++) {
4356                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4357         }
4358         return ret;
4359 }
4360 typedef struct LDKWatch_JCalls {
4361         atomic_size_t refcnt;
4362         JavaVM *vm;
4363         jweak o;
4364         jmethodID watch_channel_meth;
4365         jmethodID update_channel_meth;
4366         jmethodID release_pending_monitor_events_meth;
4367 } LDKWatch_JCalls;
4368 static void LDKWatch_JCalls_free(void* this_arg) {
4369         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4370         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4371                 JNIEnv *env;
4372                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4373                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4374                 FREE(j_calls);
4375         }
4376 }
4377 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4378         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4379         JNIEnv *env;
4380         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4381         LDKOutPoint funding_txo_var = funding_txo;
4382         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4383         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4384         long funding_txo_ref = (long)funding_txo_var.inner;
4385         if (funding_txo_var.is_owned) {
4386                 funding_txo_ref |= 1;
4387         }
4388         LDKChannelMonitor monitor_var = monitor;
4389         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4390         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4391         long monitor_ref = (long)monitor_var.inner;
4392         if (monitor_var.is_owned) {
4393                 monitor_ref |= 1;
4394         }
4395         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4396         CHECK(obj != NULL);
4397         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
4398         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
4399         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
4400         return ret_conv;
4401 }
4402 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
4403         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4404         JNIEnv *env;
4405         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4406         LDKOutPoint funding_txo_var = funding_txo;
4407         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4408         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4409         long funding_txo_ref = (long)funding_txo_var.inner;
4410         if (funding_txo_var.is_owned) {
4411                 funding_txo_ref |= 1;
4412         }
4413         LDKChannelMonitorUpdate update_var = update;
4414         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4415         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4416         long update_ref = (long)update_var.inner;
4417         if (update_var.is_owned) {
4418                 update_ref |= 1;
4419         }
4420         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4421         CHECK(obj != NULL);
4422         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
4423         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
4424         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
4425         return ret_conv;
4426 }
4427 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
4428         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4429         JNIEnv *env;
4430         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4431         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4432         CHECK(obj != NULL);
4433         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
4434         LDKCVec_MonitorEventZ ret_constr;
4435         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
4436         if (ret_constr.datalen > 0)
4437                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4438         else
4439                 ret_constr.data = NULL;
4440         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
4441         for (size_t o = 0; o < ret_constr.datalen; o++) {
4442                 int64_t ret_conv_14 = ret_vals[o];
4443                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
4444                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
4445                 ret_constr.data[o] = ret_conv_14_conv;
4446         }
4447         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
4448         return ret_constr;
4449 }
4450 static void* LDKWatch_JCalls_clone(const void* this_arg) {
4451         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4452         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4453         return (void*) this_arg;
4454 }
4455 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
4456         jclass c = (*env)->GetObjectClass(env, o);
4457         CHECK(c != NULL);
4458         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
4459         atomic_init(&calls->refcnt, 1);
4460         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4461         calls->o = (*env)->NewWeakGlobalRef(env, o);
4462         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
4463         CHECK(calls->watch_channel_meth != NULL);
4464         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
4465         CHECK(calls->update_channel_meth != NULL);
4466         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
4467         CHECK(calls->release_pending_monitor_events_meth != NULL);
4468
4469         LDKWatch ret = {
4470                 .this_arg = (void*) calls,
4471                 .watch_channel = watch_channel_LDKWatch_jcall,
4472                 .update_channel = update_channel_LDKWatch_jcall,
4473                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
4474                 .free = LDKWatch_JCalls_free,
4475         };
4476         return ret;
4477 }
4478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
4479         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
4480         *res_ptr = LDKWatch_init(env, clz, o);
4481         return (long)res_ptr;
4482 }
4483 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) {
4484         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
4485         LDKOutPoint funding_txo_conv;
4486         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4487         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4488         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4489         LDKChannelMonitor monitor_conv;
4490         monitor_conv.inner = (void*)(monitor & (~1));
4491         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
4492         monitor_conv = ChannelMonitor_clone(&monitor_conv);
4493         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4494         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
4495         return (long)ret_conv;
4496 }
4497
4498 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) {
4499         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
4500         LDKOutPoint funding_txo_conv;
4501         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4502         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4503         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4504         LDKChannelMonitorUpdate update_conv;
4505         update_conv.inner = (void*)(update & (~1));
4506         update_conv.is_owned = (update & 1) || (update == 0);
4507         update_conv = ChannelMonitorUpdate_clone(&update_conv);
4508         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4509         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
4510         return (long)ret_conv;
4511 }
4512
4513 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4514         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
4515         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
4516         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4517         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4518         for (size_t o = 0; o < ret_var.datalen; o++) {
4519                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4520                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
4521                 long ret_conv_14_ref = (long)ret_conv_14_copy;
4522                 ret_arr_ptr[o] = ret_conv_14_ref;
4523         }
4524         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4525         FREE(ret_var.data);
4526         return ret_arr;
4527 }
4528
4529 typedef struct LDKBroadcasterInterface_JCalls {
4530         atomic_size_t refcnt;
4531         JavaVM *vm;
4532         jweak o;
4533         jmethodID broadcast_transaction_meth;
4534 } LDKBroadcasterInterface_JCalls;
4535 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
4536         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4537         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4538                 JNIEnv *env;
4539                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4540                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4541                 FREE(j_calls);
4542         }
4543 }
4544 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
4545         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4546         JNIEnv *env;
4547         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4548         LDKTransaction tx_var = tx;
4549         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
4550         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
4551         Transaction_free(tx_var);
4552         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4553         CHECK(obj != NULL);
4554         return (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
4555 }
4556 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
4557         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4558         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4559         return (void*) this_arg;
4560 }
4561 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
4562         jclass c = (*env)->GetObjectClass(env, o);
4563         CHECK(c != NULL);
4564         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
4565         atomic_init(&calls->refcnt, 1);
4566         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4567         calls->o = (*env)->NewWeakGlobalRef(env, o);
4568         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
4569         CHECK(calls->broadcast_transaction_meth != NULL);
4570
4571         LDKBroadcasterInterface ret = {
4572                 .this_arg = (void*) calls,
4573                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
4574                 .free = LDKBroadcasterInterface_JCalls_free,
4575         };
4576         return ret;
4577 }
4578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4579         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
4580         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
4581         return (long)res_ptr;
4582 }
4583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
4584         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
4585         LDKTransaction tx_ref;
4586         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
4587         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
4588         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
4589         tx_ref.data_is_owned = true;
4590         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
4591 }
4592
4593 typedef struct LDKKeysInterface_JCalls {
4594         atomic_size_t refcnt;
4595         JavaVM *vm;
4596         jweak o;
4597         jmethodID get_node_secret_meth;
4598         jmethodID get_destination_script_meth;
4599         jmethodID get_shutdown_pubkey_meth;
4600         jmethodID get_channel_signer_meth;
4601         jmethodID get_secure_random_bytes_meth;
4602         jmethodID read_chan_signer_meth;
4603 } LDKKeysInterface_JCalls;
4604 static void LDKKeysInterface_JCalls_free(void* this_arg) {
4605         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4606         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4607                 JNIEnv *env;
4608                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4609                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4610                 FREE(j_calls);
4611         }
4612 }
4613 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
4614         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4615         JNIEnv *env;
4616         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4617         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4618         CHECK(obj != NULL);
4619         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
4620         LDKSecretKey ret_ref;
4621         CHECK((*env)->GetArrayLength(env, ret) == 32);
4622         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
4623         return ret_ref;
4624 }
4625 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
4626         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4627         JNIEnv *env;
4628         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4629         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4630         CHECK(obj != NULL);
4631         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
4632         LDKCVec_u8Z ret_ref;
4633         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4634         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4635         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4636         return ret_ref;
4637 }
4638 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
4639         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4640         JNIEnv *env;
4641         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4642         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4643         CHECK(obj != NULL);
4644         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
4645         LDKPublicKey ret_ref;
4646         CHECK((*env)->GetArrayLength(env, ret) == 33);
4647         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
4648         return ret_ref;
4649 }
4650 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4651         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4652         JNIEnv *env;
4653         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4654         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4655         CHECK(obj != NULL);
4656         LDKSign* ret = (LDKSign*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
4657         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
4658         ret_conv = Sign_clone(ret);
4659         return ret_conv;
4660 }
4661 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4662         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4663         JNIEnv *env;
4664         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4665         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4666         CHECK(obj != NULL);
4667         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
4668         LDKThirtyTwoBytes ret_ref;
4669         CHECK((*env)->GetArrayLength(env, ret) == 32);
4670         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4671         return ret_ref;
4672 }
4673 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4674         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4675         JNIEnv *env;
4676         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4677         LDKu8slice reader_var = reader;
4678         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
4679         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
4680         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4681         CHECK(obj != NULL);
4682         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
4683         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
4684         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
4685         return ret_conv;
4686 }
4687 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
4688         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4689         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4690         return (void*) this_arg;
4691 }
4692 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
4693         jclass c = (*env)->GetObjectClass(env, o);
4694         CHECK(c != NULL);
4695         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4696         atomic_init(&calls->refcnt, 1);
4697         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4698         calls->o = (*env)->NewWeakGlobalRef(env, o);
4699         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
4700         CHECK(calls->get_node_secret_meth != NULL);
4701         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
4702         CHECK(calls->get_destination_script_meth != NULL);
4703         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
4704         CHECK(calls->get_shutdown_pubkey_meth != NULL);
4705         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
4706         CHECK(calls->get_channel_signer_meth != NULL);
4707         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
4708         CHECK(calls->get_secure_random_bytes_meth != NULL);
4709         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
4710         CHECK(calls->read_chan_signer_meth != NULL);
4711
4712         LDKKeysInterface ret = {
4713                 .this_arg = (void*) calls,
4714                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4715                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4716                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
4717                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4718                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4719                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4720                 .free = LDKKeysInterface_JCalls_free,
4721         };
4722         return ret;
4723 }
4724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4725         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4726         *res_ptr = LDKKeysInterface_init(env, clz, o);
4727         return (long)res_ptr;
4728 }
4729 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
4730         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4731         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4732         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
4733         return ret_arr;
4734 }
4735
4736 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
4737         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4738         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4739         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4740         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4741         CVec_u8Z_free(ret_var);
4742         return ret_arr;
4743 }
4744
4745 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
4746         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4747         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
4748         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
4749         return ret_arr;
4750 }
4751
4752 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) {
4753         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4754         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
4755         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4756         return (long)ret;
4757 }
4758
4759 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
4760         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4761         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4762         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
4763         return ret_arr;
4764 }
4765
4766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
4767         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4768         LDKu8slice reader_ref;
4769         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
4770         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
4771         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4772         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4773         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
4774         return (long)ret_conv;
4775 }
4776
4777 typedef struct LDKFeeEstimator_JCalls {
4778         atomic_size_t refcnt;
4779         JavaVM *vm;
4780         jweak o;
4781         jmethodID get_est_sat_per_1000_weight_meth;
4782 } LDKFeeEstimator_JCalls;
4783 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4784         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4785         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4786                 JNIEnv *env;
4787                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4788                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4789                 FREE(j_calls);
4790         }
4791 }
4792 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4793         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4794         JNIEnv *env;
4795         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4796         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
4797         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4798         CHECK(obj != NULL);
4799         return (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
4800 }
4801 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
4802         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4803         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4804         return (void*) this_arg;
4805 }
4806 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4807         jclass c = (*env)->GetObjectClass(env, o);
4808         CHECK(c != NULL);
4809         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4810         atomic_init(&calls->refcnt, 1);
4811         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4812         calls->o = (*env)->NewWeakGlobalRef(env, o);
4813         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I");
4814         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4815
4816         LDKFeeEstimator ret = {
4817                 .this_arg = (void*) calls,
4818                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4819                 .free = LDKFeeEstimator_JCalls_free,
4820         };
4821         return ret;
4822 }
4823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4824         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4825         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4826         return (long)res_ptr;
4827 }
4828 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) {
4829         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
4830         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4831         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4832         return ret_val;
4833 }
4834
4835 typedef struct LDKLogger_JCalls {
4836         atomic_size_t refcnt;
4837         JavaVM *vm;
4838         jweak o;
4839         jmethodID log_meth;
4840 } LDKLogger_JCalls;
4841 static void LDKLogger_JCalls_free(void* this_arg) {
4842         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4843         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4844                 JNIEnv *env;
4845                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4846                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4847                 FREE(j_calls);
4848         }
4849 }
4850 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
4851         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4852         JNIEnv *env;
4853         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4854         const char* record_str = record;
4855         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
4856         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4857         CHECK(obj != NULL);
4858         return (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
4859 }
4860 static void* LDKLogger_JCalls_clone(const void* this_arg) {
4861         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4862         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4863         return (void*) this_arg;
4864 }
4865 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4866         jclass c = (*env)->GetObjectClass(env, o);
4867         CHECK(c != NULL);
4868         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4869         atomic_init(&calls->refcnt, 1);
4870         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4871         calls->o = (*env)->NewWeakGlobalRef(env, o);
4872         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
4873         CHECK(calls->log_meth != NULL);
4874
4875         LDKLogger ret = {
4876                 .this_arg = (void*) calls,
4877                 .log = log_LDKLogger_jcall,
4878                 .free = LDKLogger_JCalls_free,
4879         };
4880         return ret;
4881 }
4882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4883         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4884         *res_ptr = LDKLogger_init(env, clz, o);
4885         return (long)res_ptr;
4886 }
4887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
4888         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
4889         LDKThirtyTwoBytes a_ref;
4890         CHECK((*env)->GetArrayLength(env, a) == 32);
4891         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4892         ret->a = a_ref;
4893         LDKChannelManager b_conv;
4894         b_conv.inner = (void*)(b & (~1));
4895         b_conv.is_owned = (b & 1) || (b == 0);
4896         // Warning: we need a move here but no clone is available for LDKChannelManager
4897         ret->b = b_conv;
4898         return (long)ret;
4899 }
4900 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4901         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4902         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4903         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4904         return a_arr;
4905 }
4906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4907         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4908         LDKChannelManager b_var = tuple->b;
4909         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4910         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4911         long b_ref = (long)b_var.inner & ~1;
4912         return b_ref;
4913 }
4914 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4915         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
4916 }
4917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4918         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4919         CHECK(val->result_ok);
4920         long res_ref = (long)(&(*val->contents.result)) | 1;
4921         return res_ref;
4922 }
4923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4924         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4925         CHECK(!val->result_ok);
4926         LDKDecodeError err_var = (*val->contents.err);
4927         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4928         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4929         long err_ref = (long)err_var.inner & ~1;
4930         return err_ref;
4931 }
4932 typedef struct LDKMessageSendEventsProvider_JCalls {
4933         atomic_size_t refcnt;
4934         JavaVM *vm;
4935         jweak o;
4936         jmethodID get_and_clear_pending_msg_events_meth;
4937 } LDKMessageSendEventsProvider_JCalls;
4938 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
4939         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4940         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4941                 JNIEnv *env;
4942                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4943                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4944                 FREE(j_calls);
4945         }
4946 }
4947 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
4948         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4949         JNIEnv *env;
4950         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4951         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4952         CHECK(obj != NULL);
4953         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
4954         LDKCVec_MessageSendEventZ ret_constr;
4955         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
4956         if (ret_constr.datalen > 0)
4957                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4958         else
4959                 ret_constr.data = NULL;
4960         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
4961         for (size_t s = 0; s < ret_constr.datalen; s++) {
4962                 int64_t ret_conv_18 = ret_vals[s];
4963                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
4964                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
4965                 ret_constr.data[s] = ret_conv_18_conv;
4966         }
4967         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
4968         return ret_constr;
4969 }
4970 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
4971         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4972         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4973         return (void*) this_arg;
4974 }
4975 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
4976         jclass c = (*env)->GetObjectClass(env, o);
4977         CHECK(c != NULL);
4978         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
4979         atomic_init(&calls->refcnt, 1);
4980         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4981         calls->o = (*env)->NewWeakGlobalRef(env, o);
4982         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
4983         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
4984
4985         LDKMessageSendEventsProvider ret = {
4986                 .this_arg = (void*) calls,
4987                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
4988                 .free = LDKMessageSendEventsProvider_JCalls_free,
4989         };
4990         return ret;
4991 }
4992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
4993         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
4994         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
4995         return (long)res_ptr;
4996 }
4997 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4998         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
4999         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
5000         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5001         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5002         for (size_t s = 0; s < ret_var.datalen; s++) {
5003                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
5004                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
5005                 long ret_conv_18_ref = (long)ret_conv_18_copy;
5006                 ret_arr_ptr[s] = ret_conv_18_ref;
5007         }
5008         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5009         FREE(ret_var.data);
5010         return ret_arr;
5011 }
5012
5013 typedef struct LDKEventsProvider_JCalls {
5014         atomic_size_t refcnt;
5015         JavaVM *vm;
5016         jweak o;
5017         jmethodID get_and_clear_pending_events_meth;
5018 } LDKEventsProvider_JCalls;
5019 static void LDKEventsProvider_JCalls_free(void* this_arg) {
5020         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5021         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5022                 JNIEnv *env;
5023                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5024                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5025                 FREE(j_calls);
5026         }
5027 }
5028 LDKCVec_EventZ get_and_clear_pending_events_LDKEventsProvider_jcall(const void* this_arg) {
5029         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5030         JNIEnv *env;
5031         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5032         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5033         CHECK(obj != NULL);
5034         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_events_meth);
5035         LDKCVec_EventZ ret_constr;
5036         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
5037         if (ret_constr.datalen > 0)
5038                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
5039         else
5040                 ret_constr.data = NULL;
5041         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
5042         for (size_t h = 0; h < ret_constr.datalen; h++) {
5043                 int64_t ret_conv_7 = ret_vals[h];
5044                 LDKEvent ret_conv_7_conv = *(LDKEvent*)(((uint64_t)ret_conv_7) & ~1);
5045                 ret_conv_7_conv = Event_clone((LDKEvent*)(((uint64_t)ret_conv_7) & ~1));
5046                 ret_constr.data[h] = ret_conv_7_conv;
5047         }
5048         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
5049         return ret_constr;
5050 }
5051 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
5052         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5053         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5054         return (void*) this_arg;
5055 }
5056 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
5057         jclass c = (*env)->GetObjectClass(env, o);
5058         CHECK(c != NULL);
5059         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
5060         atomic_init(&calls->refcnt, 1);
5061         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5062         calls->o = (*env)->NewWeakGlobalRef(env, o);
5063         calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()[J");
5064         CHECK(calls->get_and_clear_pending_events_meth != NULL);
5065
5066         LDKEventsProvider ret = {
5067                 .this_arg = (void*) calls,
5068                 .get_and_clear_pending_events = get_and_clear_pending_events_LDKEventsProvider_jcall,
5069                 .free = LDKEventsProvider_JCalls_free,
5070         };
5071         return ret;
5072 }
5073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
5074         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
5075         *res_ptr = LDKEventsProvider_init(env, clz, o);
5076         return (long)res_ptr;
5077 }
5078 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_EventsProvider_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
5079         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
5080         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
5081         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5082         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5083         for (size_t h = 0; h < ret_var.datalen; h++) {
5084                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
5085                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
5086                 long ret_conv_7_ref = (long)ret_conv_7_copy;
5087                 ret_arr_ptr[h] = ret_conv_7_ref;
5088         }
5089         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5090         FREE(ret_var.data);
5091         return ret_arr;
5092 }
5093
5094 typedef struct LDKAccess_JCalls {
5095         atomic_size_t refcnt;
5096         JavaVM *vm;
5097         jweak o;
5098         jmethodID get_utxo_meth;
5099 } LDKAccess_JCalls;
5100 static void LDKAccess_JCalls_free(void* this_arg) {
5101         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
5102         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5103                 JNIEnv *env;
5104                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5105                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5106                 FREE(j_calls);
5107         }
5108 }
5109 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
5110         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
5111         JNIEnv *env;
5112         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5113         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
5114         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
5115         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5116         CHECK(obj != NULL);
5117         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
5118         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
5119         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
5120         return ret_conv;
5121 }
5122 static void* LDKAccess_JCalls_clone(const void* this_arg) {
5123         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
5124         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5125         return (void*) this_arg;
5126 }
5127 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
5128         jclass c = (*env)->GetObjectClass(env, o);
5129         CHECK(c != NULL);
5130         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
5131         atomic_init(&calls->refcnt, 1);
5132         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5133         calls->o = (*env)->NewWeakGlobalRef(env, o);
5134         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
5135         CHECK(calls->get_utxo_meth != NULL);
5136
5137         LDKAccess ret = {
5138                 .this_arg = (void*) calls,
5139                 .get_utxo = get_utxo_LDKAccess_jcall,
5140                 .free = LDKAccess_JCalls_free,
5141         };
5142         return ret;
5143 }
5144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
5145         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
5146         *res_ptr = LDKAccess_init(env, clz, o);
5147         return (long)res_ptr;
5148 }
5149 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) {
5150         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
5151         unsigned char genesis_hash_arr[32];
5152         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
5153         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
5154         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
5155         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
5156         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
5157         return (long)ret_conv;
5158 }
5159
5160 typedef struct LDKListen_JCalls {
5161         atomic_size_t refcnt;
5162         JavaVM *vm;
5163         jweak o;
5164         jmethodID block_connected_meth;
5165         jmethodID block_disconnected_meth;
5166 } LDKListen_JCalls;
5167 static void LDKListen_JCalls_free(void* this_arg) {
5168         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5169         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5170                 JNIEnv *env;
5171                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5172                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5173                 FREE(j_calls);
5174         }
5175 }
5176 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
5177         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5178         JNIEnv *env;
5179         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5180         LDKu8slice block_var = block;
5181         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
5182         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
5183         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5184         CHECK(obj != NULL);
5185         return (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
5186 }
5187 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
5188         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5189         JNIEnv *env;
5190         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5191         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
5192         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
5193         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5194         CHECK(obj != NULL);
5195         return (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
5196 }
5197 static void* LDKListen_JCalls_clone(const void* this_arg) {
5198         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5199         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5200         return (void*) this_arg;
5201 }
5202 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
5203         jclass c = (*env)->GetObjectClass(env, o);
5204         CHECK(c != NULL);
5205         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
5206         atomic_init(&calls->refcnt, 1);
5207         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5208         calls->o = (*env)->NewWeakGlobalRef(env, o);
5209         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
5210         CHECK(calls->block_connected_meth != NULL);
5211         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
5212         CHECK(calls->block_disconnected_meth != NULL);
5213
5214         LDKListen ret = {
5215                 .this_arg = (void*) calls,
5216                 .block_connected = block_connected_LDKListen_jcall,
5217                 .block_disconnected = block_disconnected_LDKListen_jcall,
5218                 .free = LDKListen_JCalls_free,
5219         };
5220         return ret;
5221 }
5222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
5223         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
5224         *res_ptr = LDKListen_init(env, clz, o);
5225         return (long)res_ptr;
5226 }
5227 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) {
5228         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
5229         LDKu8slice block_ref;
5230         block_ref.datalen = (*env)->GetArrayLength(env, block);
5231         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
5232         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
5233         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
5234 }
5235
5236 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) {
5237         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
5238         unsigned char header_arr[80];
5239         CHECK((*env)->GetArrayLength(env, header) == 80);
5240         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
5241         unsigned char (*header_ref)[80] = &header_arr;
5242         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
5243 }
5244
5245 typedef struct LDKFilter_JCalls {
5246         atomic_size_t refcnt;
5247         JavaVM *vm;
5248         jweak o;
5249         jmethodID register_tx_meth;
5250         jmethodID register_output_meth;
5251 } LDKFilter_JCalls;
5252 static void LDKFilter_JCalls_free(void* this_arg) {
5253         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5254         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5255                 JNIEnv *env;
5256                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5257                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5258                 FREE(j_calls);
5259         }
5260 }
5261 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5262         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5263         JNIEnv *env;
5264         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5265         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
5266         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
5267         LDKu8slice script_pubkey_var = script_pubkey;
5268         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
5269         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
5270         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5271         CHECK(obj != NULL);
5272         return (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
5273 }
5274 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5275         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5276         JNIEnv *env;
5277         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5278         LDKWatchedOutput output_var = output;
5279         CHECK((((long)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5280         CHECK((((long)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5281         long output_ref = (long)output_var.inner;
5282         if (output_var.is_owned) {
5283                 output_ref |= 1;
5284         }
5285         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5286         CHECK(obj != NULL);
5287         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)(*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
5288         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
5289         // Warning: we may need a move here but no clone is available for LDKCOption_C2Tuple_usizeTransactionZZ
5290         return ret_conv;
5291 }
5292 static void* LDKFilter_JCalls_clone(const void* this_arg) {
5293         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5294         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5295         return (void*) this_arg;
5296 }
5297 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
5298         jclass c = (*env)->GetObjectClass(env, o);
5299         CHECK(c != NULL);
5300         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5301         atomic_init(&calls->refcnt, 1);
5302         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5303         calls->o = (*env)->NewWeakGlobalRef(env, o);
5304         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
5305         CHECK(calls->register_tx_meth != NULL);
5306         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
5307         CHECK(calls->register_output_meth != NULL);
5308
5309         LDKFilter ret = {
5310                 .this_arg = (void*) calls,
5311                 .register_tx = register_tx_LDKFilter_jcall,
5312                 .register_output = register_output_LDKFilter_jcall,
5313                 .free = LDKFilter_JCalls_free,
5314         };
5315         return ret;
5316 }
5317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
5318         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5319         *res_ptr = LDKFilter_init(env, clz, o);
5320         return (long)res_ptr;
5321 }
5322 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) {
5323         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5324         unsigned char txid_arr[32];
5325         CHECK((*env)->GetArrayLength(env, txid) == 32);
5326         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
5327         unsigned char (*txid_ref)[32] = &txid_arr;
5328         LDKu8slice script_pubkey_ref;
5329         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
5330         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
5331         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5332         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
5333 }
5334
5335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
5336         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5337         LDKWatchedOutput output_conv;
5338         output_conv.inner = (void*)(output & (~1));
5339         output_conv.is_owned = (output & 1) || (output == 0);
5340         // Warning: we need a move here but no clone is available for LDKWatchedOutput
5341         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5342         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5343         long ret_ref = (long)ret_copy;
5344         return ret_ref;
5345 }
5346
5347 typedef struct LDKPersist_JCalls {
5348         atomic_size_t refcnt;
5349         JavaVM *vm;
5350         jweak o;
5351         jmethodID persist_new_channel_meth;
5352         jmethodID update_persisted_channel_meth;
5353 } LDKPersist_JCalls;
5354 static void LDKPersist_JCalls_free(void* this_arg) {
5355         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5356         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5357                 JNIEnv *env;
5358                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5359                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5360                 FREE(j_calls);
5361         }
5362 }
5363 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
5364         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5365         JNIEnv *env;
5366         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5367         LDKOutPoint id_var = id;
5368         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5369         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5370         long id_ref = (long)id_var.inner;
5371         if (id_var.is_owned) {
5372                 id_ref |= 1;
5373         }
5374         LDKChannelMonitor data_var = *data;
5375         data_var = ChannelMonitor_clone(data);
5376         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5377         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5378         long data_ref = (long)data_var.inner;
5379         if (data_var.is_owned) {
5380                 data_ref |= 1;
5381         }
5382         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5383         CHECK(obj != NULL);
5384         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
5385         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5386         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5387         return ret_conv;
5388 }
5389 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
5390         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5391         JNIEnv *env;
5392         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5393         LDKOutPoint id_var = id;
5394         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5395         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5396         long id_ref = (long)id_var.inner;
5397         if (id_var.is_owned) {
5398                 id_ref |= 1;
5399         }
5400         LDKChannelMonitorUpdate update_var = *update;
5401         update_var = ChannelMonitorUpdate_clone(update);
5402         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5403         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5404         long update_ref = (long)update_var.inner;
5405         if (update_var.is_owned) {
5406                 update_ref |= 1;
5407         }
5408         LDKChannelMonitor data_var = *data;
5409         data_var = ChannelMonitor_clone(data);
5410         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5411         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5412         long data_ref = (long)data_var.inner;
5413         if (data_var.is_owned) {
5414                 data_ref |= 1;
5415         }
5416         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5417         CHECK(obj != NULL);
5418         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
5419         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5420         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5421         return ret_conv;
5422 }
5423 static void* LDKPersist_JCalls_clone(const void* this_arg) {
5424         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5425         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5426         return (void*) this_arg;
5427 }
5428 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
5429         jclass c = (*env)->GetObjectClass(env, o);
5430         CHECK(c != NULL);
5431         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
5432         atomic_init(&calls->refcnt, 1);
5433         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5434         calls->o = (*env)->NewWeakGlobalRef(env, o);
5435         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
5436         CHECK(calls->persist_new_channel_meth != NULL);
5437         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
5438         CHECK(calls->update_persisted_channel_meth != NULL);
5439
5440         LDKPersist ret = {
5441                 .this_arg = (void*) calls,
5442                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
5443                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
5444                 .free = LDKPersist_JCalls_free,
5445         };
5446         return ret;
5447 }
5448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
5449         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
5450         *res_ptr = LDKPersist_init(env, clz, o);
5451         return (long)res_ptr;
5452 }
5453 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) {
5454         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5455         LDKOutPoint id_conv;
5456         id_conv.inner = (void*)(id & (~1));
5457         id_conv.is_owned = (id & 1) || (id == 0);
5458         id_conv = OutPoint_clone(&id_conv);
5459         LDKChannelMonitor data_conv;
5460         data_conv.inner = (void*)(data & (~1));
5461         data_conv.is_owned = false;
5462         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5463         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
5464         return (long)ret_conv;
5465 }
5466
5467 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) {
5468         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5469         LDKOutPoint id_conv;
5470         id_conv.inner = (void*)(id & (~1));
5471         id_conv.is_owned = (id & 1) || (id == 0);
5472         id_conv = OutPoint_clone(&id_conv);
5473         LDKChannelMonitorUpdate update_conv;
5474         update_conv.inner = (void*)(update & (~1));
5475         update_conv.is_owned = false;
5476         LDKChannelMonitor data_conv;
5477         data_conv.inner = (void*)(data & (~1));
5478         data_conv.is_owned = false;
5479         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5480         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
5481         return (long)ret_conv;
5482 }
5483
5484 typedef struct LDKChannelMessageHandler_JCalls {
5485         atomic_size_t refcnt;
5486         JavaVM *vm;
5487         jweak o;
5488         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5489         jmethodID handle_open_channel_meth;
5490         jmethodID handle_accept_channel_meth;
5491         jmethodID handle_funding_created_meth;
5492         jmethodID handle_funding_signed_meth;
5493         jmethodID handle_funding_locked_meth;
5494         jmethodID handle_shutdown_meth;
5495         jmethodID handle_closing_signed_meth;
5496         jmethodID handle_update_add_htlc_meth;
5497         jmethodID handle_update_fulfill_htlc_meth;
5498         jmethodID handle_update_fail_htlc_meth;
5499         jmethodID handle_update_fail_malformed_htlc_meth;
5500         jmethodID handle_commitment_signed_meth;
5501         jmethodID handle_revoke_and_ack_meth;
5502         jmethodID handle_update_fee_meth;
5503         jmethodID handle_announcement_signatures_meth;
5504         jmethodID peer_disconnected_meth;
5505         jmethodID peer_connected_meth;
5506         jmethodID handle_channel_reestablish_meth;
5507         jmethodID handle_channel_update_meth;
5508         jmethodID handle_error_meth;
5509 } LDKChannelMessageHandler_JCalls;
5510 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
5511         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5512         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5513                 JNIEnv *env;
5514                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5515                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5516                 FREE(j_calls);
5517         }
5518 }
5519 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
5520         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5521         JNIEnv *env;
5522         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5523         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5524         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5525         LDKInitFeatures their_features_var = their_features;
5526         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5527         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5528         long their_features_ref = (long)their_features_var.inner;
5529         if (their_features_var.is_owned) {
5530                 their_features_ref |= 1;
5531         }
5532         LDKOpenChannel msg_var = *msg;
5533         msg_var = OpenChannel_clone(msg);
5534         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5535         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5536         long msg_ref = (long)msg_var.inner;
5537         if (msg_var.is_owned) {
5538                 msg_ref |= 1;
5539         }
5540         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5541         CHECK(obj != NULL);
5542         return (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5543 }
5544 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
5545         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5546         JNIEnv *env;
5547         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5548         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5549         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5550         LDKInitFeatures their_features_var = their_features;
5551         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5552         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5553         long their_features_ref = (long)their_features_var.inner;
5554         if (their_features_var.is_owned) {
5555                 their_features_ref |= 1;
5556         }
5557         LDKAcceptChannel msg_var = *msg;
5558         msg_var = AcceptChannel_clone(msg);
5559         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5560         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5561         long msg_ref = (long)msg_var.inner;
5562         if (msg_var.is_owned) {
5563                 msg_ref |= 1;
5564         }
5565         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5566         CHECK(obj != NULL);
5567         return (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5568 }
5569 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
5570         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5571         JNIEnv *env;
5572         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5573         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5574         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5575         LDKFundingCreated msg_var = *msg;
5576         msg_var = FundingCreated_clone(msg);
5577         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5578         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5579         long msg_ref = (long)msg_var.inner;
5580         if (msg_var.is_owned) {
5581                 msg_ref |= 1;
5582         }
5583         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5584         CHECK(obj != NULL);
5585         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
5586 }
5587 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
5588         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5589         JNIEnv *env;
5590         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5591         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5592         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5593         LDKFundingSigned msg_var = *msg;
5594         msg_var = FundingSigned_clone(msg);
5595         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5596         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5597         long msg_ref = (long)msg_var.inner;
5598         if (msg_var.is_owned) {
5599                 msg_ref |= 1;
5600         }
5601         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5602         CHECK(obj != NULL);
5603         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
5604 }
5605 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
5606         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5607         JNIEnv *env;
5608         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5609         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5610         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5611         LDKFundingLocked msg_var = *msg;
5612         msg_var = FundingLocked_clone(msg);
5613         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5614         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5615         long msg_ref = (long)msg_var.inner;
5616         if (msg_var.is_owned) {
5617                 msg_ref |= 1;
5618         }
5619         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5620         CHECK(obj != NULL);
5621         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
5622 }
5623 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
5624         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5625         JNIEnv *env;
5626         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5627         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5628         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5629         LDKInitFeatures their_features_var = *their_features;
5630         their_features_var = InitFeatures_clone(their_features);
5631         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5632         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5633         long their_features_ref = (long)their_features_var.inner;
5634         if (their_features_var.is_owned) {
5635                 their_features_ref |= 1;
5636         }
5637         LDKShutdown msg_var = *msg;
5638         msg_var = Shutdown_clone(msg);
5639         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5640         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5641         long msg_ref = (long)msg_var.inner;
5642         if (msg_var.is_owned) {
5643                 msg_ref |= 1;
5644         }
5645         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5646         CHECK(obj != NULL);
5647         return (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
5648 }
5649 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
5650         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5651         JNIEnv *env;
5652         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5653         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5654         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5655         LDKClosingSigned msg_var = *msg;
5656         msg_var = ClosingSigned_clone(msg);
5657         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5658         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5659         long msg_ref = (long)msg_var.inner;
5660         if (msg_var.is_owned) {
5661                 msg_ref |= 1;
5662         }
5663         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5664         CHECK(obj != NULL);
5665         return (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
5666 }
5667 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
5668         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5669         JNIEnv *env;
5670         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5671         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5672         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5673         LDKUpdateAddHTLC msg_var = *msg;
5674         msg_var = UpdateAddHTLC_clone(msg);
5675         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5676         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5677         long msg_ref = (long)msg_var.inner;
5678         if (msg_var.is_owned) {
5679                 msg_ref |= 1;
5680         }
5681         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5682         CHECK(obj != NULL);
5683         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
5684 }
5685 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
5686         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5687         JNIEnv *env;
5688         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5689         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5690         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5691         LDKUpdateFulfillHTLC msg_var = *msg;
5692         msg_var = UpdateFulfillHTLC_clone(msg);
5693         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5694         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5695         long msg_ref = (long)msg_var.inner;
5696         if (msg_var.is_owned) {
5697                 msg_ref |= 1;
5698         }
5699         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5700         CHECK(obj != NULL);
5701         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
5702 }
5703 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
5704         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5705         JNIEnv *env;
5706         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5707         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5708         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5709         LDKUpdateFailHTLC msg_var = *msg;
5710         msg_var = UpdateFailHTLC_clone(msg);
5711         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5712         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5713         long msg_ref = (long)msg_var.inner;
5714         if (msg_var.is_owned) {
5715                 msg_ref |= 1;
5716         }
5717         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5718         CHECK(obj != NULL);
5719         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
5720 }
5721 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
5722         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5723         JNIEnv *env;
5724         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5725         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5726         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5727         LDKUpdateFailMalformedHTLC msg_var = *msg;
5728         msg_var = UpdateFailMalformedHTLC_clone(msg);
5729         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5730         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5731         long msg_ref = (long)msg_var.inner;
5732         if (msg_var.is_owned) {
5733                 msg_ref |= 1;
5734         }
5735         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5736         CHECK(obj != NULL);
5737         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
5738 }
5739 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
5740         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5741         JNIEnv *env;
5742         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5743         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5744         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5745         LDKCommitmentSigned msg_var = *msg;
5746         msg_var = CommitmentSigned_clone(msg);
5747         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5748         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5749         long msg_ref = (long)msg_var.inner;
5750         if (msg_var.is_owned) {
5751                 msg_ref |= 1;
5752         }
5753         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5754         CHECK(obj != NULL);
5755         return (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
5756 }
5757 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
5758         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5759         JNIEnv *env;
5760         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5761         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5762         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5763         LDKRevokeAndACK msg_var = *msg;
5764         msg_var = RevokeAndACK_clone(msg);
5765         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5766         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5767         long msg_ref = (long)msg_var.inner;
5768         if (msg_var.is_owned) {
5769                 msg_ref |= 1;
5770         }
5771         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5772         CHECK(obj != NULL);
5773         return (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
5774 }
5775 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
5776         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5777         JNIEnv *env;
5778         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5779         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5780         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5781         LDKUpdateFee msg_var = *msg;
5782         msg_var = UpdateFee_clone(msg);
5783         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5784         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5785         long msg_ref = (long)msg_var.inner;
5786         if (msg_var.is_owned) {
5787                 msg_ref |= 1;
5788         }
5789         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5790         CHECK(obj != NULL);
5791         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
5792 }
5793 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
5794         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5795         JNIEnv *env;
5796         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5797         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5798         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5799         LDKAnnouncementSignatures msg_var = *msg;
5800         msg_var = AnnouncementSignatures_clone(msg);
5801         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5802         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5803         long msg_ref = (long)msg_var.inner;
5804         if (msg_var.is_owned) {
5805                 msg_ref |= 1;
5806         }
5807         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5808         CHECK(obj != NULL);
5809         return (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
5810 }
5811 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
5812         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5813         JNIEnv *env;
5814         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5815         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5816         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5817         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5818         CHECK(obj != NULL);
5819         return (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
5820 }
5821 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
5822         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5823         JNIEnv *env;
5824         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5825         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5826         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5827         LDKInit msg_var = *msg;
5828         msg_var = Init_clone(msg);
5829         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5830         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5831         long msg_ref = (long)msg_var.inner;
5832         if (msg_var.is_owned) {
5833                 msg_ref |= 1;
5834         }
5835         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5836         CHECK(obj != NULL);
5837         return (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
5838 }
5839 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
5840         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5841         JNIEnv *env;
5842         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5843         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5844         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5845         LDKChannelReestablish msg_var = *msg;
5846         msg_var = ChannelReestablish_clone(msg);
5847         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5848         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5849         long msg_ref = (long)msg_var.inner;
5850         if (msg_var.is_owned) {
5851                 msg_ref |= 1;
5852         }
5853         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5854         CHECK(obj != NULL);
5855         return (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
5856 }
5857 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
5858         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5859         JNIEnv *env;
5860         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5861         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5862         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5863         LDKChannelUpdate msg_var = *msg;
5864         msg_var = ChannelUpdate_clone(msg);
5865         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5866         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5867         long msg_ref = (long)msg_var.inner;
5868         if (msg_var.is_owned) {
5869                 msg_ref |= 1;
5870         }
5871         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5872         CHECK(obj != NULL);
5873         return (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
5874 }
5875 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
5876         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5877         JNIEnv *env;
5878         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5879         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5880         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5881         LDKErrorMessage msg_var = *msg;
5882         msg_var = ErrorMessage_clone(msg);
5883         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5884         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5885         long msg_ref = (long)msg_var.inner;
5886         if (msg_var.is_owned) {
5887                 msg_ref |= 1;
5888         }
5889         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5890         CHECK(obj != NULL);
5891         return (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
5892 }
5893 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
5894         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5895         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5896         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5897         return (void*) this_arg;
5898 }
5899 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
5900         jclass c = (*env)->GetObjectClass(env, o);
5901         CHECK(c != NULL);
5902         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
5903         atomic_init(&calls->refcnt, 1);
5904         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5905         calls->o = (*env)->NewWeakGlobalRef(env, o);
5906         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
5907         CHECK(calls->handle_open_channel_meth != NULL);
5908         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
5909         CHECK(calls->handle_accept_channel_meth != NULL);
5910         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
5911         CHECK(calls->handle_funding_created_meth != NULL);
5912         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
5913         CHECK(calls->handle_funding_signed_meth != NULL);
5914         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
5915         CHECK(calls->handle_funding_locked_meth != NULL);
5916         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
5917         CHECK(calls->handle_shutdown_meth != NULL);
5918         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
5919         CHECK(calls->handle_closing_signed_meth != NULL);
5920         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
5921         CHECK(calls->handle_update_add_htlc_meth != NULL);
5922         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
5923         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
5924         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
5925         CHECK(calls->handle_update_fail_htlc_meth != NULL);
5926         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
5927         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
5928         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
5929         CHECK(calls->handle_commitment_signed_meth != NULL);
5930         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
5931         CHECK(calls->handle_revoke_and_ack_meth != NULL);
5932         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
5933         CHECK(calls->handle_update_fee_meth != NULL);
5934         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
5935         CHECK(calls->handle_announcement_signatures_meth != NULL);
5936         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
5937         CHECK(calls->peer_disconnected_meth != NULL);
5938         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
5939         CHECK(calls->peer_connected_meth != NULL);
5940         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
5941         CHECK(calls->handle_channel_reestablish_meth != NULL);
5942         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
5943         CHECK(calls->handle_channel_update_meth != NULL);
5944         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
5945         CHECK(calls->handle_error_meth != NULL);
5946
5947         LDKChannelMessageHandler ret = {
5948                 .this_arg = (void*) calls,
5949                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
5950                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
5951                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
5952                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
5953                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
5954                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
5955                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
5956                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
5957                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
5958                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
5959                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
5960                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
5961                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
5962                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
5963                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
5964                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
5965                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
5966                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
5967                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
5968                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
5969                 .free = LDKChannelMessageHandler_JCalls_free,
5970                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
5971         };
5972         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5973         return ret;
5974 }
5975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
5976         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
5977         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
5978         return (long)res_ptr;
5979 }
5980 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) {
5981         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5982         LDKPublicKey their_node_id_ref;
5983         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5984         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5985         LDKInitFeatures their_features_conv;
5986         their_features_conv.inner = (void*)(their_features & (~1));
5987         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5988         their_features_conv = InitFeatures_clone(&their_features_conv);
5989         LDKOpenChannel msg_conv;
5990         msg_conv.inner = (void*)(msg & (~1));
5991         msg_conv.is_owned = false;
5992         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5993 }
5994
5995 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) {
5996         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5997         LDKPublicKey their_node_id_ref;
5998         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5999         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6000         LDKInitFeatures their_features_conv;
6001         their_features_conv.inner = (void*)(their_features & (~1));
6002         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
6003         their_features_conv = InitFeatures_clone(&their_features_conv);
6004         LDKAcceptChannel msg_conv;
6005         msg_conv.inner = (void*)(msg & (~1));
6006         msg_conv.is_owned = false;
6007         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
6008 }
6009
6010 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) {
6011         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6012         LDKPublicKey their_node_id_ref;
6013         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6014         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6015         LDKFundingCreated msg_conv;
6016         msg_conv.inner = (void*)(msg & (~1));
6017         msg_conv.is_owned = false;
6018         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6019 }
6020
6021 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) {
6022         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6023         LDKPublicKey their_node_id_ref;
6024         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6025         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6026         LDKFundingSigned msg_conv;
6027         msg_conv.inner = (void*)(msg & (~1));
6028         msg_conv.is_owned = false;
6029         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6030 }
6031
6032 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) {
6033         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6034         LDKPublicKey their_node_id_ref;
6035         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6036         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6037         LDKFundingLocked msg_conv;
6038         msg_conv.inner = (void*)(msg & (~1));
6039         msg_conv.is_owned = false;
6040         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6041 }
6042
6043 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) {
6044         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6045         LDKPublicKey their_node_id_ref;
6046         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6047         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6048         LDKInitFeatures their_features_conv;
6049         their_features_conv.inner = (void*)(their_features & (~1));
6050         their_features_conv.is_owned = false;
6051         LDKShutdown msg_conv;
6052         msg_conv.inner = (void*)(msg & (~1));
6053         msg_conv.is_owned = false;
6054         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
6055 }
6056
6057 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) {
6058         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6059         LDKPublicKey their_node_id_ref;
6060         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6061         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6062         LDKClosingSigned msg_conv;
6063         msg_conv.inner = (void*)(msg & (~1));
6064         msg_conv.is_owned = false;
6065         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6066 }
6067
6068 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) {
6069         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6070         LDKPublicKey their_node_id_ref;
6071         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6072         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6073         LDKUpdateAddHTLC msg_conv;
6074         msg_conv.inner = (void*)(msg & (~1));
6075         msg_conv.is_owned = false;
6076         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6077 }
6078
6079 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) {
6080         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6081         LDKPublicKey their_node_id_ref;
6082         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6083         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6084         LDKUpdateFulfillHTLC msg_conv;
6085         msg_conv.inner = (void*)(msg & (~1));
6086         msg_conv.is_owned = false;
6087         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6088 }
6089
6090 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) {
6091         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6092         LDKPublicKey their_node_id_ref;
6093         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6094         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6095         LDKUpdateFailHTLC msg_conv;
6096         msg_conv.inner = (void*)(msg & (~1));
6097         msg_conv.is_owned = false;
6098         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6099 }
6100
6101 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) {
6102         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6103         LDKPublicKey their_node_id_ref;
6104         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6105         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6106         LDKUpdateFailMalformedHTLC msg_conv;
6107         msg_conv.inner = (void*)(msg & (~1));
6108         msg_conv.is_owned = false;
6109         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6110 }
6111
6112 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) {
6113         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6114         LDKPublicKey their_node_id_ref;
6115         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6116         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6117         LDKCommitmentSigned msg_conv;
6118         msg_conv.inner = (void*)(msg & (~1));
6119         msg_conv.is_owned = false;
6120         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6121 }
6122
6123 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) {
6124         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6125         LDKPublicKey their_node_id_ref;
6126         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6127         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6128         LDKRevokeAndACK msg_conv;
6129         msg_conv.inner = (void*)(msg & (~1));
6130         msg_conv.is_owned = false;
6131         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6132 }
6133
6134 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) {
6135         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6136         LDKPublicKey their_node_id_ref;
6137         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6138         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6139         LDKUpdateFee msg_conv;
6140         msg_conv.inner = (void*)(msg & (~1));
6141         msg_conv.is_owned = false;
6142         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6143 }
6144
6145 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) {
6146         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6147         LDKPublicKey their_node_id_ref;
6148         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6149         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6150         LDKAnnouncementSignatures msg_conv;
6151         msg_conv.inner = (void*)(msg & (~1));
6152         msg_conv.is_owned = false;
6153         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6154 }
6155
6156 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) {
6157         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6158         LDKPublicKey their_node_id_ref;
6159         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6160         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6161         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
6162 }
6163
6164 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) {
6165         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6166         LDKPublicKey their_node_id_ref;
6167         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6168         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6169         LDKInit msg_conv;
6170         msg_conv.inner = (void*)(msg & (~1));
6171         msg_conv.is_owned = false;
6172         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6173 }
6174
6175 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) {
6176         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6177         LDKPublicKey their_node_id_ref;
6178         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6179         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6180         LDKChannelReestablish msg_conv;
6181         msg_conv.inner = (void*)(msg & (~1));
6182         msg_conv.is_owned = false;
6183         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6184 }
6185
6186 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) {
6187         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6188         LDKPublicKey their_node_id_ref;
6189         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6190         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6191         LDKChannelUpdate msg_conv;
6192         msg_conv.inner = (void*)(msg & (~1));
6193         msg_conv.is_owned = false;
6194         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6195 }
6196
6197 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) {
6198         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6199         LDKPublicKey their_node_id_ref;
6200         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6201         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6202         LDKErrorMessage msg_conv;
6203         msg_conv.inner = (void*)(msg & (~1));
6204         msg_conv.is_owned = false;
6205         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6206 }
6207
6208 typedef struct LDKRoutingMessageHandler_JCalls {
6209         atomic_size_t refcnt;
6210         JavaVM *vm;
6211         jweak o;
6212         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
6213         jmethodID handle_node_announcement_meth;
6214         jmethodID handle_channel_announcement_meth;
6215         jmethodID handle_channel_update_meth;
6216         jmethodID handle_htlc_fail_channel_update_meth;
6217         jmethodID get_next_channel_announcements_meth;
6218         jmethodID get_next_node_announcements_meth;
6219         jmethodID sync_routing_table_meth;
6220         jmethodID handle_reply_channel_range_meth;
6221         jmethodID handle_reply_short_channel_ids_end_meth;
6222         jmethodID handle_query_channel_range_meth;
6223         jmethodID handle_query_short_channel_ids_meth;
6224 } LDKRoutingMessageHandler_JCalls;
6225 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
6226         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6227         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6228                 JNIEnv *env;
6229                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6230                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6231                 FREE(j_calls);
6232         }
6233 }
6234 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
6235         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6236         JNIEnv *env;
6237         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6238         LDKNodeAnnouncement msg_var = *msg;
6239         msg_var = NodeAnnouncement_clone(msg);
6240         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6241         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6242         long msg_ref = (long)msg_var.inner;
6243         if (msg_var.is_owned) {
6244                 msg_ref |= 1;
6245         }
6246         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6247         CHECK(obj != NULL);
6248         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
6249         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6250         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6251         return ret_conv;
6252 }
6253 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
6254         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6255         JNIEnv *env;
6256         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6257         LDKChannelAnnouncement msg_var = *msg;
6258         msg_var = ChannelAnnouncement_clone(msg);
6259         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6260         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6261         long msg_ref = (long)msg_var.inner;
6262         if (msg_var.is_owned) {
6263                 msg_ref |= 1;
6264         }
6265         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6266         CHECK(obj != NULL);
6267         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
6268         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6269         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6270         return ret_conv;
6271 }
6272 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
6273         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6274         JNIEnv *env;
6275         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6276         LDKChannelUpdate msg_var = *msg;
6277         msg_var = ChannelUpdate_clone(msg);
6278         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6279         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6280         long msg_ref = (long)msg_var.inner;
6281         if (msg_var.is_owned) {
6282                 msg_ref |= 1;
6283         }
6284         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6285         CHECK(obj != NULL);
6286         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
6287         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6288         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6289         return ret_conv;
6290 }
6291 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
6292         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6293         JNIEnv *env;
6294         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6295         long ret_update = (long)update;
6296         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6297         CHECK(obj != NULL);
6298         return (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
6299 }
6300 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
6301         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6302         JNIEnv *env;
6303         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6304         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6305         CHECK(obj != NULL);
6306         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
6307         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
6308         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6309         if (ret_constr.datalen > 0)
6310                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
6311         else
6312                 ret_constr.data = NULL;
6313         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6314         for (size_t l = 0; l < ret_constr.datalen; l++) {
6315                 int64_t ret_conv_63 = ret_vals[l];
6316                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
6317                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
6318                 ret_constr.data[l] = ret_conv_63_conv;
6319         }
6320         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6321         return ret_constr;
6322 }
6323 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
6324         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6325         JNIEnv *env;
6326         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6327         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
6328         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
6329         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6330         CHECK(obj != NULL);
6331         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
6332         LDKCVec_NodeAnnouncementZ ret_constr;
6333         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6334         if (ret_constr.datalen > 0)
6335                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
6336         else
6337                 ret_constr.data = NULL;
6338         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6339         for (size_t s = 0; s < ret_constr.datalen; s++) {
6340                 int64_t ret_conv_18 = ret_vals[s];
6341                 LDKNodeAnnouncement ret_conv_18_conv;
6342                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
6343                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
6344                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
6345                 ret_constr.data[s] = ret_conv_18_conv;
6346         }
6347         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6348         return ret_constr;
6349 }
6350 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
6351         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6352         JNIEnv *env;
6353         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6354         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6355         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6356         LDKInit init_var = *init;
6357         init_var = Init_clone(init);
6358         CHECK((((long)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6359         CHECK((((long)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6360         long init_ref = (long)init_var.inner;
6361         if (init_var.is_owned) {
6362                 init_ref |= 1;
6363         }
6364         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6365         CHECK(obj != NULL);
6366         return (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
6367 }
6368 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
6369         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6370         JNIEnv *env;
6371         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6372         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6373         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6374         LDKReplyChannelRange msg_var = msg;
6375         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6376         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6377         long msg_ref = (long)msg_var.inner;
6378         if (msg_var.is_owned) {
6379                 msg_ref |= 1;
6380         }
6381         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6382         CHECK(obj != NULL);
6383         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
6384         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6385         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6386         return ret_conv;
6387 }
6388 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
6389         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6390         JNIEnv *env;
6391         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6392         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6393         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6394         LDKReplyShortChannelIdsEnd msg_var = msg;
6395         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6396         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6397         long msg_ref = (long)msg_var.inner;
6398         if (msg_var.is_owned) {
6399                 msg_ref |= 1;
6400         }
6401         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6402         CHECK(obj != NULL);
6403         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
6404         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6405         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6406         return ret_conv;
6407 }
6408 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
6409         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6410         JNIEnv *env;
6411         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6412         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6413         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6414         LDKQueryChannelRange msg_var = msg;
6415         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6416         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6417         long msg_ref = (long)msg_var.inner;
6418         if (msg_var.is_owned) {
6419                 msg_ref |= 1;
6420         }
6421         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6422         CHECK(obj != NULL);
6423         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
6424         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6425         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6426         return ret_conv;
6427 }
6428 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
6429         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6430         JNIEnv *env;
6431         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6432         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6433         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6434         LDKQueryShortChannelIds msg_var = msg;
6435         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6436         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6437         long msg_ref = (long)msg_var.inner;
6438         if (msg_var.is_owned) {
6439                 msg_ref |= 1;
6440         }
6441         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6442         CHECK(obj != NULL);
6443         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
6444         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6445         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6446         return ret_conv;
6447 }
6448 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
6449         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6450         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6451         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6452         return (void*) this_arg;
6453 }
6454 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
6455         jclass c = (*env)->GetObjectClass(env, o);
6456         CHECK(c != NULL);
6457         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
6458         atomic_init(&calls->refcnt, 1);
6459         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6460         calls->o = (*env)->NewWeakGlobalRef(env, o);
6461         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
6462         CHECK(calls->handle_node_announcement_meth != NULL);
6463         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
6464         CHECK(calls->handle_channel_announcement_meth != NULL);
6465         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
6466         CHECK(calls->handle_channel_update_meth != NULL);
6467         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
6468         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
6469         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
6470         CHECK(calls->get_next_channel_announcements_meth != NULL);
6471         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
6472         CHECK(calls->get_next_node_announcements_meth != NULL);
6473         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
6474         CHECK(calls->sync_routing_table_meth != NULL);
6475         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
6476         CHECK(calls->handle_reply_channel_range_meth != NULL);
6477         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
6478         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
6479         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
6480         CHECK(calls->handle_query_channel_range_meth != NULL);
6481         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
6482         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
6483
6484         LDKRoutingMessageHandler ret = {
6485                 .this_arg = (void*) calls,
6486                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
6487                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
6488                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
6489                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
6490                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
6491                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
6492                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
6493                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
6494                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
6495                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
6496                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
6497                 .free = LDKRoutingMessageHandler_JCalls_free,
6498                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
6499         };
6500         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6501         return ret;
6502 }
6503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
6504         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
6505         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
6506         return (long)res_ptr;
6507 }
6508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6509         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6510         LDKNodeAnnouncement msg_conv;
6511         msg_conv.inner = (void*)(msg & (~1));
6512         msg_conv.is_owned = false;
6513         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6514         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
6515         return (long)ret_conv;
6516 }
6517
6518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6519         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6520         LDKChannelAnnouncement msg_conv;
6521         msg_conv.inner = (void*)(msg & (~1));
6522         msg_conv.is_owned = false;
6523         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6524         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6525         return (long)ret_conv;
6526 }
6527
6528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6529         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6530         LDKChannelUpdate msg_conv;
6531         msg_conv.inner = (void*)(msg & (~1));
6532         msg_conv.is_owned = false;
6533         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6534         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
6535         return (long)ret_conv;
6536 }
6537
6538 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) {
6539         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6540         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
6541         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
6542 }
6543
6544 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) {
6545         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6546         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
6547         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6548         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6549         for (size_t l = 0; l < ret_var.datalen; l++) {
6550                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6551                 *ret_conv_63_ref = ret_var.data[l];
6552                 ret_arr_ptr[l] = (long)ret_conv_63_ref;
6553         }
6554         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6555         FREE(ret_var.data);
6556         return ret_arr;
6557 }
6558
6559 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) {
6560         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6561         LDKPublicKey starting_point_ref;
6562         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
6563         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
6564         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
6565         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6566         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6567         for (size_t s = 0; s < ret_var.datalen; s++) {
6568                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
6569                 CHECK((((long)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6570                 CHECK((((long)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6571                 long ret_conv_18_ref = (long)ret_conv_18_var.inner;
6572                 if (ret_conv_18_var.is_owned) {
6573                         ret_conv_18_ref |= 1;
6574                 }
6575                 ret_arr_ptr[s] = ret_conv_18_ref;
6576         }
6577         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6578         FREE(ret_var.data);
6579         return ret_arr;
6580 }
6581
6582 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) {
6583         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6584         LDKPublicKey their_node_id_ref;
6585         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6586         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6587         LDKInit init_conv;
6588         init_conv.inner = (void*)(init & (~1));
6589         init_conv.is_owned = false;
6590         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
6591 }
6592
6593 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) {
6594         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6595         LDKPublicKey their_node_id_ref;
6596         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6597         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6598         LDKReplyChannelRange msg_conv;
6599         msg_conv.inner = (void*)(msg & (~1));
6600         msg_conv.is_owned = (msg & 1) || (msg == 0);
6601         msg_conv = ReplyChannelRange_clone(&msg_conv);
6602         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6603         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6604         return (long)ret_conv;
6605 }
6606
6607 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) {
6608         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6609         LDKPublicKey their_node_id_ref;
6610         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6611         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6612         LDKReplyShortChannelIdsEnd msg_conv;
6613         msg_conv.inner = (void*)(msg & (~1));
6614         msg_conv.is_owned = (msg & 1) || (msg == 0);
6615         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
6616         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6617         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6618         return (long)ret_conv;
6619 }
6620
6621 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) {
6622         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6623         LDKPublicKey their_node_id_ref;
6624         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6625         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6626         LDKQueryChannelRange msg_conv;
6627         msg_conv.inner = (void*)(msg & (~1));
6628         msg_conv.is_owned = (msg & 1) || (msg == 0);
6629         msg_conv = QueryChannelRange_clone(&msg_conv);
6630         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6631         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6632         return (long)ret_conv;
6633 }
6634
6635 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) {
6636         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6637         LDKPublicKey their_node_id_ref;
6638         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6639         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6640         LDKQueryShortChannelIds msg_conv;
6641         msg_conv.inner = (void*)(msg & (~1));
6642         msg_conv.is_owned = (msg & 1) || (msg == 0);
6643         msg_conv = QueryShortChannelIds_clone(&msg_conv);
6644         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6645         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6646         return (long)ret_conv;
6647 }
6648
6649 typedef struct LDKSocketDescriptor_JCalls {
6650         atomic_size_t refcnt;
6651         JavaVM *vm;
6652         jweak o;
6653         jmethodID send_data_meth;
6654         jmethodID disconnect_socket_meth;
6655         jmethodID eq_meth;
6656         jmethodID hash_meth;
6657 } LDKSocketDescriptor_JCalls;
6658 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
6659         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6660         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6661                 JNIEnv *env;
6662                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6663                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6664                 FREE(j_calls);
6665         }
6666 }
6667 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
6668         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6669         JNIEnv *env;
6670         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6671         LDKu8slice data_var = data;
6672         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
6673         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
6674         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6675         CHECK(obj != NULL);
6676         return (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
6677 }
6678 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
6679         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6680         JNIEnv *env;
6681         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6682         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6683         CHECK(obj != NULL);
6684         return (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
6685 }
6686 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
6687         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6688         JNIEnv *env;
6689         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6690         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6691         *other_arg_clone = SocketDescriptor_clone(other_arg);
6692         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6693         CHECK(obj != NULL);
6694         return (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (long)other_arg_clone);
6695 }
6696 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
6697         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6698         JNIEnv *env;
6699         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6700         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6701         CHECK(obj != NULL);
6702         return (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
6703 }
6704 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
6705         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6706         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6707         return (void*) this_arg;
6708 }
6709 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
6710         jclass c = (*env)->GetObjectClass(env, o);
6711         CHECK(c != NULL);
6712         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
6713         atomic_init(&calls->refcnt, 1);
6714         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6715         calls->o = (*env)->NewWeakGlobalRef(env, o);
6716         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
6717         CHECK(calls->send_data_meth != NULL);
6718         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
6719         CHECK(calls->disconnect_socket_meth != NULL);
6720         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
6721         CHECK(calls->eq_meth != NULL);
6722         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
6723         CHECK(calls->hash_meth != NULL);
6724
6725         LDKSocketDescriptor ret = {
6726                 .this_arg = (void*) calls,
6727                 .send_data = send_data_LDKSocketDescriptor_jcall,
6728                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
6729                 .eq = eq_LDKSocketDescriptor_jcall,
6730                 .hash = hash_LDKSocketDescriptor_jcall,
6731                 .clone = LDKSocketDescriptor_JCalls_clone,
6732                 .free = LDKSocketDescriptor_JCalls_free,
6733         };
6734         return ret;
6735 }
6736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
6737         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6738         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
6739         return (long)res_ptr;
6740 }
6741 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) {
6742         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6743         LDKu8slice data_ref;
6744         data_ref.datalen = (*env)->GetArrayLength(env, data);
6745         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
6746         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
6747         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
6748         return ret_val;
6749 }
6750
6751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
6752         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6753         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
6754 }
6755
6756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
6757         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6758         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
6759         return ret_val;
6760 }
6761
6762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
6763         LDKTransaction _res_ref;
6764         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
6765         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
6766         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
6767         _res_ref.data_is_owned = true;
6768         Transaction_free(_res_ref);
6769 }
6770
6771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
6772         if ((_res & 1) != 0) return;
6773         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
6774         FREE((void*)_res);
6775         TxOut_free(_res_conv);
6776 }
6777
6778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6779         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
6780         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6781         *ret_ref = TxOut_clone(orig_conv);
6782         return (long)ret_ref;
6783 }
6784
6785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6786         LDKChannelConfig o_conv;
6787         o_conv.inner = (void*)(o & (~1));
6788         o_conv.is_owned = (o & 1) || (o == 0);
6789         o_conv = ChannelConfig_clone(&o_conv);
6790         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6791         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
6792         return (long)ret_conv;
6793 }
6794
6795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6796         LDKDecodeError e_conv;
6797         e_conv.inner = (void*)(e & (~1));
6798         e_conv.is_owned = (e & 1) || (e == 0);
6799         e_conv = DecodeError_clone(&e_conv);
6800         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6801         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
6802         return (long)ret_conv;
6803 }
6804
6805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6806         if ((_res & 1) != 0) return;
6807         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
6808         FREE((void*)_res);
6809         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
6810 }
6811
6812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6813         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
6814         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6815         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
6816         return (long)ret_conv;
6817 }
6818
6819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6820         LDKOutPoint o_conv;
6821         o_conv.inner = (void*)(o & (~1));
6822         o_conv.is_owned = (o & 1) || (o == 0);
6823         o_conv = OutPoint_clone(&o_conv);
6824         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
6825         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
6826         return (long)ret_conv;
6827 }
6828
6829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6830         LDKDecodeError e_conv;
6831         e_conv.inner = (void*)(e & (~1));
6832         e_conv.is_owned = (e & 1) || (e == 0);
6833         e_conv = DecodeError_clone(&e_conv);
6834         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
6835         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
6836         return (long)ret_conv;
6837 }
6838
6839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6840         if ((_res & 1) != 0) return;
6841         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
6842         FREE((void*)_res);
6843         CResult_OutPointDecodeErrorZ_free(_res_conv);
6844 }
6845
6846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6847         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
6848         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
6849         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
6850         return (long)ret_conv;
6851 }
6852
6853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
6854         LDKSecretKey o_ref;
6855         CHECK((*env)->GetArrayLength(env, o) == 32);
6856         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
6857         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6858         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
6859         return (long)ret_conv;
6860 }
6861
6862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6863         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6864         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6865         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
6866         return (long)ret_conv;
6867 }
6868
6869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6870         if ((_res & 1) != 0) return;
6871         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
6872         FREE((void*)_res);
6873         CResult_SecretKeyErrorZ_free(_res_conv);
6874 }
6875
6876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
6877         LDKPublicKey o_ref;
6878         CHECK((*env)->GetArrayLength(env, o) == 33);
6879         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
6880         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6881         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
6882         return (long)ret_conv;
6883 }
6884
6885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6886         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6887         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6888         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
6889         return (long)ret_conv;
6890 }
6891
6892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6893         if ((_res & 1) != 0) return;
6894         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
6895         FREE((void*)_res);
6896         CResult_PublicKeyErrorZ_free(_res_conv);
6897 }
6898
6899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6900         LDKTxCreationKeys o_conv;
6901         o_conv.inner = (void*)(o & (~1));
6902         o_conv.is_owned = (o & 1) || (o == 0);
6903         o_conv = TxCreationKeys_clone(&o_conv);
6904         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6905         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
6906         return (long)ret_conv;
6907 }
6908
6909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6910         LDKDecodeError e_conv;
6911         e_conv.inner = (void*)(e & (~1));
6912         e_conv.is_owned = (e & 1) || (e == 0);
6913         e_conv = DecodeError_clone(&e_conv);
6914         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6915         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
6916         return (long)ret_conv;
6917 }
6918
6919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6920         if ((_res & 1) != 0) return;
6921         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6922         FREE((void*)_res);
6923         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
6924 }
6925
6926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6927         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
6928         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6929         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
6930         return (long)ret_conv;
6931 }
6932
6933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6934         LDKChannelPublicKeys o_conv;
6935         o_conv.inner = (void*)(o & (~1));
6936         o_conv.is_owned = (o & 1) || (o == 0);
6937         o_conv = ChannelPublicKeys_clone(&o_conv);
6938         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6939         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
6940         return (long)ret_conv;
6941 }
6942
6943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6944         LDKDecodeError e_conv;
6945         e_conv.inner = (void*)(e & (~1));
6946         e_conv.is_owned = (e & 1) || (e == 0);
6947         e_conv = DecodeError_clone(&e_conv);
6948         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6949         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
6950         return (long)ret_conv;
6951 }
6952
6953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6954         if ((_res & 1) != 0) return;
6955         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6956         FREE((void*)_res);
6957         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
6958 }
6959
6960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6961         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
6962         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6963         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
6964         return (long)ret_conv;
6965 }
6966
6967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6968         LDKTxCreationKeys o_conv;
6969         o_conv.inner = (void*)(o & (~1));
6970         o_conv.is_owned = (o & 1) || (o == 0);
6971         o_conv = TxCreationKeys_clone(&o_conv);
6972         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6973         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
6974         return (long)ret_conv;
6975 }
6976
6977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6978         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6979         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6980         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
6981         return (long)ret_conv;
6982 }
6983
6984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6985         if ((_res & 1) != 0) return;
6986         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
6987         FREE((void*)_res);
6988         CResult_TxCreationKeysErrorZ_free(_res_conv);
6989 }
6990
6991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
6992         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6993         *ret_copy = COption_u32Z_some(o);
6994         long ret_ref = (long)ret_copy;
6995         return ret_ref;
6996 }
6997
6998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
6999         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
7000         *ret_copy = COption_u32Z_none();
7001         long ret_ref = (long)ret_copy;
7002         return ret_ref;
7003 }
7004
7005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
7006         if ((_res & 1) != 0) return;
7007         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
7008         FREE((void*)_res);
7009         COption_u32Z_free(_res_conv);
7010 }
7011
7012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7013         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
7014         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
7015         *ret_copy = COption_u32Z_clone(orig_conv);
7016         long ret_ref = (long)ret_copy;
7017         return ret_ref;
7018 }
7019
7020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7021         LDKHTLCOutputInCommitment o_conv;
7022         o_conv.inner = (void*)(o & (~1));
7023         o_conv.is_owned = (o & 1) || (o == 0);
7024         o_conv = HTLCOutputInCommitment_clone(&o_conv);
7025         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
7026         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
7027         return (long)ret_conv;
7028 }
7029
7030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7031         LDKDecodeError e_conv;
7032         e_conv.inner = (void*)(e & (~1));
7033         e_conv.is_owned = (e & 1) || (e == 0);
7034         e_conv = DecodeError_clone(&e_conv);
7035         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
7036         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
7037         return (long)ret_conv;
7038 }
7039
7040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7041         if ((_res & 1) != 0) return;
7042         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
7043         FREE((void*)_res);
7044         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
7045 }
7046
7047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7048         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
7049         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
7050         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
7051         return (long)ret_conv;
7052 }
7053
7054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7055         LDKCounterpartyChannelTransactionParameters o_conv;
7056         o_conv.inner = (void*)(o & (~1));
7057         o_conv.is_owned = (o & 1) || (o == 0);
7058         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
7059         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
7060         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
7061         return (long)ret_conv;
7062 }
7063
7064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7065         LDKDecodeError e_conv;
7066         e_conv.inner = (void*)(e & (~1));
7067         e_conv.is_owned = (e & 1) || (e == 0);
7068         e_conv = DecodeError_clone(&e_conv);
7069         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
7070         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
7071         return (long)ret_conv;
7072 }
7073
7074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7075         if ((_res & 1) != 0) return;
7076         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
7077         FREE((void*)_res);
7078         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
7079 }
7080
7081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7082         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
7083         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
7084         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
7085         return (long)ret_conv;
7086 }
7087
7088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7089         LDKChannelTransactionParameters o_conv;
7090         o_conv.inner = (void*)(o & (~1));
7091         o_conv.is_owned = (o & 1) || (o == 0);
7092         o_conv = ChannelTransactionParameters_clone(&o_conv);
7093         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
7094         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
7095         return (long)ret_conv;
7096 }
7097
7098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7099         LDKDecodeError e_conv;
7100         e_conv.inner = (void*)(e & (~1));
7101         e_conv.is_owned = (e & 1) || (e == 0);
7102         e_conv = DecodeError_clone(&e_conv);
7103         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
7104         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
7105         return (long)ret_conv;
7106 }
7107
7108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7109         if ((_res & 1) != 0) return;
7110         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
7111         FREE((void*)_res);
7112         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
7113 }
7114
7115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7116         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
7117         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
7118         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
7119         return (long)ret_conv;
7120 }
7121
7122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
7123         LDKCVec_SignatureZ _res_constr;
7124         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7125         if (_res_constr.datalen > 0)
7126                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7127         else
7128                 _res_constr.data = NULL;
7129         for (size_t i = 0; i < _res_constr.datalen; i++) {
7130                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
7131                 LDKSignature _res_conv_8_ref;
7132                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
7133                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
7134                 _res_constr.data[i] = _res_conv_8_ref;
7135         }
7136         CVec_SignatureZ_free(_res_constr);
7137 }
7138
7139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7140         LDKHolderCommitmentTransaction o_conv;
7141         o_conv.inner = (void*)(o & (~1));
7142         o_conv.is_owned = (o & 1) || (o == 0);
7143         o_conv = HolderCommitmentTransaction_clone(&o_conv);
7144         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
7145         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
7146         return (long)ret_conv;
7147 }
7148
7149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7150         LDKDecodeError e_conv;
7151         e_conv.inner = (void*)(e & (~1));
7152         e_conv.is_owned = (e & 1) || (e == 0);
7153         e_conv = DecodeError_clone(&e_conv);
7154         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
7155         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
7156         return (long)ret_conv;
7157 }
7158
7159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7160         if ((_res & 1) != 0) return;
7161         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
7162         FREE((void*)_res);
7163         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
7164 }
7165
7166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7167         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
7168         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
7169         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
7170         return (long)ret_conv;
7171 }
7172
7173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7174         LDKBuiltCommitmentTransaction o_conv;
7175         o_conv.inner = (void*)(o & (~1));
7176         o_conv.is_owned = (o & 1) || (o == 0);
7177         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
7178         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
7179         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
7180         return (long)ret_conv;
7181 }
7182
7183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7184         LDKDecodeError e_conv;
7185         e_conv.inner = (void*)(e & (~1));
7186         e_conv.is_owned = (e & 1) || (e == 0);
7187         e_conv = DecodeError_clone(&e_conv);
7188         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
7189         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
7190         return (long)ret_conv;
7191 }
7192
7193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7194         if ((_res & 1) != 0) return;
7195         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
7196         FREE((void*)_res);
7197         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
7198 }
7199
7200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7201         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
7202         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
7203         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
7204         return (long)ret_conv;
7205 }
7206
7207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7208         LDKCommitmentTransaction o_conv;
7209         o_conv.inner = (void*)(o & (~1));
7210         o_conv.is_owned = (o & 1) || (o == 0);
7211         o_conv = CommitmentTransaction_clone(&o_conv);
7212         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
7213         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
7214         return (long)ret_conv;
7215 }
7216
7217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7218         LDKDecodeError e_conv;
7219         e_conv.inner = (void*)(e & (~1));
7220         e_conv.is_owned = (e & 1) || (e == 0);
7221         e_conv = DecodeError_clone(&e_conv);
7222         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
7223         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
7224         return (long)ret_conv;
7225 }
7226
7227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7228         if ((_res & 1) != 0) return;
7229         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
7230         FREE((void*)_res);
7231         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
7232 }
7233
7234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7235         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
7236         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
7237         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
7238         return (long)ret_conv;
7239 }
7240
7241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7242         LDKTrustedCommitmentTransaction o_conv;
7243         o_conv.inner = (void*)(o & (~1));
7244         o_conv.is_owned = (o & 1) || (o == 0);
7245         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
7246         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
7247         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
7248         return (long)ret_conv;
7249 }
7250
7251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
7252         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
7253         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
7254         return (long)ret_conv;
7255 }
7256
7257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7258         if ((_res & 1) != 0) return;
7259         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
7260         FREE((void*)_res);
7261         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
7262 }
7263
7264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
7265         LDKCVec_SignatureZ o_constr;
7266         o_constr.datalen = (*env)->GetArrayLength(env, o);
7267         if (o_constr.datalen > 0)
7268                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7269         else
7270                 o_constr.data = NULL;
7271         for (size_t i = 0; i < o_constr.datalen; i++) {
7272                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
7273                 LDKSignature o_conv_8_ref;
7274                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
7275                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
7276                 o_constr.data[i] = o_conv_8_ref;
7277         }
7278         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7279         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
7280         return (long)ret_conv;
7281 }
7282
7283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
7284         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7285         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
7286         return (long)ret_conv;
7287 }
7288
7289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7290         if ((_res & 1) != 0) return;
7291         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
7292         FREE((void*)_res);
7293         CResult_CVec_SignatureZNoneZ_free(_res_conv);
7294 }
7295
7296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7297         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
7298         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7299         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
7300         return (long)ret_conv;
7301 }
7302
7303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7304         LDKChannelMonitorUpdate o_conv;
7305         o_conv.inner = (void*)(o & (~1));
7306         o_conv.is_owned = (o & 1) || (o == 0);
7307         o_conv = ChannelMonitorUpdate_clone(&o_conv);
7308         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7309         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
7310         return (long)ret_conv;
7311 }
7312
7313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7314         LDKDecodeError e_conv;
7315         e_conv.inner = (void*)(e & (~1));
7316         e_conv.is_owned = (e & 1) || (e == 0);
7317         e_conv = DecodeError_clone(&e_conv);
7318         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7319         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
7320         return (long)ret_conv;
7321 }
7322
7323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7324         if ((_res & 1) != 0) return;
7325         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
7326         FREE((void*)_res);
7327         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
7328 }
7329
7330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7331         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
7332         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7333         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
7334         return (long)ret_conv;
7335 }
7336
7337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7338         LDKHTLCUpdate o_conv;
7339         o_conv.inner = (void*)(o & (~1));
7340         o_conv.is_owned = (o & 1) || (o == 0);
7341         o_conv = HTLCUpdate_clone(&o_conv);
7342         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7343         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
7344         return (long)ret_conv;
7345 }
7346
7347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7348         LDKDecodeError e_conv;
7349         e_conv.inner = (void*)(e & (~1));
7350         e_conv.is_owned = (e & 1) || (e == 0);
7351         e_conv = DecodeError_clone(&e_conv);
7352         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7353         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
7354         return (long)ret_conv;
7355 }
7356
7357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7358         if ((_res & 1) != 0) return;
7359         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
7360         FREE((void*)_res);
7361         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
7362 }
7363
7364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7365         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
7366         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7367         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
7368         return (long)ret_conv;
7369 }
7370
7371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
7372         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7373         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
7374         return (long)ret_conv;
7375 }
7376
7377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7378         LDKMonitorUpdateError e_conv;
7379         e_conv.inner = (void*)(e & (~1));
7380         e_conv.is_owned = (e & 1) || (e == 0);
7381         e_conv = MonitorUpdateError_clone(&e_conv);
7382         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7383         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
7384         return (long)ret_conv;
7385 }
7386
7387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7388         if ((_res & 1) != 0) return;
7389         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
7390         FREE((void*)_res);
7391         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
7392 }
7393
7394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7395         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
7396         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7397         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
7398         return (long)ret_conv;
7399 }
7400
7401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
7402         LDKOutPoint a_conv;
7403         a_conv.inner = (void*)(a & (~1));
7404         a_conv.is_owned = (a & 1) || (a == 0);
7405         a_conv = OutPoint_clone(&a_conv);
7406         LDKCVec_u8Z b_ref;
7407         b_ref.datalen = (*env)->GetArrayLength(env, b);
7408         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
7409         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7410         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
7411         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
7412         return (long)ret_ref;
7413 }
7414
7415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7416         if ((_res & 1) != 0) return;
7417         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
7418         FREE((void*)_res);
7419         C2Tuple_OutPointScriptZ_free(_res_conv);
7420 }
7421
7422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
7423         LDKCVec_u8Z b_ref;
7424         b_ref.datalen = (*env)->GetArrayLength(env, b);
7425         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
7426         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7427         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
7428         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
7429         return (long)ret_ref;
7430 }
7431
7432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7433         if ((_res & 1) != 0) return;
7434         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
7435         FREE((void*)_res);
7436         C2Tuple_u32ScriptZ_free(_res_conv);
7437 }
7438
7439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7440         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
7441         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7442         if (_res_constr.datalen > 0)
7443                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
7444         else
7445                 _res_constr.data = NULL;
7446         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7447         for (size_t b = 0; b < _res_constr.datalen; b++) {
7448                 int64_t _res_conv_27 = _res_vals[b];
7449                 LDKC2Tuple_u32ScriptZ _res_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_27) & ~1);
7450                 FREE((void*)_res_conv_27);
7451                 _res_constr.data[b] = _res_conv_27_conv;
7452         }
7453         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7454         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
7455 }
7456
7457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
7458         LDKThirtyTwoBytes a_ref;
7459         CHECK((*env)->GetArrayLength(env, a) == 32);
7460         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
7461         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
7462         b_constr.datalen = (*env)->GetArrayLength(env, b);
7463         if (b_constr.datalen > 0)
7464                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
7465         else
7466                 b_constr.data = NULL;
7467         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
7468         for (size_t b = 0; b < b_constr.datalen; b++) {
7469                 int64_t b_conv_27 = b_vals[b];
7470                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
7471                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_u32ScriptZ
7472                 b_constr.data[b] = b_conv_27_conv;
7473         }
7474         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
7475         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
7476         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
7477         return (long)ret_ref;
7478 }
7479
7480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7481         if ((_res & 1) != 0) return;
7482         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
7483         FREE((void*)_res);
7484         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
7485 }
7486
7487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7488         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
7489         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7490         if (_res_constr.datalen > 0)
7491                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
7492         else
7493                 _res_constr.data = NULL;
7494         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7495         for (size_t v = 0; v < _res_constr.datalen; v++) {
7496                 int64_t _res_conv_47 = _res_vals[v];
7497                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_47_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_47) & ~1);
7498                 FREE((void*)_res_conv_47);
7499                 _res_constr.data[v] = _res_conv_47_conv;
7500         }
7501         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7502         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
7503 }
7504
7505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7506         LDKCVec_MonitorEventZ _res_constr;
7507         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7508         if (_res_constr.datalen > 0)
7509                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
7510         else
7511                 _res_constr.data = NULL;
7512         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7513         for (size_t o = 0; o < _res_constr.datalen; o++) {
7514                 int64_t _res_conv_14 = _res_vals[o];
7515                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
7516                 FREE((void*)_res_conv_14);
7517                 _res_constr.data[o] = _res_conv_14_conv;
7518         }
7519         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7520         CVec_MonitorEventZ_free(_res_constr);
7521 }
7522
7523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7524         LDKCVec_EventZ _res_constr;
7525         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7526         if (_res_constr.datalen > 0)
7527                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
7528         else
7529                 _res_constr.data = NULL;
7530         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7531         for (size_t h = 0; h < _res_constr.datalen; h++) {
7532                 int64_t _res_conv_7 = _res_vals[h];
7533                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
7534                 FREE((void*)_res_conv_7);
7535                 _res_constr.data[h] = _res_conv_7_conv;
7536         }
7537         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7538         CVec_EventZ_free(_res_constr);
7539 }
7540
7541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
7542         LDKCVec_TransactionZ _res_constr;
7543         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7544         if (_res_constr.datalen > 0)
7545                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
7546         else
7547                 _res_constr.data = NULL;
7548         for (size_t i = 0; i < _res_constr.datalen; i++) {
7549                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
7550                 LDKTransaction _res_conv_8_ref;
7551                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
7552                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
7553                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
7554                 _res_conv_8_ref.data_is_owned = true;
7555                 _res_constr.data[i] = _res_conv_8_ref;
7556         }
7557         CVec_TransactionZ_free(_res_constr);
7558 }
7559
7560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
7561         LDKTransaction b_ref;
7562         b_ref.datalen = (*env)->GetArrayLength(env, b);
7563         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
7564         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7565         b_ref.data_is_owned = true;
7566         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7567         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
7568         return (long)ret_ref;
7569 }
7570
7571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7572         if ((_res & 1) != 0) return;
7573         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
7574         FREE((void*)_res);
7575         C2Tuple_usizeTransactionZ_free(_res_conv);
7576 }
7577
7578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7579         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
7580         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7581         if (_res_constr.datalen > 0)
7582                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7583         else
7584                 _res_constr.data = NULL;
7585         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7586         for (size_t y = 0; y < _res_constr.datalen; y++) {
7587                 int64_t _res_conv_24 = _res_vals[y];
7588                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
7589                 FREE((void*)_res_conv_24);
7590                 _res_constr.data[y] = _res_conv_24_conv;
7591         }
7592         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7593         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
7594 }
7595
7596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7597         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
7598         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7599         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
7600         return (long)ret_ref;
7601 }
7602
7603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
7604         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
7605         FREE((void*)b);
7606         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7607         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
7608         return (long)ret_ref;
7609 }
7610
7611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7612         if ((_res & 1) != 0) return;
7613         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
7614         FREE((void*)_res);
7615         C2Tuple_u32TxOutZ_free(_res_conv);
7616 }
7617
7618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7619         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
7620         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7621         if (_res_constr.datalen > 0)
7622                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
7623         else
7624                 _res_constr.data = NULL;
7625         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7626         for (size_t a = 0; a < _res_constr.datalen; a++) {
7627                 int64_t _res_conv_26 = _res_vals[a];
7628                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
7629                 FREE((void*)_res_conv_26);
7630                 _res_constr.data[a] = _res_conv_26_conv;
7631         }
7632         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7633         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
7634 }
7635
7636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
7637         LDKThirtyTwoBytes a_ref;
7638         CHECK((*env)->GetArrayLength(env, a) == 32);
7639         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
7640         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
7641         b_constr.datalen = (*env)->GetArrayLength(env, b);
7642         if (b_constr.datalen > 0)
7643                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
7644         else
7645                 b_constr.data = NULL;
7646         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
7647         for (size_t a = 0; a < b_constr.datalen; a++) {
7648                 int64_t b_conv_26 = b_vals[a];
7649                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
7650                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
7651                 b_constr.data[a] = b_conv_26_conv;
7652         }
7653         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
7654         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
7655         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
7656         return (long)ret_ref;
7657 }
7658
7659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7660         if ((_res & 1) != 0) return;
7661         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
7662         FREE((void*)_res);
7663         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
7664 }
7665
7666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7667         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
7668         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7669         if (_res_constr.datalen > 0)
7670                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
7671         else
7672                 _res_constr.data = NULL;
7673         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7674         for (size_t u = 0; u < _res_constr.datalen; u++) {
7675                 int64_t _res_conv_46 = _res_vals[u];
7676                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
7677                 FREE((void*)_res_conv_46);
7678                 _res_constr.data[u] = _res_conv_46_conv;
7679         }
7680         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7681         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
7682 }
7683
7684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
7685         LDKCVec_TxidZ _res_constr;
7686         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7687         if (_res_constr.datalen > 0)
7688                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7689         else
7690                 _res_constr.data = NULL;
7691         for (size_t i = 0; i < _res_constr.datalen; i++) {
7692                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
7693                 LDKThirtyTwoBytes _res_conv_8_ref;
7694                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
7695                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
7696                 _res_constr.data[i] = _res_conv_8_ref;
7697         }
7698         CVec_TxidZ_free(_res_constr);
7699 }
7700
7701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
7702         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7703         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
7704         return (long)ret_conv;
7705 }
7706
7707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
7708         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
7709         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7710         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
7711         return (long)ret_conv;
7712 }
7713
7714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7715         if ((_res & 1) != 0) return;
7716         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
7717         FREE((void*)_res);
7718         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
7719 }
7720
7721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7722         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
7723         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7724         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
7725         return (long)ret_conv;
7726 }
7727
7728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
7729         LDKThirtyTwoBytes a_ref;
7730         CHECK((*env)->GetArrayLength(env, a) == 32);
7731         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
7732         LDKChannelMonitor b_conv;
7733         b_conv.inner = (void*)(b & (~1));
7734         b_conv.is_owned = (b & 1) || (b == 0);
7735         b_conv = ChannelMonitor_clone(&b_conv);
7736         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7737         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
7738         return (long)ret_ref;
7739 }
7740
7741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7742         if ((_res & 1) != 0) return;
7743         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
7744         FREE((void*)_res);
7745         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
7746 }
7747
7748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7749         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
7750         FREE((void*)o);
7751         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
7752         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
7753         return (long)ret_conv;
7754 }
7755
7756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7757         LDKDecodeError e_conv;
7758         e_conv.inner = (void*)(e & (~1));
7759         e_conv.is_owned = (e & 1) || (e == 0);
7760         e_conv = DecodeError_clone(&e_conv);
7761         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
7762         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
7763         return (long)ret_conv;
7764 }
7765
7766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7767         if ((_res & 1) != 0) return;
7768         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
7769         FREE((void*)_res);
7770         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
7771 }
7772
7773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7774         LDKCVec_RouteHopZ _res_constr;
7775         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7776         if (_res_constr.datalen > 0)
7777                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7778         else
7779                 _res_constr.data = NULL;
7780         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7781         for (size_t k = 0; k < _res_constr.datalen; k++) {
7782                 int64_t _res_conv_10 = _res_vals[k];
7783                 LDKRouteHop _res_conv_10_conv;
7784                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
7785                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
7786                 _res_constr.data[k] = _res_conv_10_conv;
7787         }
7788         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7789         CVec_RouteHopZ_free(_res_constr);
7790 }
7791
7792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
7793         LDKCVec_CVec_RouteHopZZ _res_constr;
7794         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7795         if (_res_constr.datalen > 0)
7796                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
7797         else
7798                 _res_constr.data = NULL;
7799         for (size_t m = 0; m < _res_constr.datalen; m++) {
7800                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
7801                 LDKCVec_RouteHopZ _res_conv_12_constr;
7802                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
7803                 if (_res_conv_12_constr.datalen > 0)
7804                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7805                 else
7806                         _res_conv_12_constr.data = NULL;
7807                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
7808                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
7809                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
7810                         LDKRouteHop _res_conv_12_conv_10_conv;
7811                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
7812                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
7813                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
7814                 }
7815                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
7816                 _res_constr.data[m] = _res_conv_12_constr;
7817         }
7818         CVec_CVec_RouteHopZZ_free(_res_constr);
7819 }
7820
7821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7822         LDKRoute o_conv;
7823         o_conv.inner = (void*)(o & (~1));
7824         o_conv.is_owned = (o & 1) || (o == 0);
7825         o_conv = Route_clone(&o_conv);
7826         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7827         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
7828         return (long)ret_conv;
7829 }
7830
7831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7832         LDKDecodeError e_conv;
7833         e_conv.inner = (void*)(e & (~1));
7834         e_conv.is_owned = (e & 1) || (e == 0);
7835         e_conv = DecodeError_clone(&e_conv);
7836         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7837         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
7838         return (long)ret_conv;
7839 }
7840
7841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7842         if ((_res & 1) != 0) return;
7843         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
7844         FREE((void*)_res);
7845         CResult_RouteDecodeErrorZ_free(_res_conv);
7846 }
7847
7848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7849         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
7850         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7851         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
7852         return (long)ret_conv;
7853 }
7854
7855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
7856         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7857         *ret_copy = COption_u64Z_some(o);
7858         long ret_ref = (long)ret_copy;
7859         return ret_ref;
7860 }
7861
7862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
7863         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7864         *ret_copy = COption_u64Z_none();
7865         long ret_ref = (long)ret_copy;
7866         return ret_ref;
7867 }
7868
7869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
7870         if ((_res & 1) != 0) return;
7871         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
7872         FREE((void*)_res);
7873         COption_u64Z_free(_res_conv);
7874 }
7875
7876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7877         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
7878         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7879         *ret_copy = COption_u64Z_clone(orig_conv);
7880         long ret_ref = (long)ret_copy;
7881         return ret_ref;
7882 }
7883
7884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7885         LDKCVec_ChannelDetailsZ _res_constr;
7886         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7887         if (_res_constr.datalen > 0)
7888                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7889         else
7890                 _res_constr.data = NULL;
7891         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7892         for (size_t q = 0; q < _res_constr.datalen; q++) {
7893                 int64_t _res_conv_16 = _res_vals[q];
7894                 LDKChannelDetails _res_conv_16_conv;
7895                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7896                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7897                 _res_constr.data[q] = _res_conv_16_conv;
7898         }
7899         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7900         CVec_ChannelDetailsZ_free(_res_constr);
7901 }
7902
7903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7904         LDKCVec_RouteHintZ _res_constr;
7905         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7906         if (_res_constr.datalen > 0)
7907                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
7908         else
7909                 _res_constr.data = NULL;
7910         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7911         for (size_t l = 0; l < _res_constr.datalen; l++) {
7912                 int64_t _res_conv_11 = _res_vals[l];
7913                 LDKRouteHint _res_conv_11_conv;
7914                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
7915                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
7916                 _res_constr.data[l] = _res_conv_11_conv;
7917         }
7918         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7919         CVec_RouteHintZ_free(_res_constr);
7920 }
7921
7922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7923         LDKRoute o_conv;
7924         o_conv.inner = (void*)(o & (~1));
7925         o_conv.is_owned = (o & 1) || (o == 0);
7926         o_conv = Route_clone(&o_conv);
7927         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7928         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
7929         return (long)ret_conv;
7930 }
7931
7932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7933         LDKLightningError e_conv;
7934         e_conv.inner = (void*)(e & (~1));
7935         e_conv.is_owned = (e & 1) || (e == 0);
7936         e_conv = LightningError_clone(&e_conv);
7937         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7938         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
7939         return (long)ret_conv;
7940 }
7941
7942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7943         if ((_res & 1) != 0) return;
7944         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
7945         FREE((void*)_res);
7946         CResult_RouteLightningErrorZ_free(_res_conv);
7947 }
7948
7949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7950         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
7951         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7952         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
7953         return (long)ret_conv;
7954 }
7955
7956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7957         LDKCVec_MessageSendEventZ _res_constr;
7958         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7959         if (_res_constr.datalen > 0)
7960                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7961         else
7962                 _res_constr.data = NULL;
7963         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7964         for (size_t s = 0; s < _res_constr.datalen; s++) {
7965                 int64_t _res_conv_18 = _res_vals[s];
7966                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
7967                 FREE((void*)_res_conv_18);
7968                 _res_constr.data[s] = _res_conv_18_conv;
7969         }
7970         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7971         CVec_MessageSendEventZ_free(_res_constr);
7972 }
7973
7974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
7975         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7976         *ret_conv = CResult_boolLightningErrorZ_ok(o);
7977         return (long)ret_conv;
7978 }
7979
7980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7981         LDKLightningError e_conv;
7982         e_conv.inner = (void*)(e & (~1));
7983         e_conv.is_owned = (e & 1) || (e == 0);
7984         e_conv = LightningError_clone(&e_conv);
7985         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7986         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
7987         return (long)ret_conv;
7988 }
7989
7990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7991         if ((_res & 1) != 0) return;
7992         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
7993         FREE((void*)_res);
7994         CResult_boolLightningErrorZ_free(_res_conv);
7995 }
7996
7997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7998         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
7999         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8000         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
8001         return (long)ret_conv;
8002 }
8003
8004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8005         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
8006         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8007         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
8008         return (long)ret_ref;
8009 }
8010
8011 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) {
8012         LDKChannelAnnouncement a_conv;
8013         a_conv.inner = (void*)(a & (~1));
8014         a_conv.is_owned = (a & 1) || (a == 0);
8015         a_conv = ChannelAnnouncement_clone(&a_conv);
8016         LDKChannelUpdate b_conv;
8017         b_conv.inner = (void*)(b & (~1));
8018         b_conv.is_owned = (b & 1) || (b == 0);
8019         b_conv = ChannelUpdate_clone(&b_conv);
8020         LDKChannelUpdate c_conv;
8021         c_conv.inner = (void*)(c & (~1));
8022         c_conv.is_owned = (c & 1) || (c == 0);
8023         c_conv = ChannelUpdate_clone(&c_conv);
8024         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8025         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
8026         return (long)ret_ref;
8027 }
8028
8029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8030         if ((_res & 1) != 0) return;
8031         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
8032         FREE((void*)_res);
8033         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
8034 }
8035
8036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8037         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
8038         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8039         if (_res_constr.datalen > 0)
8040                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
8041         else
8042                 _res_constr.data = NULL;
8043         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8044         for (size_t l = 0; l < _res_constr.datalen; l++) {
8045                 int64_t _res_conv_63 = _res_vals[l];
8046                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
8047                 FREE((void*)_res_conv_63);
8048                 _res_constr.data[l] = _res_conv_63_conv;
8049         }
8050         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8051         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
8052 }
8053
8054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8055         LDKCVec_NodeAnnouncementZ _res_constr;
8056         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8057         if (_res_constr.datalen > 0)
8058                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
8059         else
8060                 _res_constr.data = NULL;
8061         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8062         for (size_t s = 0; s < _res_constr.datalen; s++) {
8063                 int64_t _res_conv_18 = _res_vals[s];
8064                 LDKNodeAnnouncement _res_conv_18_conv;
8065                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
8066                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
8067                 _res_constr.data[s] = _res_conv_18_conv;
8068         }
8069         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8070         CVec_NodeAnnouncementZ_free(_res_constr);
8071 }
8072
8073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
8074         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8075         *ret_conv = CResult_NoneLightningErrorZ_ok();
8076         return (long)ret_conv;
8077 }
8078
8079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8080         LDKLightningError e_conv;
8081         e_conv.inner = (void*)(e & (~1));
8082         e_conv.is_owned = (e & 1) || (e == 0);
8083         e_conv = LightningError_clone(&e_conv);
8084         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8085         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
8086         return (long)ret_conv;
8087 }
8088
8089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8090         if ((_res & 1) != 0) return;
8091         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
8092         FREE((void*)_res);
8093         CResult_NoneLightningErrorZ_free(_res_conv);
8094 }
8095
8096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8097         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
8098         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8099         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
8100         return (long)ret_conv;
8101 }
8102
8103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
8104         LDKCVec_PublicKeyZ _res_constr;
8105         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8106         if (_res_constr.datalen > 0)
8107                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
8108         else
8109                 _res_constr.data = NULL;
8110         for (size_t i = 0; i < _res_constr.datalen; i++) {
8111                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
8112                 LDKPublicKey _res_conv_8_ref;
8113                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
8114                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
8115                 _res_constr.data[i] = _res_conv_8_ref;
8116         }
8117         CVec_PublicKeyZ_free(_res_constr);
8118 }
8119
8120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
8121         LDKCVec_u8Z _res_ref;
8122         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
8123         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
8124         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
8125         CVec_u8Z_free(_res_ref);
8126 }
8127
8128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8129         LDKCVec_u8Z o_ref;
8130         o_ref.datalen = (*env)->GetArrayLength(env, o);
8131         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
8132         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
8133         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
8134         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
8135         return (long)ret_conv;
8136 }
8137
8138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8139         LDKPeerHandleError e_conv;
8140         e_conv.inner = (void*)(e & (~1));
8141         e_conv.is_owned = (e & 1) || (e == 0);
8142         e_conv = PeerHandleError_clone(&e_conv);
8143         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
8144         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
8145         return (long)ret_conv;
8146 }
8147
8148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8149         if ((_res & 1) != 0) return;
8150         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
8151         FREE((void*)_res);
8152         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
8153 }
8154
8155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8156         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
8157         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
8158         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
8159         return (long)ret_conv;
8160 }
8161
8162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
8163         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
8164         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
8165         return (long)ret_conv;
8166 }
8167
8168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8169         LDKPeerHandleError e_conv;
8170         e_conv.inner = (void*)(e & (~1));
8171         e_conv.is_owned = (e & 1) || (e == 0);
8172         e_conv = PeerHandleError_clone(&e_conv);
8173         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
8174         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
8175         return (long)ret_conv;
8176 }
8177
8178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8179         if ((_res & 1) != 0) return;
8180         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
8181         FREE((void*)_res);
8182         CResult_NonePeerHandleErrorZ_free(_res_conv);
8183 }
8184
8185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8186         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
8187         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
8188         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
8189         return (long)ret_conv;
8190 }
8191
8192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
8193         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
8194         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
8195         return (long)ret_conv;
8196 }
8197
8198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8199         LDKPeerHandleError e_conv;
8200         e_conv.inner = (void*)(e & (~1));
8201         e_conv.is_owned = (e & 1) || (e == 0);
8202         e_conv = PeerHandleError_clone(&e_conv);
8203         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
8204         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
8205         return (long)ret_conv;
8206 }
8207
8208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8209         if ((_res & 1) != 0) return;
8210         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
8211         FREE((void*)_res);
8212         CResult_boolPeerHandleErrorZ_free(_res_conv);
8213 }
8214
8215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8216         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
8217         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
8218         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
8219         return (long)ret_conv;
8220 }
8221
8222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8223         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
8224         FREE((void*)o);
8225         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8226         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
8227         return (long)ret_conv;
8228 }
8229
8230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
8231         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
8232         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8233         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
8234         return (long)ret_conv;
8235 }
8236
8237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8238         if ((_res & 1) != 0) return;
8239         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
8240         FREE((void*)_res);
8241         CResult_TxOutAccessErrorZ_free(_res_conv);
8242 }
8243
8244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8245         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
8246         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8247         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
8248         return (long)ret_conv;
8249 }
8250
8251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
8252         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
8253         FREE((void*)o);
8254         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8255         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
8256         long ret_ref = (long)ret_copy;
8257         return ret_ref;
8258 }
8259
8260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
8261         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8262         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
8263         long ret_ref = (long)ret_copy;
8264         return ret_ref;
8265 }
8266
8267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8268         if ((_res & 1) != 0) return;
8269         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
8270         FREE((void*)_res);
8271         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
8272 }
8273
8274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8275         LDKCVec_SpendableOutputDescriptorZ _res_constr;
8276         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8277         if (_res_constr.datalen > 0)
8278                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
8279         else
8280                 _res_constr.data = NULL;
8281         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8282         for (size_t b = 0; b < _res_constr.datalen; b++) {
8283                 int64_t _res_conv_27 = _res_vals[b];
8284                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
8285                 FREE((void*)_res_conv_27);
8286                 _res_constr.data[b] = _res_conv_27_conv;
8287         }
8288         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8289         CVec_SpendableOutputDescriptorZ_free(_res_constr);
8290 }
8291
8292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8293         LDKDirectionalChannelInfo o_conv;
8294         o_conv.inner = (void*)(o & (~1));
8295         o_conv.is_owned = (o & 1) || (o == 0);
8296         o_conv = DirectionalChannelInfo_clone(&o_conv);
8297         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
8298         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
8299         return (long)ret_conv;
8300 }
8301
8302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8303         LDKDecodeError e_conv;
8304         e_conv.inner = (void*)(e & (~1));
8305         e_conv.is_owned = (e & 1) || (e == 0);
8306         e_conv = DecodeError_clone(&e_conv);
8307         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
8308         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
8309         return (long)ret_conv;
8310 }
8311
8312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8313         if ((_res & 1) != 0) return;
8314         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
8315         FREE((void*)_res);
8316         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
8317 }
8318
8319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8320         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
8321         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
8322         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
8323         return (long)ret_conv;
8324 }
8325
8326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8327         LDKChannelInfo o_conv;
8328         o_conv.inner = (void*)(o & (~1));
8329         o_conv.is_owned = (o & 1) || (o == 0);
8330         o_conv = ChannelInfo_clone(&o_conv);
8331         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
8332         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
8333         return (long)ret_conv;
8334 }
8335
8336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8337         LDKDecodeError e_conv;
8338         e_conv.inner = (void*)(e & (~1));
8339         e_conv.is_owned = (e & 1) || (e == 0);
8340         e_conv = DecodeError_clone(&e_conv);
8341         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
8342         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
8343         return (long)ret_conv;
8344 }
8345
8346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8347         if ((_res & 1) != 0) return;
8348         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
8349         FREE((void*)_res);
8350         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
8351 }
8352
8353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8354         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
8355         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
8356         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
8357         return (long)ret_conv;
8358 }
8359
8360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8361         LDKRoutingFees o_conv;
8362         o_conv.inner = (void*)(o & (~1));
8363         o_conv.is_owned = (o & 1) || (o == 0);
8364         o_conv = RoutingFees_clone(&o_conv);
8365         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
8366         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
8367         return (long)ret_conv;
8368 }
8369
8370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8371         LDKDecodeError e_conv;
8372         e_conv.inner = (void*)(e & (~1));
8373         e_conv.is_owned = (e & 1) || (e == 0);
8374         e_conv = DecodeError_clone(&e_conv);
8375         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
8376         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
8377         return (long)ret_conv;
8378 }
8379
8380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8381         if ((_res & 1) != 0) return;
8382         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8383         FREE((void*)_res);
8384         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
8385 }
8386
8387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8388         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
8389         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
8390         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
8391         return (long)ret_conv;
8392 }
8393
8394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8395         LDKCVec_NetAddressZ _res_constr;
8396         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8397         if (_res_constr.datalen > 0)
8398                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
8399         else
8400                 _res_constr.data = NULL;
8401         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8402         for (size_t m = 0; m < _res_constr.datalen; m++) {
8403                 int64_t _res_conv_12 = _res_vals[m];
8404                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
8405                 FREE((void*)_res_conv_12);
8406                 _res_constr.data[m] = _res_conv_12_conv;
8407         }
8408         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8409         CVec_NetAddressZ_free(_res_constr);
8410 }
8411
8412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8413         LDKNodeAnnouncementInfo o_conv;
8414         o_conv.inner = (void*)(o & (~1));
8415         o_conv.is_owned = (o & 1) || (o == 0);
8416         o_conv = NodeAnnouncementInfo_clone(&o_conv);
8417         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
8418         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
8419         return (long)ret_conv;
8420 }
8421
8422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8423         LDKDecodeError e_conv;
8424         e_conv.inner = (void*)(e & (~1));
8425         e_conv.is_owned = (e & 1) || (e == 0);
8426         e_conv = DecodeError_clone(&e_conv);
8427         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
8428         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
8429         return (long)ret_conv;
8430 }
8431
8432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8433         if ((_res & 1) != 0) return;
8434         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
8435         FREE((void*)_res);
8436         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
8437 }
8438
8439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8440         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
8441         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
8442         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
8443         return (long)ret_conv;
8444 }
8445
8446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8447         LDKCVec_u64Z _res_constr;
8448         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8449         if (_res_constr.datalen > 0)
8450                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
8451         else
8452                 _res_constr.data = NULL;
8453         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8454         for (size_t g = 0; g < _res_constr.datalen; g++) {
8455                 int64_t _res_conv_6 = _res_vals[g];
8456                 _res_constr.data[g] = _res_conv_6;
8457         }
8458         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8459         CVec_u64Z_free(_res_constr);
8460 }
8461
8462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8463         LDKNodeInfo o_conv;
8464         o_conv.inner = (void*)(o & (~1));
8465         o_conv.is_owned = (o & 1) || (o == 0);
8466         o_conv = NodeInfo_clone(&o_conv);
8467         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
8468         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
8469         return (long)ret_conv;
8470 }
8471
8472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8473         LDKDecodeError e_conv;
8474         e_conv.inner = (void*)(e & (~1));
8475         e_conv.is_owned = (e & 1) || (e == 0);
8476         e_conv = DecodeError_clone(&e_conv);
8477         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
8478         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
8479         return (long)ret_conv;
8480 }
8481
8482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8483         if ((_res & 1) != 0) return;
8484         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
8485         FREE((void*)_res);
8486         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
8487 }
8488
8489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8490         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
8491         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
8492         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
8493         return (long)ret_conv;
8494 }
8495
8496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8497         LDKNetworkGraph o_conv;
8498         o_conv.inner = (void*)(o & (~1));
8499         o_conv.is_owned = (o & 1) || (o == 0);
8500         o_conv = NetworkGraph_clone(&o_conv);
8501         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
8502         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
8503         return (long)ret_conv;
8504 }
8505
8506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8507         LDKDecodeError e_conv;
8508         e_conv.inner = (void*)(e & (~1));
8509         e_conv.is_owned = (e & 1) || (e == 0);
8510         e_conv = DecodeError_clone(&e_conv);
8511         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
8512         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
8513         return (long)ret_conv;
8514 }
8515
8516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8517         if ((_res & 1) != 0) return;
8518         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
8519         FREE((void*)_res);
8520         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
8521 }
8522
8523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8524         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
8525         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
8526         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
8527         return (long)ret_conv;
8528 }
8529
8530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8531         LDKInitFeatures o_conv;
8532         o_conv.inner = (void*)(o & (~1));
8533         o_conv.is_owned = (o & 1) || (o == 0);
8534         o_conv = InitFeatures_clone(&o_conv);
8535         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
8536         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
8537         return (long)ret_conv;
8538 }
8539
8540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8541         LDKDecodeError e_conv;
8542         e_conv.inner = (void*)(e & (~1));
8543         e_conv.is_owned = (e & 1) || (e == 0);
8544         e_conv = DecodeError_clone(&e_conv);
8545         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
8546         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
8547         return (long)ret_conv;
8548 }
8549
8550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8551         if ((_res & 1) != 0) return;
8552         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8553         FREE((void*)_res);
8554         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
8555 }
8556
8557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8558         LDKNodeFeatures o_conv;
8559         o_conv.inner = (void*)(o & (~1));
8560         o_conv.is_owned = (o & 1) || (o == 0);
8561         o_conv = NodeFeatures_clone(&o_conv);
8562         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
8563         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
8564         return (long)ret_conv;
8565 }
8566
8567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8568         LDKDecodeError e_conv;
8569         e_conv.inner = (void*)(e & (~1));
8570         e_conv.is_owned = (e & 1) || (e == 0);
8571         e_conv = DecodeError_clone(&e_conv);
8572         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
8573         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
8574         return (long)ret_conv;
8575 }
8576
8577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8578         if ((_res & 1) != 0) return;
8579         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8580         FREE((void*)_res);
8581         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
8582 }
8583
8584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8585         LDKChannelFeatures o_conv;
8586         o_conv.inner = (void*)(o & (~1));
8587         o_conv.is_owned = (o & 1) || (o == 0);
8588         o_conv = ChannelFeatures_clone(&o_conv);
8589         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
8590         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
8591         return (long)ret_conv;
8592 }
8593
8594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8595         LDKDecodeError e_conv;
8596         e_conv.inner = (void*)(e & (~1));
8597         e_conv.is_owned = (e & 1) || (e == 0);
8598         e_conv = DecodeError_clone(&e_conv);
8599         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
8600         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
8601         return (long)ret_conv;
8602 }
8603
8604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8605         if ((_res & 1) != 0) return;
8606         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8607         FREE((void*)_res);
8608         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
8609 }
8610
8611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8612         LDKInvoiceFeatures o_conv;
8613         o_conv.inner = (void*)(o & (~1));
8614         o_conv.is_owned = (o & 1) || (o == 0);
8615         o_conv = InvoiceFeatures_clone(&o_conv);
8616         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
8617         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
8618         return (long)ret_conv;
8619 }
8620
8621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8622         LDKDecodeError e_conv;
8623         e_conv.inner = (void*)(e & (~1));
8624         e_conv.is_owned = (e & 1) || (e == 0);
8625         e_conv = DecodeError_clone(&e_conv);
8626         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
8627         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
8628         return (long)ret_conv;
8629 }
8630
8631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8632         if ((_res & 1) != 0) return;
8633         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8634         FREE((void*)_res);
8635         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
8636 }
8637
8638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
8639         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
8640         FREE((void*)o);
8641         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8642         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
8643         return (long)ret_conv;
8644 }
8645
8646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
8647         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8648         *ret_conv = CResult_NetAddressu8Z_err(e);
8649         return (long)ret_conv;
8650 }
8651
8652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
8653         if ((_res & 1) != 0) return;
8654         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
8655         FREE((void*)_res);
8656         CResult_NetAddressu8Z_free(_res_conv);
8657 }
8658
8659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8660         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
8661         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8662         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
8663         return (long)ret_conv;
8664 }
8665
8666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8667         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
8668         FREE((void*)o);
8669         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8670         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
8671         return (long)ret_conv;
8672 }
8673
8674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8675         LDKDecodeError e_conv;
8676         e_conv.inner = (void*)(e & (~1));
8677         e_conv.is_owned = (e & 1) || (e == 0);
8678         e_conv = DecodeError_clone(&e_conv);
8679         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8680         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
8681         return (long)ret_conv;
8682 }
8683
8684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8685         if ((_res & 1) != 0) return;
8686         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8687         FREE((void*)_res);
8688         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
8689 }
8690
8691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8692         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
8693         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8694         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
8695         return (long)ret_conv;
8696 }
8697
8698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8699         LDKCVec_UpdateAddHTLCZ _res_constr;
8700         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8701         if (_res_constr.datalen > 0)
8702                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
8703         else
8704                 _res_constr.data = NULL;
8705         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8706         for (size_t p = 0; p < _res_constr.datalen; p++) {
8707                 int64_t _res_conv_15 = _res_vals[p];
8708                 LDKUpdateAddHTLC _res_conv_15_conv;
8709                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
8710                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
8711                 _res_constr.data[p] = _res_conv_15_conv;
8712         }
8713         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8714         CVec_UpdateAddHTLCZ_free(_res_constr);
8715 }
8716
8717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8718         LDKCVec_UpdateFulfillHTLCZ _res_constr;
8719         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8720         if (_res_constr.datalen > 0)
8721                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
8722         else
8723                 _res_constr.data = NULL;
8724         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8725         for (size_t t = 0; t < _res_constr.datalen; t++) {
8726                 int64_t _res_conv_19 = _res_vals[t];
8727                 LDKUpdateFulfillHTLC _res_conv_19_conv;
8728                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
8729                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
8730                 _res_constr.data[t] = _res_conv_19_conv;
8731         }
8732         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8733         CVec_UpdateFulfillHTLCZ_free(_res_constr);
8734 }
8735
8736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8737         LDKCVec_UpdateFailHTLCZ _res_constr;
8738         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8739         if (_res_constr.datalen > 0)
8740                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
8741         else
8742                 _res_constr.data = NULL;
8743         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8744         for (size_t q = 0; q < _res_constr.datalen; q++) {
8745                 int64_t _res_conv_16 = _res_vals[q];
8746                 LDKUpdateFailHTLC _res_conv_16_conv;
8747                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8748                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8749                 _res_constr.data[q] = _res_conv_16_conv;
8750         }
8751         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8752         CVec_UpdateFailHTLCZ_free(_res_constr);
8753 }
8754
8755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8756         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
8757         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8758         if (_res_constr.datalen > 0)
8759                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
8760         else
8761                 _res_constr.data = NULL;
8762         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8763         for (size_t z = 0; z < _res_constr.datalen; z++) {
8764                 int64_t _res_conv_25 = _res_vals[z];
8765                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
8766                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
8767                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
8768                 _res_constr.data[z] = _res_conv_25_conv;
8769         }
8770         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8771         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
8772 }
8773
8774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8775         LDKAcceptChannel o_conv;
8776         o_conv.inner = (void*)(o & (~1));
8777         o_conv.is_owned = (o & 1) || (o == 0);
8778         o_conv = AcceptChannel_clone(&o_conv);
8779         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
8780         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
8781         return (long)ret_conv;
8782 }
8783
8784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8785         LDKDecodeError e_conv;
8786         e_conv.inner = (void*)(e & (~1));
8787         e_conv.is_owned = (e & 1) || (e == 0);
8788         e_conv = DecodeError_clone(&e_conv);
8789         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
8790         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
8791         return (long)ret_conv;
8792 }
8793
8794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8795         if ((_res & 1) != 0) return;
8796         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
8797         FREE((void*)_res);
8798         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
8799 }
8800
8801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8802         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
8803         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
8804         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
8805         return (long)ret_conv;
8806 }
8807
8808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8809         LDKAnnouncementSignatures o_conv;
8810         o_conv.inner = (void*)(o & (~1));
8811         o_conv.is_owned = (o & 1) || (o == 0);
8812         o_conv = AnnouncementSignatures_clone(&o_conv);
8813         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
8814         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
8815         return (long)ret_conv;
8816 }
8817
8818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8819         LDKDecodeError e_conv;
8820         e_conv.inner = (void*)(e & (~1));
8821         e_conv.is_owned = (e & 1) || (e == 0);
8822         e_conv = DecodeError_clone(&e_conv);
8823         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
8824         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
8825         return (long)ret_conv;
8826 }
8827
8828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8829         if ((_res & 1) != 0) return;
8830         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8831         FREE((void*)_res);
8832         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
8833 }
8834
8835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8836         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
8837         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
8838         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
8839         return (long)ret_conv;
8840 }
8841
8842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8843         LDKChannelReestablish o_conv;
8844         o_conv.inner = (void*)(o & (~1));
8845         o_conv.is_owned = (o & 1) || (o == 0);
8846         o_conv = ChannelReestablish_clone(&o_conv);
8847         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
8848         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
8849         return (long)ret_conv;
8850 }
8851
8852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8853         LDKDecodeError e_conv;
8854         e_conv.inner = (void*)(e & (~1));
8855         e_conv.is_owned = (e & 1) || (e == 0);
8856         e_conv = DecodeError_clone(&e_conv);
8857         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
8858         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
8859         return (long)ret_conv;
8860 }
8861
8862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8863         if ((_res & 1) != 0) return;
8864         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
8865         FREE((void*)_res);
8866         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
8867 }
8868
8869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8870         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
8871         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
8872         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
8873         return (long)ret_conv;
8874 }
8875
8876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8877         LDKClosingSigned o_conv;
8878         o_conv.inner = (void*)(o & (~1));
8879         o_conv.is_owned = (o & 1) || (o == 0);
8880         o_conv = ClosingSigned_clone(&o_conv);
8881         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
8882         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
8883         return (long)ret_conv;
8884 }
8885
8886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8887         LDKDecodeError e_conv;
8888         e_conv.inner = (void*)(e & (~1));
8889         e_conv.is_owned = (e & 1) || (e == 0);
8890         e_conv = DecodeError_clone(&e_conv);
8891         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
8892         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
8893         return (long)ret_conv;
8894 }
8895
8896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8897         if ((_res & 1) != 0) return;
8898         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8899         FREE((void*)_res);
8900         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
8901 }
8902
8903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8904         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
8905         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
8906         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
8907         return (long)ret_conv;
8908 }
8909
8910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8911         LDKCommitmentSigned o_conv;
8912         o_conv.inner = (void*)(o & (~1));
8913         o_conv.is_owned = (o & 1) || (o == 0);
8914         o_conv = CommitmentSigned_clone(&o_conv);
8915         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8916         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
8917         return (long)ret_conv;
8918 }
8919
8920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8921         LDKDecodeError e_conv;
8922         e_conv.inner = (void*)(e & (~1));
8923         e_conv.is_owned = (e & 1) || (e == 0);
8924         e_conv = DecodeError_clone(&e_conv);
8925         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8926         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
8927         return (long)ret_conv;
8928 }
8929
8930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8931         if ((_res & 1) != 0) return;
8932         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8933         FREE((void*)_res);
8934         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
8935 }
8936
8937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8938         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
8939         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8940         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
8941         return (long)ret_conv;
8942 }
8943
8944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8945         LDKFundingCreated o_conv;
8946         o_conv.inner = (void*)(o & (~1));
8947         o_conv.is_owned = (o & 1) || (o == 0);
8948         o_conv = FundingCreated_clone(&o_conv);
8949         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8950         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
8951         return (long)ret_conv;
8952 }
8953
8954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8955         LDKDecodeError e_conv;
8956         e_conv.inner = (void*)(e & (~1));
8957         e_conv.is_owned = (e & 1) || (e == 0);
8958         e_conv = DecodeError_clone(&e_conv);
8959         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8960         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
8961         return (long)ret_conv;
8962 }
8963
8964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8965         if ((_res & 1) != 0) return;
8966         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8967         FREE((void*)_res);
8968         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
8969 }
8970
8971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8972         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
8973         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8974         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
8975         return (long)ret_conv;
8976 }
8977
8978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8979         LDKFundingSigned o_conv;
8980         o_conv.inner = (void*)(o & (~1));
8981         o_conv.is_owned = (o & 1) || (o == 0);
8982         o_conv = FundingSigned_clone(&o_conv);
8983         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8984         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
8985         return (long)ret_conv;
8986 }
8987
8988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8989         LDKDecodeError e_conv;
8990         e_conv.inner = (void*)(e & (~1));
8991         e_conv.is_owned = (e & 1) || (e == 0);
8992         e_conv = DecodeError_clone(&e_conv);
8993         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8994         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
8995         return (long)ret_conv;
8996 }
8997
8998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8999         if ((_res & 1) != 0) return;
9000         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9001         FREE((void*)_res);
9002         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
9003 }
9004
9005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9006         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
9007         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9008         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
9009         return (long)ret_conv;
9010 }
9011
9012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9013         LDKFundingLocked o_conv;
9014         o_conv.inner = (void*)(o & (~1));
9015         o_conv.is_owned = (o & 1) || (o == 0);
9016         o_conv = FundingLocked_clone(&o_conv);
9017         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9018         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
9019         return (long)ret_conv;
9020 }
9021
9022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9023         LDKDecodeError e_conv;
9024         e_conv.inner = (void*)(e & (~1));
9025         e_conv.is_owned = (e & 1) || (e == 0);
9026         e_conv = DecodeError_clone(&e_conv);
9027         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9028         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
9029         return (long)ret_conv;
9030 }
9031
9032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9033         if ((_res & 1) != 0) return;
9034         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9035         FREE((void*)_res);
9036         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
9037 }
9038
9039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9040         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
9041         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9042         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
9043         return (long)ret_conv;
9044 }
9045
9046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9047         LDKInit o_conv;
9048         o_conv.inner = (void*)(o & (~1));
9049         o_conv.is_owned = (o & 1) || (o == 0);
9050         o_conv = Init_clone(&o_conv);
9051         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9052         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
9053         return (long)ret_conv;
9054 }
9055
9056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9057         LDKDecodeError e_conv;
9058         e_conv.inner = (void*)(e & (~1));
9059         e_conv.is_owned = (e & 1) || (e == 0);
9060         e_conv = DecodeError_clone(&e_conv);
9061         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9062         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
9063         return (long)ret_conv;
9064 }
9065
9066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9067         if ((_res & 1) != 0) return;
9068         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
9069         FREE((void*)_res);
9070         CResult_InitDecodeErrorZ_free(_res_conv);
9071 }
9072
9073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9074         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
9075         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9076         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
9077         return (long)ret_conv;
9078 }
9079
9080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9081         LDKOpenChannel o_conv;
9082         o_conv.inner = (void*)(o & (~1));
9083         o_conv.is_owned = (o & 1) || (o == 0);
9084         o_conv = OpenChannel_clone(&o_conv);
9085         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9086         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
9087         return (long)ret_conv;
9088 }
9089
9090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9091         LDKDecodeError e_conv;
9092         e_conv.inner = (void*)(e & (~1));
9093         e_conv.is_owned = (e & 1) || (e == 0);
9094         e_conv = DecodeError_clone(&e_conv);
9095         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9096         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
9097         return (long)ret_conv;
9098 }
9099
9100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9101         if ((_res & 1) != 0) return;
9102         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
9103         FREE((void*)_res);
9104         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
9105 }
9106
9107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9108         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
9109         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9110         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
9111         return (long)ret_conv;
9112 }
9113
9114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9115         LDKRevokeAndACK o_conv;
9116         o_conv.inner = (void*)(o & (~1));
9117         o_conv.is_owned = (o & 1) || (o == 0);
9118         o_conv = RevokeAndACK_clone(&o_conv);
9119         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9120         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
9121         return (long)ret_conv;
9122 }
9123
9124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9125         LDKDecodeError e_conv;
9126         e_conv.inner = (void*)(e & (~1));
9127         e_conv.is_owned = (e & 1) || (e == 0);
9128         e_conv = DecodeError_clone(&e_conv);
9129         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9130         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
9131         return (long)ret_conv;
9132 }
9133
9134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9135         if ((_res & 1) != 0) return;
9136         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
9137         FREE((void*)_res);
9138         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
9139 }
9140
9141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9142         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
9143         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9144         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
9145         return (long)ret_conv;
9146 }
9147
9148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9149         LDKShutdown o_conv;
9150         o_conv.inner = (void*)(o & (~1));
9151         o_conv.is_owned = (o & 1) || (o == 0);
9152         o_conv = Shutdown_clone(&o_conv);
9153         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9154         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
9155         return (long)ret_conv;
9156 }
9157
9158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9159         LDKDecodeError e_conv;
9160         e_conv.inner = (void*)(e & (~1));
9161         e_conv.is_owned = (e & 1) || (e == 0);
9162         e_conv = DecodeError_clone(&e_conv);
9163         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9164         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
9165         return (long)ret_conv;
9166 }
9167
9168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9169         if ((_res & 1) != 0) return;
9170         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
9171         FREE((void*)_res);
9172         CResult_ShutdownDecodeErrorZ_free(_res_conv);
9173 }
9174
9175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9176         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
9177         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9178         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
9179         return (long)ret_conv;
9180 }
9181
9182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9183         LDKUpdateFailHTLC o_conv;
9184         o_conv.inner = (void*)(o & (~1));
9185         o_conv.is_owned = (o & 1) || (o == 0);
9186         o_conv = UpdateFailHTLC_clone(&o_conv);
9187         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9188         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
9189         return (long)ret_conv;
9190 }
9191
9192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9193         LDKDecodeError e_conv;
9194         e_conv.inner = (void*)(e & (~1));
9195         e_conv.is_owned = (e & 1) || (e == 0);
9196         e_conv = DecodeError_clone(&e_conv);
9197         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9198         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
9199         return (long)ret_conv;
9200 }
9201
9202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9203         if ((_res & 1) != 0) return;
9204         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9205         FREE((void*)_res);
9206         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
9207 }
9208
9209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9210         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
9211         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9212         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
9213         return (long)ret_conv;
9214 }
9215
9216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9217         LDKUpdateFailMalformedHTLC o_conv;
9218         o_conv.inner = (void*)(o & (~1));
9219         o_conv.is_owned = (o & 1) || (o == 0);
9220         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
9221         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
9222         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
9223         return (long)ret_conv;
9224 }
9225
9226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9227         LDKDecodeError e_conv;
9228         e_conv.inner = (void*)(e & (~1));
9229         e_conv.is_owned = (e & 1) || (e == 0);
9230         e_conv = DecodeError_clone(&e_conv);
9231         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
9232         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
9233         return (long)ret_conv;
9234 }
9235
9236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9237         if ((_res & 1) != 0) return;
9238         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9239         FREE((void*)_res);
9240         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
9241 }
9242
9243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9244         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
9245         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
9246         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
9247         return (long)ret_conv;
9248 }
9249
9250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9251         LDKUpdateFee o_conv;
9252         o_conv.inner = (void*)(o & (~1));
9253         o_conv.is_owned = (o & 1) || (o == 0);
9254         o_conv = UpdateFee_clone(&o_conv);
9255         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
9256         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
9257         return (long)ret_conv;
9258 }
9259
9260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9261         LDKDecodeError e_conv;
9262         e_conv.inner = (void*)(e & (~1));
9263         e_conv.is_owned = (e & 1) || (e == 0);
9264         e_conv = DecodeError_clone(&e_conv);
9265         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
9266         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
9267         return (long)ret_conv;
9268 }
9269
9270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9271         if ((_res & 1) != 0) return;
9272         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9273         FREE((void*)_res);
9274         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
9275 }
9276
9277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9278         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
9279         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
9280         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
9281         return (long)ret_conv;
9282 }
9283
9284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9285         LDKUpdateFulfillHTLC o_conv;
9286         o_conv.inner = (void*)(o & (~1));
9287         o_conv.is_owned = (o & 1) || (o == 0);
9288         o_conv = UpdateFulfillHTLC_clone(&o_conv);
9289         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
9290         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
9291         return (long)ret_conv;
9292 }
9293
9294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9295         LDKDecodeError e_conv;
9296         e_conv.inner = (void*)(e & (~1));
9297         e_conv.is_owned = (e & 1) || (e == 0);
9298         e_conv = DecodeError_clone(&e_conv);
9299         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
9300         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
9301         return (long)ret_conv;
9302 }
9303
9304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9305         if ((_res & 1) != 0) return;
9306         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9307         FREE((void*)_res);
9308         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
9309 }
9310
9311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9312         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
9313         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
9314         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
9315         return (long)ret_conv;
9316 }
9317
9318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9319         LDKUpdateAddHTLC o_conv;
9320         o_conv.inner = (void*)(o & (~1));
9321         o_conv.is_owned = (o & 1) || (o == 0);
9322         o_conv = UpdateAddHTLC_clone(&o_conv);
9323         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
9324         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
9325         return (long)ret_conv;
9326 }
9327
9328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9329         LDKDecodeError e_conv;
9330         e_conv.inner = (void*)(e & (~1));
9331         e_conv.is_owned = (e & 1) || (e == 0);
9332         e_conv = DecodeError_clone(&e_conv);
9333         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
9334         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
9335         return (long)ret_conv;
9336 }
9337
9338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9339         if ((_res & 1) != 0) return;
9340         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9341         FREE((void*)_res);
9342         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
9343 }
9344
9345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9346         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
9347         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
9348         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
9349         return (long)ret_conv;
9350 }
9351
9352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9353         LDKPing o_conv;
9354         o_conv.inner = (void*)(o & (~1));
9355         o_conv.is_owned = (o & 1) || (o == 0);
9356         o_conv = Ping_clone(&o_conv);
9357         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
9358         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
9359         return (long)ret_conv;
9360 }
9361
9362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9363         LDKDecodeError e_conv;
9364         e_conv.inner = (void*)(e & (~1));
9365         e_conv.is_owned = (e & 1) || (e == 0);
9366         e_conv = DecodeError_clone(&e_conv);
9367         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
9368         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
9369         return (long)ret_conv;
9370 }
9371
9372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9373         if ((_res & 1) != 0) return;
9374         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
9375         FREE((void*)_res);
9376         CResult_PingDecodeErrorZ_free(_res_conv);
9377 }
9378
9379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9380         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
9381         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
9382         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
9383         return (long)ret_conv;
9384 }
9385
9386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9387         LDKPong o_conv;
9388         o_conv.inner = (void*)(o & (~1));
9389         o_conv.is_owned = (o & 1) || (o == 0);
9390         o_conv = Pong_clone(&o_conv);
9391         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
9392         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
9393         return (long)ret_conv;
9394 }
9395
9396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9397         LDKDecodeError e_conv;
9398         e_conv.inner = (void*)(e & (~1));
9399         e_conv.is_owned = (e & 1) || (e == 0);
9400         e_conv = DecodeError_clone(&e_conv);
9401         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
9402         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
9403         return (long)ret_conv;
9404 }
9405
9406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9407         if ((_res & 1) != 0) return;
9408         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
9409         FREE((void*)_res);
9410         CResult_PongDecodeErrorZ_free(_res_conv);
9411 }
9412
9413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9414         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
9415         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
9416         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
9417         return (long)ret_conv;
9418 }
9419
9420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9421         LDKUnsignedChannelAnnouncement o_conv;
9422         o_conv.inner = (void*)(o & (~1));
9423         o_conv.is_owned = (o & 1) || (o == 0);
9424         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
9425         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
9426         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
9427         return (long)ret_conv;
9428 }
9429
9430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9431         LDKDecodeError e_conv;
9432         e_conv.inner = (void*)(e & (~1));
9433         e_conv.is_owned = (e & 1) || (e == 0);
9434         e_conv = DecodeError_clone(&e_conv);
9435         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
9436         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
9437         return (long)ret_conv;
9438 }
9439
9440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9441         if ((_res & 1) != 0) return;
9442         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9443         FREE((void*)_res);
9444         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
9445 }
9446
9447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9448         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
9449         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
9450         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
9451         return (long)ret_conv;
9452 }
9453
9454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9455         LDKChannelAnnouncement o_conv;
9456         o_conv.inner = (void*)(o & (~1));
9457         o_conv.is_owned = (o & 1) || (o == 0);
9458         o_conv = ChannelAnnouncement_clone(&o_conv);
9459         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
9460         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
9461         return (long)ret_conv;
9462 }
9463
9464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9465         LDKDecodeError e_conv;
9466         e_conv.inner = (void*)(e & (~1));
9467         e_conv.is_owned = (e & 1) || (e == 0);
9468         e_conv = DecodeError_clone(&e_conv);
9469         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
9470         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
9471         return (long)ret_conv;
9472 }
9473
9474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9475         if ((_res & 1) != 0) return;
9476         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9477         FREE((void*)_res);
9478         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
9479 }
9480
9481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9482         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
9483         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
9484         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
9485         return (long)ret_conv;
9486 }
9487
9488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9489         LDKUnsignedChannelUpdate o_conv;
9490         o_conv.inner = (void*)(o & (~1));
9491         o_conv.is_owned = (o & 1) || (o == 0);
9492         o_conv = UnsignedChannelUpdate_clone(&o_conv);
9493         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
9494         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
9495         return (long)ret_conv;
9496 }
9497
9498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9499         LDKDecodeError e_conv;
9500         e_conv.inner = (void*)(e & (~1));
9501         e_conv.is_owned = (e & 1) || (e == 0);
9502         e_conv = DecodeError_clone(&e_conv);
9503         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
9504         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
9505         return (long)ret_conv;
9506 }
9507
9508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9509         if ((_res & 1) != 0) return;
9510         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
9511         FREE((void*)_res);
9512         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
9513 }
9514
9515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9516         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
9517         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
9518         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
9519         return (long)ret_conv;
9520 }
9521
9522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9523         LDKChannelUpdate o_conv;
9524         o_conv.inner = (void*)(o & (~1));
9525         o_conv.is_owned = (o & 1) || (o == 0);
9526         o_conv = ChannelUpdate_clone(&o_conv);
9527         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
9528         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
9529         return (long)ret_conv;
9530 }
9531
9532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9533         LDKDecodeError e_conv;
9534         e_conv.inner = (void*)(e & (~1));
9535         e_conv.is_owned = (e & 1) || (e == 0);
9536         e_conv = DecodeError_clone(&e_conv);
9537         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
9538         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
9539         return (long)ret_conv;
9540 }
9541
9542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9543         if ((_res & 1) != 0) return;
9544         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
9545         FREE((void*)_res);
9546         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
9547 }
9548
9549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9550         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
9551         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
9552         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
9553         return (long)ret_conv;
9554 }
9555
9556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9557         LDKErrorMessage o_conv;
9558         o_conv.inner = (void*)(o & (~1));
9559         o_conv.is_owned = (o & 1) || (o == 0);
9560         o_conv = ErrorMessage_clone(&o_conv);
9561         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
9562         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
9563         return (long)ret_conv;
9564 }
9565
9566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9567         LDKDecodeError e_conv;
9568         e_conv.inner = (void*)(e & (~1));
9569         e_conv.is_owned = (e & 1) || (e == 0);
9570         e_conv = DecodeError_clone(&e_conv);
9571         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
9572         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
9573         return (long)ret_conv;
9574 }
9575
9576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9577         if ((_res & 1) != 0) return;
9578         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
9579         FREE((void*)_res);
9580         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
9581 }
9582
9583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9584         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
9585         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
9586         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
9587         return (long)ret_conv;
9588 }
9589
9590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9591         LDKUnsignedNodeAnnouncement o_conv;
9592         o_conv.inner = (void*)(o & (~1));
9593         o_conv.is_owned = (o & 1) || (o == 0);
9594         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
9595         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
9596         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
9597         return (long)ret_conv;
9598 }
9599
9600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9601         LDKDecodeError e_conv;
9602         e_conv.inner = (void*)(e & (~1));
9603         e_conv.is_owned = (e & 1) || (e == 0);
9604         e_conv = DecodeError_clone(&e_conv);
9605         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
9606         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
9607         return (long)ret_conv;
9608 }
9609
9610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9611         if ((_res & 1) != 0) return;
9612         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9613         FREE((void*)_res);
9614         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
9615 }
9616
9617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9618         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
9619         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
9620         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
9621         return (long)ret_conv;
9622 }
9623
9624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9625         LDKNodeAnnouncement o_conv;
9626         o_conv.inner = (void*)(o & (~1));
9627         o_conv.is_owned = (o & 1) || (o == 0);
9628         o_conv = NodeAnnouncement_clone(&o_conv);
9629         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9630         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
9631         return (long)ret_conv;
9632 }
9633
9634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9635         LDKDecodeError e_conv;
9636         e_conv.inner = (void*)(e & (~1));
9637         e_conv.is_owned = (e & 1) || (e == 0);
9638         e_conv = DecodeError_clone(&e_conv);
9639         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9640         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
9641         return (long)ret_conv;
9642 }
9643
9644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9645         if ((_res & 1) != 0) return;
9646         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9647         FREE((void*)_res);
9648         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
9649 }
9650
9651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9652         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
9653         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9654         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
9655         return (long)ret_conv;
9656 }
9657
9658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9659         LDKQueryShortChannelIds o_conv;
9660         o_conv.inner = (void*)(o & (~1));
9661         o_conv.is_owned = (o & 1) || (o == 0);
9662         o_conv = QueryShortChannelIds_clone(&o_conv);
9663         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9664         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
9665         return (long)ret_conv;
9666 }
9667
9668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9669         LDKDecodeError e_conv;
9670         e_conv.inner = (void*)(e & (~1));
9671         e_conv.is_owned = (e & 1) || (e == 0);
9672         e_conv = DecodeError_clone(&e_conv);
9673         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9674         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
9675         return (long)ret_conv;
9676 }
9677
9678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9679         if ((_res & 1) != 0) return;
9680         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
9681         FREE((void*)_res);
9682         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
9683 }
9684
9685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9686         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
9687         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9688         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
9689         return (long)ret_conv;
9690 }
9691
9692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9693         LDKReplyShortChannelIdsEnd o_conv;
9694         o_conv.inner = (void*)(o & (~1));
9695         o_conv.is_owned = (o & 1) || (o == 0);
9696         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
9697         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9698         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
9699         return (long)ret_conv;
9700 }
9701
9702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9703         LDKDecodeError e_conv;
9704         e_conv.inner = (void*)(e & (~1));
9705         e_conv.is_owned = (e & 1) || (e == 0);
9706         e_conv = DecodeError_clone(&e_conv);
9707         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9708         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
9709         return (long)ret_conv;
9710 }
9711
9712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9713         if ((_res & 1) != 0) return;
9714         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
9715         FREE((void*)_res);
9716         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
9717 }
9718
9719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9720         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
9721         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9722         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
9723         return (long)ret_conv;
9724 }
9725
9726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9727         LDKQueryChannelRange o_conv;
9728         o_conv.inner = (void*)(o & (~1));
9729         o_conv.is_owned = (o & 1) || (o == 0);
9730         o_conv = QueryChannelRange_clone(&o_conv);
9731         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9732         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
9733         return (long)ret_conv;
9734 }
9735
9736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9737         LDKDecodeError e_conv;
9738         e_conv.inner = (void*)(e & (~1));
9739         e_conv.is_owned = (e & 1) || (e == 0);
9740         e_conv = DecodeError_clone(&e_conv);
9741         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9742         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
9743         return (long)ret_conv;
9744 }
9745
9746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9747         if ((_res & 1) != 0) return;
9748         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9749         FREE((void*)_res);
9750         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
9751 }
9752
9753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9754         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
9755         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9756         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
9757         return (long)ret_conv;
9758 }
9759
9760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9761         LDKReplyChannelRange o_conv;
9762         o_conv.inner = (void*)(o & (~1));
9763         o_conv.is_owned = (o & 1) || (o == 0);
9764         o_conv = ReplyChannelRange_clone(&o_conv);
9765         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
9766         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
9767         return (long)ret_conv;
9768 }
9769
9770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9771         LDKDecodeError e_conv;
9772         e_conv.inner = (void*)(e & (~1));
9773         e_conv.is_owned = (e & 1) || (e == 0);
9774         e_conv = DecodeError_clone(&e_conv);
9775         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
9776         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
9777         return (long)ret_conv;
9778 }
9779
9780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9781         if ((_res & 1) != 0) return;
9782         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9783         FREE((void*)_res);
9784         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
9785 }
9786
9787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9788         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
9789         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
9790         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
9791         return (long)ret_conv;
9792 }
9793
9794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9795         LDKGossipTimestampFilter o_conv;
9796         o_conv.inner = (void*)(o & (~1));
9797         o_conv.is_owned = (o & 1) || (o == 0);
9798         o_conv = GossipTimestampFilter_clone(&o_conv);
9799         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
9800         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
9801         return (long)ret_conv;
9802 }
9803
9804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9805         LDKDecodeError e_conv;
9806         e_conv.inner = (void*)(e & (~1));
9807         e_conv.is_owned = (e & 1) || (e == 0);
9808         e_conv = DecodeError_clone(&e_conv);
9809         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
9810         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
9811         return (long)ret_conv;
9812 }
9813
9814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9815         if ((_res & 1) != 0) return;
9816         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
9817         FREE((void*)_res);
9818         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
9819 }
9820
9821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9822         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
9823         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
9824         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
9825         return (long)ret_conv;
9826 }
9827
9828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9829         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
9830         FREE((void*)o);
9831         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9832         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
9833         return (long)ret_conv;
9834 }
9835
9836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9837         LDKDecodeError e_conv;
9838         e_conv.inner = (void*)(e & (~1));
9839         e_conv.is_owned = (e & 1) || (e == 0);
9840         e_conv = DecodeError_clone(&e_conv);
9841         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9842         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
9843         return (long)ret_conv;
9844 }
9845
9846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9847         if ((_res & 1) != 0) return;
9848         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
9849         FREE((void*)_res);
9850         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
9851 }
9852
9853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9854         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
9855         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9856         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
9857         return (long)ret_conv;
9858 }
9859
9860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9861         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
9862         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
9863         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
9864         return (long)ret_ref;
9865 }
9866
9867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
9868         LDKSignature a_ref;
9869         CHECK((*env)->GetArrayLength(env, a) == 64);
9870         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
9871         LDKCVec_SignatureZ b_constr;
9872         b_constr.datalen = (*env)->GetArrayLength(env, b);
9873         if (b_constr.datalen > 0)
9874                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9875         else
9876                 b_constr.data = NULL;
9877         for (size_t i = 0; i < b_constr.datalen; i++) {
9878                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
9879                 LDKSignature b_conv_8_ref;
9880                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
9881                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
9882                 b_constr.data[i] = b_conv_8_ref;
9883         }
9884         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
9885         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
9886         return (long)ret_ref;
9887 }
9888
9889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9890         if ((_res & 1) != 0) return;
9891         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
9892         FREE((void*)_res);
9893         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
9894 }
9895
9896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9897         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
9898         FREE((void*)o);
9899         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
9900         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
9901         return (long)ret_conv;
9902 }
9903
9904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
9905         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
9906         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
9907         return (long)ret_conv;
9908 }
9909
9910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9911         if ((_res & 1) != 0) return;
9912         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
9913         FREE((void*)_res);
9914         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
9915 }
9916
9917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9918         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
9919         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
9920         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
9921         return (long)ret_conv;
9922 }
9923
9924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9925         LDKSignature o_ref;
9926         CHECK((*env)->GetArrayLength(env, o) == 64);
9927         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
9928         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
9929         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
9930         return (long)ret_conv;
9931 }
9932
9933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
9934         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
9935         *ret_conv = CResult_SignatureNoneZ_err();
9936         return (long)ret_conv;
9937 }
9938
9939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9940         if ((_res & 1) != 0) return;
9941         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
9942         FREE((void*)_res);
9943         CResult_SignatureNoneZ_free(_res_conv);
9944 }
9945
9946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9947         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
9948         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
9949         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
9950         return (long)ret_conv;
9951 }
9952
9953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9954         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
9955         if (o_conv.free == LDKSign_JCalls_free) {
9956                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9957                 LDKSign_JCalls_clone(o_conv.this_arg);
9958         }
9959         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
9960         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
9961         return (long)ret_conv;
9962 }
9963
9964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9965         LDKDecodeError e_conv;
9966         e_conv.inner = (void*)(e & (~1));
9967         e_conv.is_owned = (e & 1) || (e == 0);
9968         e_conv = DecodeError_clone(&e_conv);
9969         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
9970         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
9971         return (long)ret_conv;
9972 }
9973
9974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9975         if ((_res & 1) != 0) return;
9976         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
9977         FREE((void*)_res);
9978         CResult_SignDecodeErrorZ_free(_res_conv);
9979 }
9980
9981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9982         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
9983         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
9984         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
9985         return (long)ret_conv;
9986 }
9987
9988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9989         LDKCVec_CVec_u8ZZ _res_constr;
9990         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9991         if (_res_constr.datalen > 0)
9992                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
9993         else
9994                 _res_constr.data = NULL;
9995         for (size_t i = 0; i < _res_constr.datalen; i++) {
9996                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9997                 LDKCVec_u8Z _res_conv_8_ref;
9998                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
9999                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10000                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
10001                 _res_constr.data[i] = _res_conv_8_ref;
10002         }
10003         CVec_CVec_u8ZZ_free(_res_constr);
10004 }
10005
10006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
10007         LDKCVec_CVec_u8ZZ o_constr;
10008         o_constr.datalen = (*env)->GetArrayLength(env, o);
10009         if (o_constr.datalen > 0)
10010                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10011         else
10012                 o_constr.data = NULL;
10013         for (size_t i = 0; i < o_constr.datalen; i++) {
10014                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
10015                 LDKCVec_u8Z o_conv_8_ref;
10016                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
10017                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10018                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
10019                 o_constr.data[i] = o_conv_8_ref;
10020         }
10021         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10022         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
10023         return (long)ret_conv;
10024 }
10025
10026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
10027         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10028         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
10029         return (long)ret_conv;
10030 }
10031
10032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10033         if ((_res & 1) != 0) return;
10034         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
10035         FREE((void*)_res);
10036         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
10037 }
10038
10039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10040         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
10041         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10042         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
10043         return (long)ret_conv;
10044 }
10045
10046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10047         LDKInMemorySigner o_conv;
10048         o_conv.inner = (void*)(o & (~1));
10049         o_conv.is_owned = (o & 1) || (o == 0);
10050         o_conv = InMemorySigner_clone(&o_conv);
10051         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10052         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
10053         return (long)ret_conv;
10054 }
10055
10056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10057         LDKDecodeError e_conv;
10058         e_conv.inner = (void*)(e & (~1));
10059         e_conv.is_owned = (e & 1) || (e == 0);
10060         e_conv = DecodeError_clone(&e_conv);
10061         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10062         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
10063         return (long)ret_conv;
10064 }
10065
10066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10067         if ((_res & 1) != 0) return;
10068         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
10069         FREE((void*)_res);
10070         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
10071 }
10072
10073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10074         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
10075         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10076         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
10077         return (long)ret_conv;
10078 }
10079
10080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10081         LDKCVec_TxOutZ _res_constr;
10082         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10083         if (_res_constr.datalen > 0)
10084                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10085         else
10086                 _res_constr.data = NULL;
10087         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10088         for (size_t h = 0; h < _res_constr.datalen; h++) {
10089                 int64_t _res_conv_7 = _res_vals[h];
10090                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
10091                 FREE((void*)_res_conv_7);
10092                 _res_constr.data[h] = _res_conv_7_conv;
10093         }
10094         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10095         CVec_TxOutZ_free(_res_constr);
10096 }
10097
10098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10099         LDKTransaction o_ref;
10100         o_ref.datalen = (*env)->GetArrayLength(env, o);
10101         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
10102         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
10103         o_ref.data_is_owned = true;
10104         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10105         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
10106         return (long)ret_conv;
10107 }
10108
10109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10110         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10111         *ret_conv = CResult_TransactionNoneZ_err();
10112         return (long)ret_conv;
10113 }
10114
10115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10116         if ((_res & 1) != 0) return;
10117         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
10118         FREE((void*)_res);
10119         CResult_TransactionNoneZ_free(_res_conv);
10120 }
10121
10122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
10123         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10124         *ret_conv = CResult_NoneErrorZ_ok();
10125         return (long)ret_conv;
10126 }
10127
10128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10129         LDKIOError e_conv = LDKIOError_from_java(env, e);
10130         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10131         *ret_conv = CResult_NoneErrorZ_err(e_conv);
10132         return (long)ret_conv;
10133 }
10134
10135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10136         if ((_res & 1) != 0) return;
10137         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
10138         FREE((void*)_res);
10139         CResult_NoneErrorZ_free(_res_conv);
10140 }
10141
10142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10143         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
10144         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10145         if (_res_constr.datalen > 0)
10146                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10147         else
10148                 _res_constr.data = NULL;
10149         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10150         for (size_t i = 0; i < _res_constr.datalen; i++) {
10151                 int64_t _res_conv_34 = _res_vals[i];
10152                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_34) & ~1);
10153                 FREE((void*)_res_conv_34);
10154                 _res_constr.data[i] = _res_conv_34_conv;
10155         }
10156         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10157         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
10158 }
10159
10160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
10161         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
10162         o_constr.datalen = (*env)->GetArrayLength(env, o);
10163         if (o_constr.datalen > 0)
10164                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10165         else
10166                 o_constr.data = NULL;
10167         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
10168         for (size_t i = 0; i < o_constr.datalen; i++) {
10169                 int64_t o_conv_34 = o_vals[i];
10170                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_34) & ~1);
10171                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
10172                 o_constr.data[i] = o_conv_34_conv;
10173         }
10174         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
10175         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10176         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
10177         return (long)ret_conv;
10178 }
10179
10180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10181         LDKIOError e_conv = LDKIOError_from_java(env, e);
10182         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10183         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
10184         return (long)ret_conv;
10185 }
10186
10187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10188         if ((_res & 1) != 0) return;
10189         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
10190         FREE((void*)_res);
10191         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
10192 }
10193
10194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
10195         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10196         *ret_conv = CResult_NoneAPIErrorZ_ok();
10197         return (long)ret_conv;
10198 }
10199
10200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10201         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10202         FREE((void*)e);
10203         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10204         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
10205         return (long)ret_conv;
10206 }
10207
10208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10209         if ((_res & 1) != 0) return;
10210         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
10211         FREE((void*)_res);
10212         CResult_NoneAPIErrorZ_free(_res_conv);
10213 }
10214
10215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10216         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
10217         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10218         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
10219         return (long)ret_conv;
10220 }
10221
10222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10223         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
10224         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10225         if (_res_constr.datalen > 0)
10226                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
10227         else
10228                 _res_constr.data = NULL;
10229         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10230         for (size_t w = 0; w < _res_constr.datalen; w++) {
10231                 int64_t _res_conv_22 = _res_vals[w];
10232                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
10233                 FREE((void*)_res_conv_22);
10234                 _res_constr.data[w] = _res_conv_22_conv;
10235         }
10236         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10237         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
10238 }
10239
10240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10241         LDKCVec_APIErrorZ _res_constr;
10242         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10243         if (_res_constr.datalen > 0)
10244                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
10245         else
10246                 _res_constr.data = NULL;
10247         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10248         for (size_t k = 0; k < _res_constr.datalen; k++) {
10249                 int64_t _res_conv_10 = _res_vals[k];
10250                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
10251                 FREE((void*)_res_conv_10);
10252                 _res_constr.data[k] = _res_conv_10_conv;
10253         }
10254         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10255         CVec_APIErrorZ_free(_res_constr);
10256 }
10257
10258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
10259         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10260         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
10261         return (long)ret_conv;
10262 }
10263
10264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10265         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10266         FREE((void*)e);
10267         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10268         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
10269         return (long)ret_conv;
10270 }
10271
10272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10273         if ((_res & 1) != 0) return;
10274         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10275         FREE((void*)_res);
10276         CResult_NonePaymentSendFailureZ_free(_res_conv);
10277 }
10278
10279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10280         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
10281         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10282         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
10283         return (long)ret_conv;
10284 }
10285
10286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10287         LDKCVec_ChannelMonitorZ _res_constr;
10288         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10289         if (_res_constr.datalen > 0)
10290                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
10291         else
10292                 _res_constr.data = NULL;
10293         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10294         for (size_t q = 0; q < _res_constr.datalen; q++) {
10295                 int64_t _res_conv_16 = _res_vals[q];
10296                 LDKChannelMonitor _res_conv_16_conv;
10297                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10298                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10299                 _res_constr.data[q] = _res_conv_16_conv;
10300         }
10301         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10302         CVec_ChannelMonitorZ_free(_res_constr);
10303 }
10304
10305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10306         LDKThirtyTwoBytes a_ref;
10307         CHECK((*env)->GetArrayLength(env, a) == 32);
10308         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10309         LDKChannelManager b_conv;
10310         b_conv.inner = (void*)(b & (~1));
10311         b_conv.is_owned = (b & 1) || (b == 0);
10312         // Warning: we need a move here but no clone is available for LDKChannelManager
10313         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
10314         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
10315         return (long)ret_ref;
10316 }
10317
10318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10319         if ((_res & 1) != 0) return;
10320         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
10321         FREE((void*)_res);
10322         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
10323 }
10324
10325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10326         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
10327         FREE((void*)o);
10328         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10329         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
10330         return (long)ret_conv;
10331 }
10332
10333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10334         LDKDecodeError e_conv;
10335         e_conv.inner = (void*)(e & (~1));
10336         e_conv.is_owned = (e & 1) || (e == 0);
10337         e_conv = DecodeError_clone(&e_conv);
10338         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10339         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
10340         return (long)ret_conv;
10341 }
10342
10343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10344         if ((_res & 1) != 0) return;
10345         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10346         FREE((void*)_res);
10347         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
10348 }
10349
10350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10351         if ((this_ptr & 1) != 0) return;
10352         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
10353         FREE((void*)this_ptr);
10354         Event_free(this_ptr_conv);
10355 }
10356
10357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10358         LDKEvent* orig_conv = (LDKEvent*)orig;
10359         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
10360         *ret_copy = Event_clone(orig_conv);
10361         long ret_ref = (long)ret_copy;
10362         return ret_ref;
10363 }
10364
10365 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
10366         LDKEvent* obj_conv = (LDKEvent*)obj;
10367         LDKCVec_u8Z ret_var = Event_write(obj_conv);
10368         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10369         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10370         CVec_u8Z_free(ret_var);
10371         return ret_arr;
10372 }
10373
10374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10375         if ((this_ptr & 1) != 0) return;
10376         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
10377         FREE((void*)this_ptr);
10378         MessageSendEvent_free(this_ptr_conv);
10379 }
10380
10381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10382         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
10383         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10384         *ret_copy = MessageSendEvent_clone(orig_conv);
10385         long ret_ref = (long)ret_copy;
10386         return ret_ref;
10387 }
10388
10389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10390         if ((this_ptr & 1) != 0) return;
10391         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
10392         FREE((void*)this_ptr);
10393         MessageSendEventsProvider_free(this_ptr_conv);
10394 }
10395
10396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10397         if ((this_ptr & 1) != 0) return;
10398         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
10399         FREE((void*)this_ptr);
10400         EventsProvider_free(this_ptr_conv);
10401 }
10402
10403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10404         if ((this_ptr & 1) != 0) return;
10405         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
10406         FREE((void*)this_ptr);
10407         APIError_free(this_ptr_conv);
10408 }
10409
10410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10411         LDKAPIError* orig_conv = (LDKAPIError*)orig;
10412         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
10413         *ret_copy = APIError_clone(orig_conv);
10414         long ret_ref = (long)ret_copy;
10415         return ret_ref;
10416 }
10417
10418 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10419         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
10420         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
10421         return ret_conv;
10422 }
10423
10424 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
10425         jclass ret_conv = LDKLevel_to_java(env, Level_max());
10426         return ret_conv;
10427 }
10428
10429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10430         if ((this_ptr & 1) != 0) return;
10431         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
10432         FREE((void*)this_ptr);
10433         Logger_free(this_ptr_conv);
10434 }
10435
10436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10437         LDKChannelHandshakeConfig this_obj_conv;
10438         this_obj_conv.inner = (void*)(this_obj & (~1));
10439         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10440         ChannelHandshakeConfig_free(this_obj_conv);
10441 }
10442
10443 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
10444         LDKChannelHandshakeConfig this_ptr_conv;
10445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10446         this_ptr_conv.is_owned = false;
10447         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
10448         return ret_val;
10449 }
10450
10451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
10452         LDKChannelHandshakeConfig this_ptr_conv;
10453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10454         this_ptr_conv.is_owned = false;
10455         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
10456 }
10457
10458 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
10459         LDKChannelHandshakeConfig this_ptr_conv;
10460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10461         this_ptr_conv.is_owned = false;
10462         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
10463         return ret_val;
10464 }
10465
10466 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) {
10467         LDKChannelHandshakeConfig this_ptr_conv;
10468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10469         this_ptr_conv.is_owned = false;
10470         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
10471 }
10472
10473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
10474         LDKChannelHandshakeConfig this_ptr_conv;
10475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10476         this_ptr_conv.is_owned = false;
10477         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
10478         return ret_val;
10479 }
10480
10481 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) {
10482         LDKChannelHandshakeConfig this_ptr_conv;
10483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10484         this_ptr_conv.is_owned = false;
10485         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
10486 }
10487
10488 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) {
10489         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
10490         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10491         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10492         long ret_ref = (long)ret_var.inner;
10493         if (ret_var.is_owned) {
10494                 ret_ref |= 1;
10495         }
10496         return ret_ref;
10497 }
10498
10499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10500         LDKChannelHandshakeConfig orig_conv;
10501         orig_conv.inner = (void*)(orig & (~1));
10502         orig_conv.is_owned = false;
10503         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
10504         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10505         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10506         long ret_ref = (long)ret_var.inner;
10507         if (ret_var.is_owned) {
10508                 ret_ref |= 1;
10509         }
10510         return ret_ref;
10511 }
10512
10513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
10514         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
10515         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10516         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10517         long ret_ref = (long)ret_var.inner;
10518         if (ret_var.is_owned) {
10519                 ret_ref |= 1;
10520         }
10521         return ret_ref;
10522 }
10523
10524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10525         LDKChannelHandshakeLimits this_obj_conv;
10526         this_obj_conv.inner = (void*)(this_obj & (~1));
10527         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10528         ChannelHandshakeLimits_free(this_obj_conv);
10529 }
10530
10531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10532         LDKChannelHandshakeLimits this_ptr_conv;
10533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10534         this_ptr_conv.is_owned = false;
10535         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
10536         return ret_val;
10537 }
10538
10539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10540         LDKChannelHandshakeLimits this_ptr_conv;
10541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10542         this_ptr_conv.is_owned = false;
10543         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
10544 }
10545
10546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
10547         LDKChannelHandshakeLimits this_ptr_conv;
10548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10549         this_ptr_conv.is_owned = false;
10550         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
10551         return ret_val;
10552 }
10553
10554 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) {
10555         LDKChannelHandshakeLimits this_ptr_conv;
10556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10557         this_ptr_conv.is_owned = false;
10558         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
10559 }
10560
10561 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) {
10562         LDKChannelHandshakeLimits this_ptr_conv;
10563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10564         this_ptr_conv.is_owned = false;
10565         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
10566         return ret_val;
10567 }
10568
10569 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) {
10570         LDKChannelHandshakeLimits this_ptr_conv;
10571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10572         this_ptr_conv.is_owned = false;
10573         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
10574 }
10575
10576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10577         LDKChannelHandshakeLimits this_ptr_conv;
10578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10579         this_ptr_conv.is_owned = false;
10580         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
10581         return ret_val;
10582 }
10583
10584 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) {
10585         LDKChannelHandshakeLimits this_ptr_conv;
10586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10587         this_ptr_conv.is_owned = false;
10588         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
10589 }
10590
10591 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
10592         LDKChannelHandshakeLimits this_ptr_conv;
10593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10594         this_ptr_conv.is_owned = false;
10595         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
10596         return ret_val;
10597 }
10598
10599 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) {
10600         LDKChannelHandshakeLimits this_ptr_conv;
10601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10602         this_ptr_conv.is_owned = false;
10603         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
10604 }
10605
10606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10607         LDKChannelHandshakeLimits this_ptr_conv;
10608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10609         this_ptr_conv.is_owned = false;
10610         int64_t ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
10611         return ret_val;
10612 }
10613
10614 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) {
10615         LDKChannelHandshakeLimits this_ptr_conv;
10616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10617         this_ptr_conv.is_owned = false;
10618         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
10619 }
10620
10621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10622         LDKChannelHandshakeLimits this_ptr_conv;
10623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10624         this_ptr_conv.is_owned = false;
10625         int64_t ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
10626         return ret_val;
10627 }
10628
10629 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) {
10630         LDKChannelHandshakeLimits this_ptr_conv;
10631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10632         this_ptr_conv.is_owned = false;
10633         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
10634 }
10635
10636 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
10637         LDKChannelHandshakeLimits this_ptr_conv;
10638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10639         this_ptr_conv.is_owned = false;
10640         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
10641         return ret_val;
10642 }
10643
10644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
10645         LDKChannelHandshakeLimits this_ptr_conv;
10646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10647         this_ptr_conv.is_owned = false;
10648         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
10649 }
10650
10651 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
10652         LDKChannelHandshakeLimits this_ptr_conv;
10653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10654         this_ptr_conv.is_owned = false;
10655         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
10656         return ret_val;
10657 }
10658
10659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
10660         LDKChannelHandshakeLimits this_ptr_conv;
10661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10662         this_ptr_conv.is_owned = false;
10663         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
10664 }
10665
10666 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
10667         LDKChannelHandshakeLimits this_ptr_conv;
10668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10669         this_ptr_conv.is_owned = false;
10670         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
10671         return ret_val;
10672 }
10673
10674 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) {
10675         LDKChannelHandshakeLimits this_ptr_conv;
10676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10677         this_ptr_conv.is_owned = false;
10678         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
10679 }
10680
10681 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) {
10682         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);
10683         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10684         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10685         long ret_ref = (long)ret_var.inner;
10686         if (ret_var.is_owned) {
10687                 ret_ref |= 1;
10688         }
10689         return ret_ref;
10690 }
10691
10692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10693         LDKChannelHandshakeLimits orig_conv;
10694         orig_conv.inner = (void*)(orig & (~1));
10695         orig_conv.is_owned = false;
10696         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
10697         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10698         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10699         long ret_ref = (long)ret_var.inner;
10700         if (ret_var.is_owned) {
10701                 ret_ref |= 1;
10702         }
10703         return ret_ref;
10704 }
10705
10706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
10707         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
10708         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10709         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10710         long ret_ref = (long)ret_var.inner;
10711         if (ret_var.is_owned) {
10712                 ret_ref |= 1;
10713         }
10714         return ret_ref;
10715 }
10716
10717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10718         LDKChannelConfig this_obj_conv;
10719         this_obj_conv.inner = (void*)(this_obj & (~1));
10720         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10721         ChannelConfig_free(this_obj_conv);
10722 }
10723
10724 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
10725         LDKChannelConfig this_ptr_conv;
10726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10727         this_ptr_conv.is_owned = false;
10728         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
10729         return ret_val;
10730 }
10731
10732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
10733         LDKChannelConfig this_ptr_conv;
10734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10735         this_ptr_conv.is_owned = false;
10736         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
10737 }
10738
10739 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
10740         LDKChannelConfig this_ptr_conv;
10741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10742         this_ptr_conv.is_owned = false;
10743         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
10744         return ret_val;
10745 }
10746
10747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
10748         LDKChannelConfig this_ptr_conv;
10749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10750         this_ptr_conv.is_owned = false;
10751         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
10752 }
10753
10754 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
10755         LDKChannelConfig this_ptr_conv;
10756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10757         this_ptr_conv.is_owned = false;
10758         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
10759         return ret_val;
10760 }
10761
10762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
10763         LDKChannelConfig this_ptr_conv;
10764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10765         this_ptr_conv.is_owned = false;
10766         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
10767 }
10768
10769 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
10770         LDKChannelConfig this_ptr_conv;
10771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10772         this_ptr_conv.is_owned = false;
10773         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
10774         return ret_val;
10775 }
10776
10777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
10778         LDKChannelConfig this_ptr_conv;
10779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10780         this_ptr_conv.is_owned = false;
10781         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
10782 }
10783
10784 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) {
10785         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
10786         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10787         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10788         long ret_ref = (long)ret_var.inner;
10789         if (ret_var.is_owned) {
10790                 ret_ref |= 1;
10791         }
10792         return ret_ref;
10793 }
10794
10795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10796         LDKChannelConfig orig_conv;
10797         orig_conv.inner = (void*)(orig & (~1));
10798         orig_conv.is_owned = false;
10799         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
10800         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10801         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10802         long ret_ref = (long)ret_var.inner;
10803         if (ret_var.is_owned) {
10804                 ret_ref |= 1;
10805         }
10806         return ret_ref;
10807 }
10808
10809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
10810         LDKChannelConfig ret_var = ChannelConfig_default();
10811         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10812         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10813         long ret_ref = (long)ret_var.inner;
10814         if (ret_var.is_owned) {
10815                 ret_ref |= 1;
10816         }
10817         return ret_ref;
10818 }
10819
10820 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
10821         LDKChannelConfig obj_conv;
10822         obj_conv.inner = (void*)(obj & (~1));
10823         obj_conv.is_owned = false;
10824         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
10825         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10826         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10827         CVec_u8Z_free(ret_var);
10828         return ret_arr;
10829 }
10830
10831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10832         LDKu8slice ser_ref;
10833         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10834         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10835         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10836         *ret_conv = ChannelConfig_read(ser_ref);
10837         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10838         return (long)ret_conv;
10839 }
10840
10841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
10842         LDKUserConfig this_obj_conv;
10843         this_obj_conv.inner = (void*)(this_obj & (~1));
10844         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10845         UserConfig_free(this_obj_conv);
10846 }
10847
10848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
10849         LDKUserConfig this_ptr_conv;
10850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10851         this_ptr_conv.is_owned = false;
10852         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
10853         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10854         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10855         long ret_ref = (long)ret_var.inner;
10856         if (ret_var.is_owned) {
10857                 ret_ref |= 1;
10858         }
10859         return ret_ref;
10860 }
10861
10862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10863         LDKUserConfig this_ptr_conv;
10864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10865         this_ptr_conv.is_owned = false;
10866         LDKChannelHandshakeConfig val_conv;
10867         val_conv.inner = (void*)(val & (~1));
10868         val_conv.is_owned = (val & 1) || (val == 0);
10869         val_conv = ChannelHandshakeConfig_clone(&val_conv);
10870         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
10871 }
10872
10873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
10874         LDKUserConfig this_ptr_conv;
10875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10876         this_ptr_conv.is_owned = false;
10877         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
10878         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10879         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10880         long ret_ref = (long)ret_var.inner;
10881         if (ret_var.is_owned) {
10882                 ret_ref |= 1;
10883         }
10884         return ret_ref;
10885 }
10886
10887 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) {
10888         LDKUserConfig this_ptr_conv;
10889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10890         this_ptr_conv.is_owned = false;
10891         LDKChannelHandshakeLimits val_conv;
10892         val_conv.inner = (void*)(val & (~1));
10893         val_conv.is_owned = (val & 1) || (val == 0);
10894         val_conv = ChannelHandshakeLimits_clone(&val_conv);
10895         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
10896 }
10897
10898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
10899         LDKUserConfig this_ptr_conv;
10900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10901         this_ptr_conv.is_owned = false;
10902         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
10903         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10904         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10905         long ret_ref = (long)ret_var.inner;
10906         if (ret_var.is_owned) {
10907                 ret_ref |= 1;
10908         }
10909         return ret_ref;
10910 }
10911
10912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10913         LDKUserConfig this_ptr_conv;
10914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10915         this_ptr_conv.is_owned = false;
10916         LDKChannelConfig val_conv;
10917         val_conv.inner = (void*)(val & (~1));
10918         val_conv.is_owned = (val & 1) || (val == 0);
10919         val_conv = ChannelConfig_clone(&val_conv);
10920         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
10921 }
10922
10923 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) {
10924         LDKChannelHandshakeConfig own_channel_config_arg_conv;
10925         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
10926         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
10927         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
10928         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
10929         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
10930         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
10931         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
10932         LDKChannelConfig channel_options_arg_conv;
10933         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
10934         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
10935         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
10936         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
10937         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10938         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10939         long ret_ref = (long)ret_var.inner;
10940         if (ret_var.is_owned) {
10941                 ret_ref |= 1;
10942         }
10943         return ret_ref;
10944 }
10945
10946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10947         LDKUserConfig orig_conv;
10948         orig_conv.inner = (void*)(orig & (~1));
10949         orig_conv.is_owned = false;
10950         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
10951         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10952         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10953         long ret_ref = (long)ret_var.inner;
10954         if (ret_var.is_owned) {
10955                 ret_ref |= 1;
10956         }
10957         return ret_ref;
10958 }
10959
10960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
10961         LDKUserConfig ret_var = UserConfig_default();
10962         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10963         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10964         long ret_ref = (long)ret_var.inner;
10965         if (ret_var.is_owned) {
10966                 ret_ref |= 1;
10967         }
10968         return ret_ref;
10969 }
10970
10971 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10972         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
10973         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
10974         return ret_conv;
10975 }
10976
10977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10978         if ((this_ptr & 1) != 0) return;
10979         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
10980         FREE((void*)this_ptr);
10981         Access_free(this_ptr_conv);
10982 }
10983
10984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10985         if ((this_ptr & 1) != 0) return;
10986         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
10987         FREE((void*)this_ptr);
10988         Listen_free(this_ptr_conv);
10989 }
10990
10991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10992         if ((this_ptr & 1) != 0) return;
10993         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
10994         FREE((void*)this_ptr);
10995         Watch_free(this_ptr_conv);
10996 }
10997
10998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10999         if ((this_ptr & 1) != 0) return;
11000         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
11001         FREE((void*)this_ptr);
11002         Filter_free(this_ptr_conv);
11003 }
11004
11005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11006         LDKWatchedOutput this_obj_conv;
11007         this_obj_conv.inner = (void*)(this_obj & (~1));
11008         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11009         WatchedOutput_free(this_obj_conv);
11010 }
11011
11012 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
11013         LDKWatchedOutput this_ptr_conv;
11014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11015         this_ptr_conv.is_owned = false;
11016         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11017         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
11018         return ret_arr;
11019 }
11020
11021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11022         LDKWatchedOutput this_ptr_conv;
11023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11024         this_ptr_conv.is_owned = false;
11025         LDKThirtyTwoBytes val_ref;
11026         CHECK((*env)->GetArrayLength(env, val) == 32);
11027         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11028         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
11029 }
11030
11031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
11032         LDKWatchedOutput this_ptr_conv;
11033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11034         this_ptr_conv.is_owned = false;
11035         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
11036         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11037         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11038         long ret_ref = (long)ret_var.inner;
11039         if (ret_var.is_owned) {
11040                 ret_ref |= 1;
11041         }
11042         return ret_ref;
11043 }
11044
11045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11046         LDKWatchedOutput this_ptr_conv;
11047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11048         this_ptr_conv.is_owned = false;
11049         LDKOutPoint val_conv;
11050         val_conv.inner = (void*)(val & (~1));
11051         val_conv.is_owned = (val & 1) || (val == 0);
11052         val_conv = OutPoint_clone(&val_conv);
11053         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
11054 }
11055
11056 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
11057         LDKWatchedOutput this_ptr_conv;
11058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11059         this_ptr_conv.is_owned = false;
11060         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
11061         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11062         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11063         return ret_arr;
11064 }
11065
11066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11067         LDKWatchedOutput this_ptr_conv;
11068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11069         this_ptr_conv.is_owned = false;
11070         LDKCVec_u8Z val_ref;
11071         val_ref.datalen = (*env)->GetArrayLength(env, val);
11072         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
11073         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
11074         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
11075 }
11076
11077 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) {
11078         LDKThirtyTwoBytes block_hash_arg_ref;
11079         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
11080         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
11081         LDKOutPoint outpoint_arg_conv;
11082         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
11083         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
11084         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
11085         LDKCVec_u8Z script_pubkey_arg_ref;
11086         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
11087         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
11088         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
11089         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
11090         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11091         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11092         long ret_ref = (long)ret_var.inner;
11093         if (ret_var.is_owned) {
11094                 ret_ref |= 1;
11095         }
11096         return ret_ref;
11097 }
11098
11099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11100         if ((this_ptr & 1) != 0) return;
11101         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
11102         FREE((void*)this_ptr);
11103         BroadcasterInterface_free(this_ptr_conv);
11104 }
11105
11106 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11107         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
11108         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
11109         return ret_conv;
11110 }
11111
11112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11113         if ((this_ptr & 1) != 0) return;
11114         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
11115         FREE((void*)this_ptr);
11116         FeeEstimator_free(this_ptr_conv);
11117 }
11118
11119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11120         LDKChainMonitor this_obj_conv;
11121         this_obj_conv.inner = (void*)(this_obj & (~1));
11122         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11123         ChainMonitor_free(this_obj_conv);
11124 }
11125
11126 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) {
11127         LDKChainMonitor this_arg_conv;
11128         this_arg_conv.inner = (void*)(this_arg & (~1));
11129         this_arg_conv.is_owned = false;
11130         unsigned char header_arr[80];
11131         CHECK((*env)->GetArrayLength(env, header) == 80);
11132         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11133         unsigned char (*header_ref)[80] = &header_arr;
11134         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11135         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11136         if (txdata_constr.datalen > 0)
11137                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11138         else
11139                 txdata_constr.data = NULL;
11140         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11141         for (size_t y = 0; y < txdata_constr.datalen; y++) {
11142                 int64_t txdata_conv_24 = txdata_vals[y];
11143                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
11144                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
11145                 txdata_constr.data[y] = txdata_conv_24_conv;
11146         }
11147         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11148         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
11149 }
11150
11151 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) {
11152         LDKChainMonitor this_arg_conv;
11153         this_arg_conv.inner = (void*)(this_arg & (~1));
11154         this_arg_conv.is_owned = false;
11155         unsigned char header_arr[80];
11156         CHECK((*env)->GetArrayLength(env, header) == 80);
11157         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11158         unsigned char (*header_ref)[80] = &header_arr;
11159         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11160         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11161         if (txdata_constr.datalen > 0)
11162                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11163         else
11164                 txdata_constr.data = NULL;
11165         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11166         for (size_t y = 0; y < txdata_constr.datalen; y++) {
11167                 int64_t txdata_conv_24 = txdata_vals[y];
11168                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
11169                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
11170                 txdata_constr.data[y] = txdata_conv_24_conv;
11171         }
11172         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11173         ChainMonitor_transactions_confirmed(&this_arg_conv, header_ref, txdata_constr, height);
11174 }
11175
11176 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) {
11177         LDKChainMonitor this_arg_conv;
11178         this_arg_conv.inner = (void*)(this_arg & (~1));
11179         this_arg_conv.is_owned = false;
11180         unsigned char header_arr[80];
11181         CHECK((*env)->GetArrayLength(env, header) == 80);
11182         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11183         unsigned char (*header_ref)[80] = &header_arr;
11184         ChainMonitor_update_best_block(&this_arg_conv, header_ref, height);
11185 }
11186
11187 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) {
11188         LDKChainMonitor this_arg_conv;
11189         this_arg_conv.inner = (void*)(this_arg & (~1));
11190         this_arg_conv.is_owned = false;
11191         unsigned char header_arr[80];
11192         CHECK((*env)->GetArrayLength(env, header) == 80);
11193         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11194         unsigned char (*header_ref)[80] = &header_arr;
11195         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
11196 }
11197
11198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
11199         LDKChainMonitor this_arg_conv;
11200         this_arg_conv.inner = (void*)(this_arg & (~1));
11201         this_arg_conv.is_owned = false;
11202         unsigned char txid_arr[32];
11203         CHECK((*env)->GetArrayLength(env, txid) == 32);
11204         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11205         unsigned char (*txid_ref)[32] = &txid_arr;
11206         ChainMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref);
11207 }
11208
11209 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
11210         LDKChainMonitor this_arg_conv;
11211         this_arg_conv.inner = (void*)(this_arg & (~1));
11212         this_arg_conv.is_owned = false;
11213         LDKCVec_TxidZ ret_var = ChainMonitor_get_relevant_txids(&this_arg_conv);
11214         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11215         ;
11216         for (size_t i = 0; i < ret_var.datalen; i++) {
11217                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
11218                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
11219                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11220         }
11221         FREE(ret_var.data);
11222         return ret_arr;
11223 }
11224
11225 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) {
11226         LDKFilter *chain_source_conv_ptr = NULL;
11227         if (chain_source != 0) {
11228                 LDKFilter chain_source_conv;
11229                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
11230                 if (chain_source_conv.free == LDKFilter_JCalls_free) {
11231                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11232                         LDKFilter_JCalls_clone(chain_source_conv.this_arg);
11233                 }
11234                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
11235                 *chain_source_conv_ptr = chain_source_conv;
11236         }
11237         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11238         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11239                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11240                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
11241         }
11242         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11243         if (logger_conv.free == LDKLogger_JCalls_free) {
11244                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11245                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11246         }
11247         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
11248         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
11249                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11250                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
11251         }
11252         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
11253         if (persister_conv.free == LDKPersist_JCalls_free) {
11254                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11255                 LDKPersist_JCalls_clone(persister_conv.this_arg);
11256         }
11257         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
11258         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11259         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11260         long ret_ref = (long)ret_var.inner;
11261         if (ret_var.is_owned) {
11262                 ret_ref |= 1;
11263         }
11264         return ret_ref;
11265 }
11266
11267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
11268         LDKChainMonitor this_arg_conv;
11269         this_arg_conv.inner = (void*)(this_arg & (~1));
11270         this_arg_conv.is_owned = false;
11271         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
11272         *ret = ChainMonitor_as_Watch(&this_arg_conv);
11273         return (long)ret;
11274 }
11275
11276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
11277         LDKChainMonitor this_arg_conv;
11278         this_arg_conv.inner = (void*)(this_arg & (~1));
11279         this_arg_conv.is_owned = false;
11280         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
11281         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
11282         return (long)ret;
11283 }
11284
11285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11286         LDKChannelMonitorUpdate this_obj_conv;
11287         this_obj_conv.inner = (void*)(this_obj & (~1));
11288         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11289         ChannelMonitorUpdate_free(this_obj_conv);
11290 }
11291
11292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11293         LDKChannelMonitorUpdate this_ptr_conv;
11294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11295         this_ptr_conv.is_owned = false;
11296         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
11297         return ret_val;
11298 }
11299
11300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11301         LDKChannelMonitorUpdate this_ptr_conv;
11302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11303         this_ptr_conv.is_owned = false;
11304         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
11305 }
11306
11307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11308         LDKChannelMonitorUpdate orig_conv;
11309         orig_conv.inner = (void*)(orig & (~1));
11310         orig_conv.is_owned = false;
11311         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
11312         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11313         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11314         long ret_ref = (long)ret_var.inner;
11315         if (ret_var.is_owned) {
11316                 ret_ref |= 1;
11317         }
11318         return ret_ref;
11319 }
11320
11321 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
11322         LDKChannelMonitorUpdate obj_conv;
11323         obj_conv.inner = (void*)(obj & (~1));
11324         obj_conv.is_owned = false;
11325         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
11326         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11327         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11328         CVec_u8Z_free(ret_var);
11329         return ret_arr;
11330 }
11331
11332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
11333         LDKu8slice ser_ref;
11334         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11335         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11336         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11337         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
11338         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11339         return (long)ret_conv;
11340 }
11341
11342 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11343         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
11344         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
11345         return ret_conv;
11346 }
11347
11348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11349         LDKMonitorUpdateError this_obj_conv;
11350         this_obj_conv.inner = (void*)(this_obj & (~1));
11351         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11352         MonitorUpdateError_free(this_obj_conv);
11353 }
11354
11355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11356         LDKMonitorUpdateError orig_conv;
11357         orig_conv.inner = (void*)(orig & (~1));
11358         orig_conv.is_owned = false;
11359         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
11360         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11361         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11362         long ret_ref = (long)ret_var.inner;
11363         if (ret_var.is_owned) {
11364                 ret_ref |= 1;
11365         }
11366         return ret_ref;
11367 }
11368
11369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11370         if ((this_ptr & 1) != 0) return;
11371         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
11372         FREE((void*)this_ptr);
11373         MonitorEvent_free(this_ptr_conv);
11374 }
11375
11376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11377         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
11378         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
11379         *ret_copy = MonitorEvent_clone(orig_conv);
11380         long ret_ref = (long)ret_copy;
11381         return ret_ref;
11382 }
11383
11384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11385         LDKHTLCUpdate this_obj_conv;
11386         this_obj_conv.inner = (void*)(this_obj & (~1));
11387         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11388         HTLCUpdate_free(this_obj_conv);
11389 }
11390
11391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11392         LDKHTLCUpdate orig_conv;
11393         orig_conv.inner = (void*)(orig & (~1));
11394         orig_conv.is_owned = false;
11395         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
11396         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11397         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11398         long ret_ref = (long)ret_var.inner;
11399         if (ret_var.is_owned) {
11400                 ret_ref |= 1;
11401         }
11402         return ret_ref;
11403 }
11404
11405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
11406         LDKHTLCUpdate obj_conv;
11407         obj_conv.inner = (void*)(obj & (~1));
11408         obj_conv.is_owned = false;
11409         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
11410         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11411         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11412         CVec_u8Z_free(ret_var);
11413         return ret_arr;
11414 }
11415
11416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
11417         LDKu8slice ser_ref;
11418         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11419         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11420         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11421         *ret_conv = HTLCUpdate_read(ser_ref);
11422         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11423         return (long)ret_conv;
11424 }
11425
11426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11427         LDKChannelMonitor this_obj_conv;
11428         this_obj_conv.inner = (void*)(this_obj & (~1));
11429         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11430         ChannelMonitor_free(this_obj_conv);
11431 }
11432
11433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11434         LDKChannelMonitor orig_conv;
11435         orig_conv.inner = (void*)(orig & (~1));
11436         orig_conv.is_owned = false;
11437         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
11438         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11439         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11440         long ret_ref = (long)ret_var.inner;
11441         if (ret_var.is_owned) {
11442                 ret_ref |= 1;
11443         }
11444         return ret_ref;
11445 }
11446
11447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
11448         LDKChannelMonitor obj_conv;
11449         obj_conv.inner = (void*)(obj & (~1));
11450         obj_conv.is_owned = false;
11451         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
11452         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11453         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11454         CVec_u8Z_free(ret_var);
11455         return ret_arr;
11456 }
11457
11458 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) {
11459         LDKChannelMonitor this_arg_conv;
11460         this_arg_conv.inner = (void*)(this_arg & (~1));
11461         this_arg_conv.is_owned = false;
11462         LDKChannelMonitorUpdate updates_conv;
11463         updates_conv.inner = (void*)(updates & (~1));
11464         updates_conv.is_owned = false;
11465         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11466         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11467         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
11468         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11469         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
11470         return (long)ret_conv;
11471 }
11472
11473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
11474         LDKChannelMonitor this_arg_conv;
11475         this_arg_conv.inner = (void*)(this_arg & (~1));
11476         this_arg_conv.is_owned = false;
11477         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
11478         return ret_val;
11479 }
11480
11481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
11482         LDKChannelMonitor this_arg_conv;
11483         this_arg_conv.inner = (void*)(this_arg & (~1));
11484         this_arg_conv.is_owned = false;
11485         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11486         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
11487         return (long)ret_ref;
11488 }
11489
11490 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
11491         LDKChannelMonitor this_arg_conv;
11492         this_arg_conv.inner = (void*)(this_arg & (~1));
11493         this_arg_conv.is_owned = false;
11494         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
11495         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11496         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11497         for (size_t v = 0; v < ret_var.datalen; v++) {
11498                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_47_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11499                 *ret_conv_47_ref = ret_var.data[v];
11500                 ret_arr_ptr[v] = (long)ret_conv_47_ref;
11501         }
11502         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11503         FREE(ret_var.data);
11504         return ret_arr;
11505 }
11506
11507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
11508         LDKChannelMonitor this_arg_conv;
11509         this_arg_conv.inner = (void*)(this_arg & (~1));
11510         this_arg_conv.is_owned = false;
11511         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
11512         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
11513 }
11514
11515 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
11516         LDKChannelMonitor this_arg_conv;
11517         this_arg_conv.inner = (void*)(this_arg & (~1));
11518         this_arg_conv.is_owned = false;
11519         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
11520         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11521         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11522         for (size_t o = 0; o < ret_var.datalen; o++) {
11523                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
11524                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
11525                 long ret_conv_14_ref = (long)ret_conv_14_copy;
11526                 ret_arr_ptr[o] = ret_conv_14_ref;
11527         }
11528         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11529         FREE(ret_var.data);
11530         return ret_arr;
11531 }
11532
11533 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
11534         LDKChannelMonitor this_arg_conv;
11535         this_arg_conv.inner = (void*)(this_arg & (~1));
11536         this_arg_conv.is_owned = false;
11537         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
11538         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11539         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11540         for (size_t h = 0; h < ret_var.datalen; h++) {
11541                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11542                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
11543                 long ret_conv_7_ref = (long)ret_conv_7_copy;
11544                 ret_arr_ptr[h] = ret_conv_7_ref;
11545         }
11546         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11547         FREE(ret_var.data);
11548         return ret_arr;
11549 }
11550
11551 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) {
11552         LDKChannelMonitor this_arg_conv;
11553         this_arg_conv.inner = (void*)(this_arg & (~1));
11554         this_arg_conv.is_owned = false;
11555         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
11556         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
11557         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11558         ;
11559         for (size_t i = 0; i < ret_var.datalen; i++) {
11560                 LDKTransaction ret_conv_8_var = ret_var.data[i];
11561                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
11562                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
11563                 Transaction_free(ret_conv_8_var);
11564                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11565         }
11566         FREE(ret_var.data);
11567         return ret_arr;
11568 }
11569
11570 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) {
11571         LDKChannelMonitor this_arg_conv;
11572         this_arg_conv.inner = (void*)(this_arg & (~1));
11573         this_arg_conv.is_owned = false;
11574         unsigned char header_arr[80];
11575         CHECK((*env)->GetArrayLength(env, header) == 80);
11576         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11577         unsigned char (*header_ref)[80] = &header_arr;
11578         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11579         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11580         if (txdata_constr.datalen > 0)
11581                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11582         else
11583                 txdata_constr.data = NULL;
11584         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11585         for (size_t y = 0; y < txdata_constr.datalen; y++) {
11586                 int64_t txdata_conv_24 = txdata_vals[y];
11587                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
11588                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
11589                 txdata_constr.data[y] = txdata_conv_24_conv;
11590         }
11591         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11592         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11593         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11594                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11595                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
11596         }
11597         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11598         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
11599                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11600                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
11601         }
11602         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11603         if (logger_conv.free == LDKLogger_JCalls_free) {
11604                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11605                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11606         }
11607         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);
11608         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11609         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11610         for (size_t u = 0; u < ret_var.datalen; u++) {
11611                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11612                 *ret_conv_46_ref = ret_var.data[u];
11613                 ret_arr_ptr[u] = (long)ret_conv_46_ref;
11614         }
11615         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11616         FREE(ret_var.data);
11617         return ret_arr;
11618 }
11619
11620 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) {
11621         LDKChannelMonitor this_arg_conv;
11622         this_arg_conv.inner = (void*)(this_arg & (~1));
11623         this_arg_conv.is_owned = false;
11624         unsigned char header_arr[80];
11625         CHECK((*env)->GetArrayLength(env, header) == 80);
11626         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11627         unsigned char (*header_ref)[80] = &header_arr;
11628         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11629         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11630                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11631                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
11632         }
11633         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11634         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
11635                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11636                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
11637         }
11638         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11639         if (logger_conv.free == LDKLogger_JCalls_free) {
11640                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11641                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11642         }
11643         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
11644 }
11645
11646 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) {
11647         LDKChannelMonitor this_arg_conv;
11648         this_arg_conv.inner = (void*)(this_arg & (~1));
11649         this_arg_conv.is_owned = false;
11650         unsigned char header_arr[80];
11651         CHECK((*env)->GetArrayLength(env, header) == 80);
11652         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11653         unsigned char (*header_ref)[80] = &header_arr;
11654         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11655         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11656         if (txdata_constr.datalen > 0)
11657                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11658         else
11659                 txdata_constr.data = NULL;
11660         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11661         for (size_t y = 0; y < txdata_constr.datalen; y++) {
11662                 int64_t txdata_conv_24 = txdata_vals[y];
11663                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
11664                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
11665                 txdata_constr.data[y] = txdata_conv_24_conv;
11666         }
11667         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11668         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11669         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11670                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11671                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
11672         }
11673         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11674         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
11675                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11676                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
11677         }
11678         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11679         if (logger_conv.free == LDKLogger_JCalls_free) {
11680                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11681                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11682         }
11683         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);
11684         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11685         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11686         for (size_t u = 0; u < ret_var.datalen; u++) {
11687                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11688                 *ret_conv_46_ref = ret_var.data[u];
11689                 ret_arr_ptr[u] = (long)ret_conv_46_ref;
11690         }
11691         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11692         FREE(ret_var.data);
11693         return ret_arr;
11694 }
11695
11696 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) {
11697         LDKChannelMonitor this_arg_conv;
11698         this_arg_conv.inner = (void*)(this_arg & (~1));
11699         this_arg_conv.is_owned = false;
11700         unsigned char txid_arr[32];
11701         CHECK((*env)->GetArrayLength(env, txid) == 32);
11702         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11703         unsigned char (*txid_ref)[32] = &txid_arr;
11704         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11705         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11706                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11707                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
11708         }
11709         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11710         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
11711                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11712                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
11713         }
11714         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11715         if (logger_conv.free == LDKLogger_JCalls_free) {
11716                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11717                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11718         }
11719         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
11720 }
11721
11722 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) {
11723         LDKChannelMonitor this_arg_conv;
11724         this_arg_conv.inner = (void*)(this_arg & (~1));
11725         this_arg_conv.is_owned = false;
11726         unsigned char header_arr[80];
11727         CHECK((*env)->GetArrayLength(env, header) == 80);
11728         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11729         unsigned char (*header_ref)[80] = &header_arr;
11730         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11731         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11732                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11733                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
11734         }
11735         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11736         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
11737                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11738                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
11739         }
11740         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11741         if (logger_conv.free == LDKLogger_JCalls_free) {
11742                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11743                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11744         }
11745         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_update_best_block(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
11746         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11747         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11748         for (size_t u = 0; u < ret_var.datalen; u++) {
11749                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11750                 *ret_conv_46_ref = ret_var.data[u];
11751                 ret_arr_ptr[u] = (long)ret_conv_46_ref;
11752         }
11753         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11754         FREE(ret_var.data);
11755         return ret_arr;
11756 }
11757
11758 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
11759         LDKChannelMonitor this_arg_conv;
11760         this_arg_conv.inner = (void*)(this_arg & (~1));
11761         this_arg_conv.is_owned = false;
11762         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
11763         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11764         ;
11765         for (size_t i = 0; i < ret_var.datalen; i++) {
11766                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
11767                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
11768                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11769         }
11770         FREE(ret_var.data);
11771         return ret_arr;
11772 }
11773
11774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11775         if ((this_ptr & 1) != 0) return;
11776         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
11777         FREE((void*)this_ptr);
11778         Persist_free(this_ptr_conv);
11779 }
11780
11781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
11782         LDKu8slice ser_ref;
11783         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11784         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11785         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
11786         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11787         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
11788         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11789         return (long)ret_conv;
11790 }
11791
11792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11793         LDKOutPoint this_obj_conv;
11794         this_obj_conv.inner = (void*)(this_obj & (~1));
11795         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11796         OutPoint_free(this_obj_conv);
11797 }
11798
11799 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
11800         LDKOutPoint this_ptr_conv;
11801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11802         this_ptr_conv.is_owned = false;
11803         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11804         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
11805         return ret_arr;
11806 }
11807
11808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11809         LDKOutPoint this_ptr_conv;
11810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11811         this_ptr_conv.is_owned = false;
11812         LDKThirtyTwoBytes val_ref;
11813         CHECK((*env)->GetArrayLength(env, val) == 32);
11814         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11815         OutPoint_set_txid(&this_ptr_conv, val_ref);
11816 }
11817
11818 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
11819         LDKOutPoint this_ptr_conv;
11820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11821         this_ptr_conv.is_owned = false;
11822         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
11823         return ret_val;
11824 }
11825
11826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
11827         LDKOutPoint this_ptr_conv;
11828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11829         this_ptr_conv.is_owned = false;
11830         OutPoint_set_index(&this_ptr_conv, val);
11831 }
11832
11833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
11834         LDKThirtyTwoBytes txid_arg_ref;
11835         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
11836         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
11837         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
11838         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11839         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11840         long ret_ref = (long)ret_var.inner;
11841         if (ret_var.is_owned) {
11842                 ret_ref |= 1;
11843         }
11844         return ret_ref;
11845 }
11846
11847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11848         LDKOutPoint orig_conv;
11849         orig_conv.inner = (void*)(orig & (~1));
11850         orig_conv.is_owned = false;
11851         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
11852         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11853         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11854         long ret_ref = (long)ret_var.inner;
11855         if (ret_var.is_owned) {
11856                 ret_ref |= 1;
11857         }
11858         return ret_ref;
11859 }
11860
11861 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
11862         LDKOutPoint this_arg_conv;
11863         this_arg_conv.inner = (void*)(this_arg & (~1));
11864         this_arg_conv.is_owned = false;
11865         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11866         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
11867         return ret_arr;
11868 }
11869
11870 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
11871         LDKOutPoint obj_conv;
11872         obj_conv.inner = (void*)(obj & (~1));
11873         obj_conv.is_owned = false;
11874         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
11875         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11876         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11877         CVec_u8Z_free(ret_var);
11878         return ret_arr;
11879 }
11880
11881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
11882         LDKu8slice ser_ref;
11883         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11884         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11885         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
11886         *ret_conv = OutPoint_read(ser_ref);
11887         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11888         return (long)ret_conv;
11889 }
11890
11891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
11892         LDKDelayedPaymentOutputDescriptor this_obj_conv;
11893         this_obj_conv.inner = (void*)(this_obj & (~1));
11894         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11895         DelayedPaymentOutputDescriptor_free(this_obj_conv);
11896 }
11897
11898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
11899         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11901         this_ptr_conv.is_owned = false;
11902         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
11903         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11904         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11905         long ret_ref = (long)ret_var.inner;
11906         if (ret_var.is_owned) {
11907                 ret_ref |= 1;
11908         }
11909         return ret_ref;
11910 }
11911
11912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11913         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11915         this_ptr_conv.is_owned = false;
11916         LDKOutPoint val_conv;
11917         val_conv.inner = (void*)(val & (~1));
11918         val_conv.is_owned = (val & 1) || (val == 0);
11919         val_conv = OutPoint_clone(&val_conv);
11920         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
11921 }
11922
11923 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
11924         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11926         this_ptr_conv.is_owned = false;
11927         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
11928         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
11929         return ret_arr;
11930 }
11931
11932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11933         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11935         this_ptr_conv.is_owned = false;
11936         LDKPublicKey val_ref;
11937         CHECK((*env)->GetArrayLength(env, val) == 33);
11938         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11939         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
11940 }
11941
11942 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
11943         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11945         this_ptr_conv.is_owned = false;
11946         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
11947         return ret_val;
11948 }
11949
11950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
11951         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11953         this_ptr_conv.is_owned = false;
11954         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
11955 }
11956
11957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11958         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11960         this_ptr_conv.is_owned = false;
11961         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
11962         FREE((void*)val);
11963         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
11964 }
11965
11966 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
11967         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11969         this_ptr_conv.is_owned = false;
11970         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
11971         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
11972         return ret_arr;
11973 }
11974
11975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11976         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11978         this_ptr_conv.is_owned = false;
11979         LDKPublicKey val_ref;
11980         CHECK((*env)->GetArrayLength(env, val) == 33);
11981         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11982         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
11983 }
11984
11985 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11986         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11988         this_ptr_conv.is_owned = false;
11989         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11990         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
11991         return ret_arr;
11992 }
11993
11994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11995         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
11996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11997         this_ptr_conv.is_owned = false;
11998         LDKThirtyTwoBytes val_ref;
11999         CHECK((*env)->GetArrayLength(env, val) == 32);
12000         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12001         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
12002 }
12003
12004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12005         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12007         this_ptr_conv.is_owned = false;
12008         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
12009         return ret_val;
12010 }
12011
12012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12013         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12015         this_ptr_conv.is_owned = false;
12016         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
12017 }
12018
12019 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) {
12020         LDKOutPoint outpoint_arg_conv;
12021         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
12022         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
12023         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
12024         LDKPublicKey per_commitment_point_arg_ref;
12025         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
12026         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
12027         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
12028         FREE((void*)output_arg);
12029         LDKPublicKey revocation_pubkey_arg_ref;
12030         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
12031         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
12032         LDKThirtyTwoBytes channel_keys_id_arg_ref;
12033         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
12034         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
12035         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);
12036         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12037         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12038         long ret_ref = (long)ret_var.inner;
12039         if (ret_var.is_owned) {
12040                 ret_ref |= 1;
12041         }
12042         return ret_ref;
12043 }
12044
12045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12046         LDKDelayedPaymentOutputDescriptor orig_conv;
12047         orig_conv.inner = (void*)(orig & (~1));
12048         orig_conv.is_owned = false;
12049         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
12050         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12051         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12052         long ret_ref = (long)ret_var.inner;
12053         if (ret_var.is_owned) {
12054                 ret_ref |= 1;
12055         }
12056         return ret_ref;
12057 }
12058
12059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12060         LDKStaticPaymentOutputDescriptor this_obj_conv;
12061         this_obj_conv.inner = (void*)(this_obj & (~1));
12062         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12063         StaticPaymentOutputDescriptor_free(this_obj_conv);
12064 }
12065
12066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
12067         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12069         this_ptr_conv.is_owned = false;
12070         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
12071         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12072         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12073         long ret_ref = (long)ret_var.inner;
12074         if (ret_var.is_owned) {
12075                 ret_ref |= 1;
12076         }
12077         return ret_ref;
12078 }
12079
12080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12081         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12083         this_ptr_conv.is_owned = false;
12084         LDKOutPoint val_conv;
12085         val_conv.inner = (void*)(val & (~1));
12086         val_conv.is_owned = (val & 1) || (val == 0);
12087         val_conv = OutPoint_clone(&val_conv);
12088         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
12089 }
12090
12091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12092         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12094         this_ptr_conv.is_owned = false;
12095         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
12096         FREE((void*)val);
12097         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
12098 }
12099
12100 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12101         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12103         this_ptr_conv.is_owned = false;
12104         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12105         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
12106         return ret_arr;
12107 }
12108
12109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12110         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12112         this_ptr_conv.is_owned = false;
12113         LDKThirtyTwoBytes val_ref;
12114         CHECK((*env)->GetArrayLength(env, val) == 32);
12115         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12116         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
12117 }
12118
12119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12120         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12122         this_ptr_conv.is_owned = false;
12123         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
12124         return ret_val;
12125 }
12126
12127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12128         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12130         this_ptr_conv.is_owned = false;
12131         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
12132 }
12133
12134 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) {
12135         LDKOutPoint outpoint_arg_conv;
12136         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
12137         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
12138         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
12139         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
12140         FREE((void*)output_arg);
12141         LDKThirtyTwoBytes channel_keys_id_arg_ref;
12142         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
12143         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
12144         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
12145         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12146         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12147         long ret_ref = (long)ret_var.inner;
12148         if (ret_var.is_owned) {
12149                 ret_ref |= 1;
12150         }
12151         return ret_ref;
12152 }
12153
12154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12155         LDKStaticPaymentOutputDescriptor orig_conv;
12156         orig_conv.inner = (void*)(orig & (~1));
12157         orig_conv.is_owned = false;
12158         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
12159         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12160         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12161         long ret_ref = (long)ret_var.inner;
12162         if (ret_var.is_owned) {
12163                 ret_ref |= 1;
12164         }
12165         return ret_ref;
12166 }
12167
12168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12169         if ((this_ptr & 1) != 0) return;
12170         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
12171         FREE((void*)this_ptr);
12172         SpendableOutputDescriptor_free(this_ptr_conv);
12173 }
12174
12175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12176         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
12177         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
12178         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
12179         long ret_ref = (long)ret_copy;
12180         return ret_ref;
12181 }
12182
12183 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
12184         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
12185         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
12186         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
12187         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
12188         CVec_u8Z_free(ret_var);
12189         return ret_arr;
12190 }
12191
12192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
12193         LDKu8slice ser_ref;
12194         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
12195         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
12196         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
12197         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
12198         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
12199         return (long)ret_conv;
12200 }
12201
12202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12203         if ((this_ptr & 1) != 0) return;
12204         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
12205         FREE((void*)this_ptr);
12206         BaseSign_free(this_ptr_conv);
12207 }
12208
12209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12210         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
12211         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
12212         *ret = Sign_clone(orig_conv);
12213         return (long)ret;
12214 }
12215
12216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12217         if ((this_ptr & 1) != 0) return;
12218         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
12219         FREE((void*)this_ptr);
12220         Sign_free(this_ptr_conv);
12221 }
12222
12223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12224         if ((this_ptr & 1) != 0) return;
12225         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
12226         FREE((void*)this_ptr);
12227         KeysInterface_free(this_ptr_conv);
12228 }
12229
12230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12231         LDKInMemorySigner this_obj_conv;
12232         this_obj_conv.inner = (void*)(this_obj & (~1));
12233         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12234         InMemorySigner_free(this_obj_conv);
12235 }
12236
12237 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
12238         LDKInMemorySigner this_ptr_conv;
12239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12240         this_ptr_conv.is_owned = false;
12241         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12242         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
12243         return ret_arr;
12244 }
12245
12246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12247         LDKInMemorySigner this_ptr_conv;
12248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12249         this_ptr_conv.is_owned = false;
12250         LDKSecretKey val_ref;
12251         CHECK((*env)->GetArrayLength(env, val) == 32);
12252         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
12253         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
12254 }
12255
12256 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
12257         LDKInMemorySigner this_ptr_conv;
12258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12259         this_ptr_conv.is_owned = false;
12260         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12261         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
12262         return ret_arr;
12263 }
12264
12265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12266         LDKInMemorySigner this_ptr_conv;
12267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12268         this_ptr_conv.is_owned = false;
12269         LDKSecretKey val_ref;
12270         CHECK((*env)->GetArrayLength(env, val) == 32);
12271         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
12272         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
12273 }
12274
12275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
12276         LDKInMemorySigner this_ptr_conv;
12277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12278         this_ptr_conv.is_owned = false;
12279         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12280         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
12281         return ret_arr;
12282 }
12283
12284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12285         LDKInMemorySigner this_ptr_conv;
12286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12287         this_ptr_conv.is_owned = false;
12288         LDKSecretKey val_ref;
12289         CHECK((*env)->GetArrayLength(env, val) == 32);
12290         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
12291         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
12292 }
12293
12294 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
12295         LDKInMemorySigner this_ptr_conv;
12296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12297         this_ptr_conv.is_owned = false;
12298         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12299         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
12300         return ret_arr;
12301 }
12302
12303 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) {
12304         LDKInMemorySigner this_ptr_conv;
12305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12306         this_ptr_conv.is_owned = false;
12307         LDKSecretKey val_ref;
12308         CHECK((*env)->GetArrayLength(env, val) == 32);
12309         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
12310         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
12311 }
12312
12313 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
12314         LDKInMemorySigner this_ptr_conv;
12315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12316         this_ptr_conv.is_owned = false;
12317         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12318         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
12319         return ret_arr;
12320 }
12321
12322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12323         LDKInMemorySigner this_ptr_conv;
12324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12325         this_ptr_conv.is_owned = false;
12326         LDKSecretKey val_ref;
12327         CHECK((*env)->GetArrayLength(env, val) == 32);
12328         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
12329         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
12330 }
12331
12332 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
12333         LDKInMemorySigner this_ptr_conv;
12334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12335         this_ptr_conv.is_owned = false;
12336         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12337         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
12338         return ret_arr;
12339 }
12340
12341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12342         LDKInMemorySigner this_ptr_conv;
12343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12344         this_ptr_conv.is_owned = false;
12345         LDKThirtyTwoBytes val_ref;
12346         CHECK((*env)->GetArrayLength(env, val) == 32);
12347         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12348         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
12349 }
12350
12351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12352         LDKInMemorySigner orig_conv;
12353         orig_conv.inner = (void*)(orig & (~1));
12354         orig_conv.is_owned = false;
12355         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
12356         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12357         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12358         long ret_ref = (long)ret_var.inner;
12359         if (ret_var.is_owned) {
12360                 ret_ref |= 1;
12361         }
12362         return ret_ref;
12363 }
12364
12365 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) {
12366         LDKSecretKey funding_key_ref;
12367         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
12368         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
12369         LDKSecretKey revocation_base_key_ref;
12370         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
12371         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
12372         LDKSecretKey payment_key_ref;
12373         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
12374         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
12375         LDKSecretKey delayed_payment_base_key_ref;
12376         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
12377         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
12378         LDKSecretKey htlc_base_key_ref;
12379         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
12380         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
12381         LDKThirtyTwoBytes commitment_seed_ref;
12382         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
12383         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
12384         LDKThirtyTwoBytes channel_keys_id_ref;
12385         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
12386         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
12387         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);
12388         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12389         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12390         long ret_ref = (long)ret_var.inner;
12391         if (ret_var.is_owned) {
12392                 ret_ref |= 1;
12393         }
12394         return ret_ref;
12395 }
12396
12397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
12398         LDKInMemorySigner this_arg_conv;
12399         this_arg_conv.inner = (void*)(this_arg & (~1));
12400         this_arg_conv.is_owned = false;
12401         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
12402         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12403         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12404         long ret_ref = (long)ret_var.inner;
12405         if (ret_var.is_owned) {
12406                 ret_ref |= 1;
12407         }
12408         return ret_ref;
12409 }
12410
12411 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
12412         LDKInMemorySigner this_arg_conv;
12413         this_arg_conv.inner = (void*)(this_arg & (~1));
12414         this_arg_conv.is_owned = false;
12415         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
12416         return ret_val;
12417 }
12418
12419 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
12420         LDKInMemorySigner this_arg_conv;
12421         this_arg_conv.inner = (void*)(this_arg & (~1));
12422         this_arg_conv.is_owned = false;
12423         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
12424         return ret_val;
12425 }
12426
12427 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
12428         LDKInMemorySigner this_arg_conv;
12429         this_arg_conv.inner = (void*)(this_arg & (~1));
12430         this_arg_conv.is_owned = false;
12431         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
12432         return ret_val;
12433 }
12434
12435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
12436         LDKInMemorySigner this_arg_conv;
12437         this_arg_conv.inner = (void*)(this_arg & (~1));
12438         this_arg_conv.is_owned = false;
12439         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
12440         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12441         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12442         long ret_ref = (long)ret_var.inner;
12443         if (ret_var.is_owned) {
12444                 ret_ref |= 1;
12445         }
12446         return ret_ref;
12447 }
12448
12449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
12450         LDKInMemorySigner this_arg_conv;
12451         this_arg_conv.inner = (void*)(this_arg & (~1));
12452         this_arg_conv.is_owned = false;
12453         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
12454         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12455         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12456         long ret_ref = (long)ret_var.inner;
12457         if (ret_var.is_owned) {
12458                 ret_ref |= 1;
12459         }
12460         return ret_ref;
12461 }
12462
12463 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) {
12464         LDKInMemorySigner this_arg_conv;
12465         this_arg_conv.inner = (void*)(this_arg & (~1));
12466         this_arg_conv.is_owned = false;
12467         LDKTransaction spend_tx_ref;
12468         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
12469         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
12470         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
12471         spend_tx_ref.data_is_owned = true;
12472         LDKStaticPaymentOutputDescriptor descriptor_conv;
12473         descriptor_conv.inner = (void*)(descriptor & (~1));
12474         descriptor_conv.is_owned = false;
12475         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12476         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
12477         return (long)ret_conv;
12478 }
12479
12480 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) {
12481         LDKInMemorySigner this_arg_conv;
12482         this_arg_conv.inner = (void*)(this_arg & (~1));
12483         this_arg_conv.is_owned = false;
12484         LDKTransaction spend_tx_ref;
12485         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
12486         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
12487         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
12488         spend_tx_ref.data_is_owned = true;
12489         LDKDelayedPaymentOutputDescriptor descriptor_conv;
12490         descriptor_conv.inner = (void*)(descriptor & (~1));
12491         descriptor_conv.is_owned = false;
12492         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12493         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
12494         return (long)ret_conv;
12495 }
12496
12497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
12498         LDKInMemorySigner this_arg_conv;
12499         this_arg_conv.inner = (void*)(this_arg & (~1));
12500         this_arg_conv.is_owned = false;
12501         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
12502         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
12503         return (long)ret;
12504 }
12505
12506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
12507         LDKInMemorySigner this_arg_conv;
12508         this_arg_conv.inner = (void*)(this_arg & (~1));
12509         this_arg_conv.is_owned = false;
12510         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
12511         *ret = InMemorySigner_as_Sign(&this_arg_conv);
12512         return (long)ret;
12513 }
12514
12515 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
12516         LDKInMemorySigner obj_conv;
12517         obj_conv.inner = (void*)(obj & (~1));
12518         obj_conv.is_owned = false;
12519         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
12520         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
12521         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
12522         CVec_u8Z_free(ret_var);
12523         return ret_arr;
12524 }
12525
12526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
12527         LDKu8slice ser_ref;
12528         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
12529         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
12530         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
12531         *ret_conv = InMemorySigner_read(ser_ref);
12532         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
12533         return (long)ret_conv;
12534 }
12535
12536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12537         LDKKeysManager this_obj_conv;
12538         this_obj_conv.inner = (void*)(this_obj & (~1));
12539         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12540         KeysManager_free(this_obj_conv);
12541 }
12542
12543 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) {
12544         unsigned char seed_arr[32];
12545         CHECK((*env)->GetArrayLength(env, seed) == 32);
12546         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
12547         unsigned char (*seed_ref)[32] = &seed_arr;
12548         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
12549         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12550         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12551         long ret_ref = (long)ret_var.inner;
12552         if (ret_var.is_owned) {
12553                 ret_ref |= 1;
12554         }
12555         return ret_ref;
12556 }
12557
12558 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) {
12559         LDKKeysManager this_arg_conv;
12560         this_arg_conv.inner = (void*)(this_arg & (~1));
12561         this_arg_conv.is_owned = false;
12562         unsigned char params_arr[32];
12563         CHECK((*env)->GetArrayLength(env, params) == 32);
12564         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
12565         unsigned char (*params_ref)[32] = &params_arr;
12566         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
12567         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12568         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12569         long ret_ref = (long)ret_var.inner;
12570         if (ret_var.is_owned) {
12571                 ret_ref |= 1;
12572         }
12573         return ret_ref;
12574 }
12575
12576 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) {
12577         LDKKeysManager this_arg_conv;
12578         this_arg_conv.inner = (void*)(this_arg & (~1));
12579         this_arg_conv.is_owned = false;
12580         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
12581         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
12582         if (descriptors_constr.datalen > 0)
12583                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12584         else
12585                 descriptors_constr.data = NULL;
12586         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
12587         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
12588                 int64_t descriptors_conv_27 = descriptors_vals[b];
12589                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
12590                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
12591                 descriptors_constr.data[b] = descriptors_conv_27_conv;
12592         }
12593         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
12594         LDKCVec_TxOutZ outputs_constr;
12595         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
12596         if (outputs_constr.datalen > 0)
12597                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
12598         else
12599                 outputs_constr.data = NULL;
12600         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
12601         for (size_t h = 0; h < outputs_constr.datalen; h++) {
12602                 int64_t outputs_conv_7 = outputs_vals[h];
12603                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
12604                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
12605                 outputs_constr.data[h] = outputs_conv_7_conv;
12606         }
12607         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
12608         LDKCVec_u8Z change_destination_script_ref;
12609         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
12610         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
12611         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
12612         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
12613         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
12614         return (long)ret_conv;
12615 }
12616
12617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
12618         LDKKeysManager this_arg_conv;
12619         this_arg_conv.inner = (void*)(this_arg & (~1));
12620         this_arg_conv.is_owned = false;
12621         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
12622         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
12623         return (long)ret;
12624 }
12625
12626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12627         LDKChannelManager this_obj_conv;
12628         this_obj_conv.inner = (void*)(this_obj & (~1));
12629         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12630         ChannelManager_free(this_obj_conv);
12631 }
12632
12633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12634         LDKChainParameters this_obj_conv;
12635         this_obj_conv.inner = (void*)(this_obj & (~1));
12636         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12637         ChainParameters_free(this_obj_conv);
12638 }
12639
12640 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
12641         LDKChainParameters this_ptr_conv;
12642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12643         this_ptr_conv.is_owned = false;
12644         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
12645         return ret_conv;
12646 }
12647
12648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
12649         LDKChainParameters this_ptr_conv;
12650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12651         this_ptr_conv.is_owned = false;
12652         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
12653         ChainParameters_set_network(&this_ptr_conv, val_conv);
12654 }
12655
12656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
12657         LDKChainParameters this_ptr_conv;
12658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12659         this_ptr_conv.is_owned = false;
12660         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
12661         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12662         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12663         long ret_ref = (long)ret_var.inner;
12664         if (ret_var.is_owned) {
12665                 ret_ref |= 1;
12666         }
12667         return ret_ref;
12668 }
12669
12670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12671         LDKChainParameters this_ptr_conv;
12672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12673         this_ptr_conv.is_owned = false;
12674         LDKBestBlock val_conv;
12675         val_conv.inner = (void*)(val & (~1));
12676         val_conv.is_owned = (val & 1) || (val == 0);
12677         val_conv = BestBlock_clone(&val_conv);
12678         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
12679 }
12680
12681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
12682         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
12683         LDKBestBlock best_block_arg_conv;
12684         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
12685         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
12686         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
12687         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
12688         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12689         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12690         long ret_ref = (long)ret_var.inner;
12691         if (ret_var.is_owned) {
12692                 ret_ref |= 1;
12693         }
12694         return ret_ref;
12695 }
12696
12697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12698         LDKBestBlock this_obj_conv;
12699         this_obj_conv.inner = (void*)(this_obj & (~1));
12700         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12701         BestBlock_free(this_obj_conv);
12702 }
12703
12704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12705         LDKBestBlock orig_conv;
12706         orig_conv.inner = (void*)(orig & (~1));
12707         orig_conv.is_owned = false;
12708         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
12709         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12710         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12711         long ret_ref = (long)ret_var.inner;
12712         if (ret_var.is_owned) {
12713                 ret_ref |= 1;
12714         }
12715         return ret_ref;
12716 }
12717
12718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
12719         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
12720         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
12721         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12722         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12723         long ret_ref = (long)ret_var.inner;
12724         if (ret_var.is_owned) {
12725                 ret_ref |= 1;
12726         }
12727         return ret_ref;
12728 }
12729
12730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
12731         LDKThirtyTwoBytes block_hash_ref;
12732         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
12733         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
12734         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
12735         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12736         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12737         long ret_ref = (long)ret_var.inner;
12738         if (ret_var.is_owned) {
12739                 ret_ref |= 1;
12740         }
12741         return ret_ref;
12742 }
12743
12744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
12745         LDKBestBlock this_arg_conv;
12746         this_arg_conv.inner = (void*)(this_arg & (~1));
12747         this_arg_conv.is_owned = false;
12748         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12749         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
12750         return ret_arr;
12751 }
12752
12753 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
12754         LDKBestBlock this_arg_conv;
12755         this_arg_conv.inner = (void*)(this_arg & (~1));
12756         this_arg_conv.is_owned = false;
12757         int32_t ret_val = BestBlock_height(&this_arg_conv);
12758         return ret_val;
12759 }
12760
12761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
12762         LDKChannelDetails this_obj_conv;
12763         this_obj_conv.inner = (void*)(this_obj & (~1));
12764         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12765         ChannelDetails_free(this_obj_conv);
12766 }
12767
12768 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12769         LDKChannelDetails this_ptr_conv;
12770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12771         this_ptr_conv.is_owned = false;
12772         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12773         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
12774         return ret_arr;
12775 }
12776
12777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12778         LDKChannelDetails this_ptr_conv;
12779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12780         this_ptr_conv.is_owned = false;
12781         LDKThirtyTwoBytes val_ref;
12782         CHECK((*env)->GetArrayLength(env, val) == 32);
12783         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12784         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
12785 }
12786
12787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12788         LDKChannelDetails this_ptr_conv;
12789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12790         this_ptr_conv.is_owned = false;
12791         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12792         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
12793         long ret_ref = (long)ret_copy;
12794         return ret_ref;
12795 }
12796
12797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12798         LDKChannelDetails this_ptr_conv;
12799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12800         this_ptr_conv.is_owned = false;
12801         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
12802         FREE((void*)val);
12803         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
12804 }
12805
12806 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12807         LDKChannelDetails this_ptr_conv;
12808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12809         this_ptr_conv.is_owned = false;
12810         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
12811         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form);
12812         return ret_arr;
12813 }
12814
12815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12816         LDKChannelDetails this_ptr_conv;
12817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12818         this_ptr_conv.is_owned = false;
12819         LDKPublicKey val_ref;
12820         CHECK((*env)->GetArrayLength(env, val) == 33);
12821         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12822         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
12823 }
12824
12825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
12826         LDKChannelDetails this_ptr_conv;
12827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12828         this_ptr_conv.is_owned = false;
12829         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
12830         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12831         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12832         long ret_ref = (long)ret_var.inner;
12833         if (ret_var.is_owned) {
12834                 ret_ref |= 1;
12835         }
12836         return ret_ref;
12837 }
12838
12839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12840         LDKChannelDetails this_ptr_conv;
12841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12842         this_ptr_conv.is_owned = false;
12843         LDKInitFeatures val_conv;
12844         val_conv.inner = (void*)(val & (~1));
12845         val_conv.is_owned = (val & 1) || (val == 0);
12846         val_conv = InitFeatures_clone(&val_conv);
12847         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
12848 }
12849
12850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12851         LDKChannelDetails this_ptr_conv;
12852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12853         this_ptr_conv.is_owned = false;
12854         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
12855         return ret_val;
12856 }
12857
12858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12859         LDKChannelDetails this_ptr_conv;
12860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12861         this_ptr_conv.is_owned = false;
12862         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
12863 }
12864
12865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12866         LDKChannelDetails this_ptr_conv;
12867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12868         this_ptr_conv.is_owned = false;
12869         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
12870         return ret_val;
12871 }
12872
12873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12874         LDKChannelDetails this_ptr_conv;
12875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12876         this_ptr_conv.is_owned = false;
12877         ChannelDetails_set_user_id(&this_ptr_conv, val);
12878 }
12879
12880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
12881         LDKChannelDetails this_ptr_conv;
12882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12883         this_ptr_conv.is_owned = false;
12884         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
12885         return ret_val;
12886 }
12887
12888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12889         LDKChannelDetails this_ptr_conv;
12890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12891         this_ptr_conv.is_owned = false;
12892         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
12893 }
12894
12895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
12896         LDKChannelDetails this_ptr_conv;
12897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12898         this_ptr_conv.is_owned = false;
12899         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
12900         return ret_val;
12901 }
12902
12903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12904         LDKChannelDetails this_ptr_conv;
12905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12906         this_ptr_conv.is_owned = false;
12907         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
12908 }
12909
12910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1live(JNIEnv *env, jclass clz, int64_t this_ptr) {
12911         LDKChannelDetails this_ptr_conv;
12912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12913         this_ptr_conv.is_owned = false;
12914         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
12915         return ret_val;
12916 }
12917
12918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1live(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
12919         LDKChannelDetails this_ptr_conv;
12920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12921         this_ptr_conv.is_owned = false;
12922         ChannelDetails_set_is_live(&this_ptr_conv, val);
12923 }
12924
12925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12926         LDKChannelDetails orig_conv;
12927         orig_conv.inner = (void*)(orig & (~1));
12928         orig_conv.is_owned = false;
12929         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
12930         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12931         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12932         long ret_ref = (long)ret_var.inner;
12933         if (ret_var.is_owned) {
12934                 ret_ref |= 1;
12935         }
12936         return ret_ref;
12937 }
12938
12939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12940         if ((this_ptr & 1) != 0) return;
12941         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
12942         FREE((void*)this_ptr);
12943         PaymentSendFailure_free(this_ptr_conv);
12944 }
12945
12946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12947         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
12948         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
12949         *ret_copy = PaymentSendFailure_clone(orig_conv);
12950         long ret_ref = (long)ret_copy;
12951         return ret_ref;
12952 }
12953
12954 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) {
12955         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
12956         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
12957                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12958                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
12959         }
12960         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
12961         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
12962                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12963                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
12964         }
12965         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
12966         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
12967                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12968                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
12969         }
12970         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12971         if (logger_conv.free == LDKLogger_JCalls_free) {
12972                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12973                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12974         }
12975         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
12976         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
12977                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12978                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
12979         }
12980         LDKUserConfig config_conv;
12981         config_conv.inner = (void*)(config & (~1));
12982         config_conv.is_owned = (config & 1) || (config == 0);
12983         config_conv = UserConfig_clone(&config_conv);
12984         LDKChainParameters params_conv;
12985         params_conv.inner = (void*)(params & (~1));
12986         params_conv.is_owned = (params & 1) || (params == 0);
12987         // Warning: we need a move here but no clone is available for LDKChainParameters
12988         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
12989         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12990         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12991         long ret_ref = (long)ret_var.inner;
12992         if (ret_var.is_owned) {
12993                 ret_ref |= 1;
12994         }
12995         return ret_ref;
12996 }
12997
12998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
12999         LDKChannelManager this_arg_conv;
13000         this_arg_conv.inner = (void*)(this_arg & (~1));
13001         this_arg_conv.is_owned = false;
13002         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
13003         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13004         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13005         long ret_ref = (long)ret_var.inner;
13006         if (ret_var.is_owned) {
13007                 ret_ref |= 1;
13008         }
13009         return ret_ref;
13010 }
13011
13012 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) {
13013         LDKChannelManager this_arg_conv;
13014         this_arg_conv.inner = (void*)(this_arg & (~1));
13015         this_arg_conv.is_owned = false;
13016         LDKPublicKey their_network_key_ref;
13017         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
13018         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
13019         LDKUserConfig override_config_conv;
13020         override_config_conv.inner = (void*)(override_config & (~1));
13021         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
13022         override_config_conv = UserConfig_clone(&override_config_conv);
13023         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13024         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
13025         return (long)ret_conv;
13026 }
13027
13028 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
13029         LDKChannelManager this_arg_conv;
13030         this_arg_conv.inner = (void*)(this_arg & (~1));
13031         this_arg_conv.is_owned = false;
13032         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
13033         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13034         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13035         for (size_t q = 0; q < ret_var.datalen; q++) {
13036                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13037                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13038                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13039                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
13040                 if (ret_conv_16_var.is_owned) {
13041                         ret_conv_16_ref |= 1;
13042                 }
13043                 ret_arr_ptr[q] = ret_conv_16_ref;
13044         }
13045         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13046         FREE(ret_var.data);
13047         return ret_arr;
13048 }
13049
13050 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
13051         LDKChannelManager this_arg_conv;
13052         this_arg_conv.inner = (void*)(this_arg & (~1));
13053         this_arg_conv.is_owned = false;
13054         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
13055         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13056         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13057         for (size_t q = 0; q < ret_var.datalen; q++) {
13058                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13059                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13060                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13061                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
13062                 if (ret_conv_16_var.is_owned) {
13063                         ret_conv_16_ref |= 1;
13064                 }
13065                 ret_arr_ptr[q] = ret_conv_16_ref;
13066         }
13067         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13068         FREE(ret_var.data);
13069         return ret_arr;
13070 }
13071
13072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
13073         LDKChannelManager this_arg_conv;
13074         this_arg_conv.inner = (void*)(this_arg & (~1));
13075         this_arg_conv.is_owned = false;
13076         unsigned char channel_id_arr[32];
13077         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
13078         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
13079         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
13080         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13081         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
13082         return (long)ret_conv;
13083 }
13084
13085 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) {
13086         LDKChannelManager this_arg_conv;
13087         this_arg_conv.inner = (void*)(this_arg & (~1));
13088         this_arg_conv.is_owned = false;
13089         unsigned char channel_id_arr[32];
13090         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
13091         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
13092         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
13093         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13094         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
13095         return (long)ret_conv;
13096 }
13097
13098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
13099         LDKChannelManager this_arg_conv;
13100         this_arg_conv.inner = (void*)(this_arg & (~1));
13101         this_arg_conv.is_owned = false;
13102         ChannelManager_force_close_all_channels(&this_arg_conv);
13103 }
13104
13105 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) {
13106         LDKChannelManager this_arg_conv;
13107         this_arg_conv.inner = (void*)(this_arg & (~1));
13108         this_arg_conv.is_owned = false;
13109         LDKRoute route_conv;
13110         route_conv.inner = (void*)(route & (~1));
13111         route_conv.is_owned = false;
13112         LDKThirtyTwoBytes payment_hash_ref;
13113         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13114         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13115         LDKThirtyTwoBytes payment_secret_ref;
13116         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13117         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13118         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13119         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
13120         return (long)ret_conv;
13121 }
13122
13123 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) {
13124         LDKChannelManager this_arg_conv;
13125         this_arg_conv.inner = (void*)(this_arg & (~1));
13126         this_arg_conv.is_owned = false;
13127         unsigned char temporary_channel_id_arr[32];
13128         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
13129         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
13130         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
13131         LDKTransaction funding_transaction_ref;
13132         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
13133         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
13134         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
13135         funding_transaction_ref.data_is_owned = true;
13136         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13137         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
13138         return (long)ret_conv;
13139 }
13140
13141 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) {
13142         LDKChannelManager this_arg_conv;
13143         this_arg_conv.inner = (void*)(this_arg & (~1));
13144         this_arg_conv.is_owned = false;
13145         LDKThreeBytes rgb_ref;
13146         CHECK((*env)->GetArrayLength(env, rgb) == 3);
13147         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
13148         LDKThirtyTwoBytes alias_ref;
13149         CHECK((*env)->GetArrayLength(env, alias) == 32);
13150         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
13151         LDKCVec_NetAddressZ addresses_constr;
13152         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
13153         if (addresses_constr.datalen > 0)
13154                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
13155         else
13156                 addresses_constr.data = NULL;
13157         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
13158         for (size_t m = 0; m < addresses_constr.datalen; m++) {
13159                 int64_t addresses_conv_12 = addresses_vals[m];
13160                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
13161                 FREE((void*)addresses_conv_12);
13162                 addresses_constr.data[m] = addresses_conv_12_conv;
13163         }
13164         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
13165         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
13166 }
13167
13168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
13169         LDKChannelManager this_arg_conv;
13170         this_arg_conv.inner = (void*)(this_arg & (~1));
13171         this_arg_conv.is_owned = false;
13172         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
13173 }
13174
13175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
13176         LDKChannelManager this_arg_conv;
13177         this_arg_conv.inner = (void*)(this_arg & (~1));
13178         this_arg_conv.is_owned = false;
13179         ChannelManager_timer_tick_occurred(&this_arg_conv);
13180 }
13181
13182 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) {
13183         LDKChannelManager this_arg_conv;
13184         this_arg_conv.inner = (void*)(this_arg & (~1));
13185         this_arg_conv.is_owned = false;
13186         unsigned char payment_hash_arr[32];
13187         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13188         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
13189         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
13190         LDKThirtyTwoBytes payment_secret_ref;
13191         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13192         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13193         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
13194         return ret_val;
13195 }
13196
13197 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) {
13198         LDKChannelManager this_arg_conv;
13199         this_arg_conv.inner = (void*)(this_arg & (~1));
13200         this_arg_conv.is_owned = false;
13201         LDKThirtyTwoBytes payment_preimage_ref;
13202         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13203         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13204         LDKThirtyTwoBytes payment_secret_ref;
13205         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13206         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13207         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
13208         return ret_val;
13209 }
13210
13211 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
13212         LDKChannelManager this_arg_conv;
13213         this_arg_conv.inner = (void*)(this_arg & (~1));
13214         this_arg_conv.is_owned = false;
13215         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13216         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
13217         return ret_arr;
13218 }
13219
13220 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) {
13221         LDKChannelManager this_arg_conv;
13222         this_arg_conv.inner = (void*)(this_arg & (~1));
13223         this_arg_conv.is_owned = false;
13224         LDKOutPoint funding_txo_conv;
13225         funding_txo_conv.inner = (void*)(funding_txo & (~1));
13226         funding_txo_conv.is_owned = false;
13227         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
13228 }
13229
13230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
13231         LDKChannelManager this_arg_conv;
13232         this_arg_conv.inner = (void*)(this_arg & (~1));
13233         this_arg_conv.is_owned = false;
13234         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
13235         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
13236         return (long)ret;
13237 }
13238
13239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
13240         LDKChannelManager this_arg_conv;
13241         this_arg_conv.inner = (void*)(this_arg & (~1));
13242         this_arg_conv.is_owned = false;
13243         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
13244         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
13245         return (long)ret;
13246 }
13247
13248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
13249         LDKChannelManager this_arg_conv;
13250         this_arg_conv.inner = (void*)(this_arg & (~1));
13251         this_arg_conv.is_owned = false;
13252         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
13253         *ret = ChannelManager_as_Listen(&this_arg_conv);
13254         return (long)ret;
13255 }
13256
13257 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) {
13258         LDKChannelManager this_arg_conv;
13259         this_arg_conv.inner = (void*)(this_arg & (~1));
13260         this_arg_conv.is_owned = false;
13261         unsigned char header_arr[80];
13262         CHECK((*env)->GetArrayLength(env, header) == 80);
13263         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
13264         unsigned char (*header_ref)[80] = &header_arr;
13265         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
13266         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
13267         if (txdata_constr.datalen > 0)
13268                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
13269         else
13270                 txdata_constr.data = NULL;
13271         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
13272         for (size_t y = 0; y < txdata_constr.datalen; y++) {
13273                 int64_t txdata_conv_24 = txdata_vals[y];
13274                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
13275                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
13276                 txdata_constr.data[y] = txdata_conv_24_conv;
13277         }
13278         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
13279         ChannelManager_transactions_confirmed(&this_arg_conv, header_ref, height, txdata_constr);
13280 }
13281
13282 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) {
13283         LDKChannelManager this_arg_conv;
13284         this_arg_conv.inner = (void*)(this_arg & (~1));
13285         this_arg_conv.is_owned = false;
13286         unsigned char header_arr[80];
13287         CHECK((*env)->GetArrayLength(env, header) == 80);
13288         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
13289         unsigned char (*header_ref)[80] = &header_arr;
13290         ChannelManager_update_best_block(&this_arg_conv, header_ref, height);
13291 }
13292
13293 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
13294         LDKChannelManager this_arg_conv;
13295         this_arg_conv.inner = (void*)(this_arg & (~1));
13296         this_arg_conv.is_owned = false;
13297         LDKCVec_TxidZ ret_var = ChannelManager_get_relevant_txids(&this_arg_conv);
13298         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
13299         ;
13300         for (size_t i = 0; i < ret_var.datalen; i++) {
13301                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
13302                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
13303                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
13304         }
13305         FREE(ret_var.data);
13306         return ret_arr;
13307 }
13308
13309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
13310         LDKChannelManager this_arg_conv;
13311         this_arg_conv.inner = (void*)(this_arg & (~1));
13312         this_arg_conv.is_owned = false;
13313         unsigned char txid_arr[32];
13314         CHECK((*env)->GetArrayLength(env, txid) == 32);
13315         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
13316         unsigned char (*txid_ref)[32] = &txid_arr;
13317         ChannelManager_transaction_unconfirmed(&this_arg_conv, txid_ref);
13318 }
13319
13320 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) {
13321         LDKChannelManager this_arg_conv;
13322         this_arg_conv.inner = (void*)(this_arg & (~1));
13323         this_arg_conv.is_owned = false;
13324         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
13325         return ret_val;
13326 }
13327
13328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
13329         LDKChannelManager this_arg_conv;
13330         this_arg_conv.inner = (void*)(this_arg & (~1));
13331         this_arg_conv.is_owned = false;
13332         ChannelManager_await_persistable_update(&this_arg_conv);
13333 }
13334
13335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
13336         LDKChannelManager this_arg_conv;
13337         this_arg_conv.inner = (void*)(this_arg & (~1));
13338         this_arg_conv.is_owned = false;
13339         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
13340         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
13341         return (long)ret;
13342 }
13343
13344 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
13345         LDKChannelManager obj_conv;
13346         obj_conv.inner = (void*)(obj & (~1));
13347         obj_conv.is_owned = false;
13348         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
13349         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13350         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13351         CVec_u8Z_free(ret_var);
13352         return ret_arr;
13353 }
13354
13355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13356         LDKChannelManagerReadArgs this_obj_conv;
13357         this_obj_conv.inner = (void*)(this_obj & (~1));
13358         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13359         ChannelManagerReadArgs_free(this_obj_conv);
13360 }
13361
13362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
13363         LDKChannelManagerReadArgs this_ptr_conv;
13364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13365         this_ptr_conv.is_owned = false;
13366         long ret_ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
13367         return ret_ret;
13368 }
13369
13370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13371         LDKChannelManagerReadArgs this_ptr_conv;
13372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13373         this_ptr_conv.is_owned = false;
13374         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
13375         if (val_conv.free == LDKKeysInterface_JCalls_free) {
13376                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13377                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
13378         }
13379         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
13380 }
13381
13382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
13383         LDKChannelManagerReadArgs this_ptr_conv;
13384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13385         this_ptr_conv.is_owned = false;
13386         long ret_ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
13387         return ret_ret;
13388 }
13389
13390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13391         LDKChannelManagerReadArgs this_ptr_conv;
13392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13393         this_ptr_conv.is_owned = false;
13394         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
13395         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
13396                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13397                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
13398         }
13399         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
13400 }
13401
13402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
13403         LDKChannelManagerReadArgs this_ptr_conv;
13404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13405         this_ptr_conv.is_owned = false;
13406         long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
13407         return ret_ret;
13408 }
13409
13410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13411         LDKChannelManagerReadArgs this_ptr_conv;
13412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13413         this_ptr_conv.is_owned = false;
13414         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
13415         if (val_conv.free == LDKWatch_JCalls_free) {
13416                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13417                 LDKWatch_JCalls_clone(val_conv.this_arg);
13418         }
13419         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
13420 }
13421
13422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
13423         LDKChannelManagerReadArgs this_ptr_conv;
13424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13425         this_ptr_conv.is_owned = false;
13426         long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
13427         return ret_ret;
13428 }
13429
13430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13431         LDKChannelManagerReadArgs this_ptr_conv;
13432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13433         this_ptr_conv.is_owned = false;
13434         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
13435         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
13436                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13437                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
13438         }
13439         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
13440 }
13441
13442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
13443         LDKChannelManagerReadArgs this_ptr_conv;
13444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13445         this_ptr_conv.is_owned = false;
13446         long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
13447         return ret_ret;
13448 }
13449
13450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13451         LDKChannelManagerReadArgs this_ptr_conv;
13452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13453         this_ptr_conv.is_owned = false;
13454         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
13455         if (val_conv.free == LDKLogger_JCalls_free) {
13456                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13457                 LDKLogger_JCalls_clone(val_conv.this_arg);
13458         }
13459         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
13460 }
13461
13462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
13463         LDKChannelManagerReadArgs this_ptr_conv;
13464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13465         this_ptr_conv.is_owned = false;
13466         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
13467         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13468         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13469         long ret_ref = (long)ret_var.inner;
13470         if (ret_var.is_owned) {
13471                 ret_ref |= 1;
13472         }
13473         return ret_ref;
13474 }
13475
13476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13477         LDKChannelManagerReadArgs this_ptr_conv;
13478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13479         this_ptr_conv.is_owned = false;
13480         LDKUserConfig val_conv;
13481         val_conv.inner = (void*)(val & (~1));
13482         val_conv.is_owned = (val & 1) || (val == 0);
13483         val_conv = UserConfig_clone(&val_conv);
13484         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
13485 }
13486
13487 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) {
13488         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
13489         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
13490                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13491                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
13492         }
13493         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13494         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
13495                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13496                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
13497         }
13498         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
13499         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
13500                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13501                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
13502         }
13503         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
13504         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
13505                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13506                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
13507         }
13508         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13509         if (logger_conv.free == LDKLogger_JCalls_free) {
13510                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13511                 LDKLogger_JCalls_clone(logger_conv.this_arg);
13512         }
13513         LDKUserConfig default_config_conv;
13514         default_config_conv.inner = (void*)(default_config & (~1));
13515         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
13516         default_config_conv = UserConfig_clone(&default_config_conv);
13517         LDKCVec_ChannelMonitorZ channel_monitors_constr;
13518         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
13519         if (channel_monitors_constr.datalen > 0)
13520                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
13521         else
13522                 channel_monitors_constr.data = NULL;
13523         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
13524         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
13525                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
13526                 LDKChannelMonitor channel_monitors_conv_16_conv;
13527                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
13528                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
13529                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
13530         }
13531         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
13532         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);
13533         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13534         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13535         long ret_ref = (long)ret_var.inner;
13536         if (ret_var.is_owned) {
13537                 ret_ref |= 1;
13538         }
13539         return ret_ref;
13540 }
13541
13542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
13543         LDKu8slice ser_ref;
13544         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13545         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13546         LDKChannelManagerReadArgs arg_conv;
13547         arg_conv.inner = (void*)(arg & (~1));
13548         arg_conv.is_owned = (arg & 1) || (arg == 0);
13549         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
13550         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
13551         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
13552         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
13553         return (long)ret_conv;
13554 }
13555
13556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13557         LDKDecodeError this_obj_conv;
13558         this_obj_conv.inner = (void*)(this_obj & (~1));
13559         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13560         DecodeError_free(this_obj_conv);
13561 }
13562
13563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13564         LDKDecodeError orig_conv;
13565         orig_conv.inner = (void*)(orig & (~1));
13566         orig_conv.is_owned = false;
13567         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
13568         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13569         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13570         long ret_ref = (long)ret_var.inner;
13571         if (ret_var.is_owned) {
13572                 ret_ref |= 1;
13573         }
13574         return ret_ref;
13575 }
13576
13577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13578         LDKInit this_obj_conv;
13579         this_obj_conv.inner = (void*)(this_obj & (~1));
13580         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13581         Init_free(this_obj_conv);
13582 }
13583
13584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
13585         LDKInit this_ptr_conv;
13586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13587         this_ptr_conv.is_owned = false;
13588         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
13589         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13590         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13591         long ret_ref = (long)ret_var.inner;
13592         if (ret_var.is_owned) {
13593                 ret_ref |= 1;
13594         }
13595         return ret_ref;
13596 }
13597
13598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13599         LDKInit this_ptr_conv;
13600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13601         this_ptr_conv.is_owned = false;
13602         LDKInitFeatures val_conv;
13603         val_conv.inner = (void*)(val & (~1));
13604         val_conv.is_owned = (val & 1) || (val == 0);
13605         val_conv = InitFeatures_clone(&val_conv);
13606         Init_set_features(&this_ptr_conv, val_conv);
13607 }
13608
13609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
13610         LDKInitFeatures features_arg_conv;
13611         features_arg_conv.inner = (void*)(features_arg & (~1));
13612         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
13613         features_arg_conv = InitFeatures_clone(&features_arg_conv);
13614         LDKInit ret_var = Init_new(features_arg_conv);
13615         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13616         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13617         long ret_ref = (long)ret_var.inner;
13618         if (ret_var.is_owned) {
13619                 ret_ref |= 1;
13620         }
13621         return ret_ref;
13622 }
13623
13624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13625         LDKInit orig_conv;
13626         orig_conv.inner = (void*)(orig & (~1));
13627         orig_conv.is_owned = false;
13628         LDKInit ret_var = Init_clone(&orig_conv);
13629         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13630         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13631         long ret_ref = (long)ret_var.inner;
13632         if (ret_var.is_owned) {
13633                 ret_ref |= 1;
13634         }
13635         return ret_ref;
13636 }
13637
13638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13639         LDKErrorMessage this_obj_conv;
13640         this_obj_conv.inner = (void*)(this_obj & (~1));
13641         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13642         ErrorMessage_free(this_obj_conv);
13643 }
13644
13645 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13646         LDKErrorMessage this_ptr_conv;
13647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13648         this_ptr_conv.is_owned = false;
13649         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13650         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
13651         return ret_arr;
13652 }
13653
13654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13655         LDKErrorMessage this_ptr_conv;
13656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13657         this_ptr_conv.is_owned = false;
13658         LDKThirtyTwoBytes val_ref;
13659         CHECK((*env)->GetArrayLength(env, val) == 32);
13660         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13661         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
13662 }
13663
13664 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
13665         LDKErrorMessage this_ptr_conv;
13666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13667         this_ptr_conv.is_owned = false;
13668         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
13669         jstring _conv = str_ref_to_java(env, _str.chars, _str.len);
13670         return _conv;
13671 }
13672
13673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13674         LDKErrorMessage this_ptr_conv;
13675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13676         this_ptr_conv.is_owned = false;
13677         LDKCVec_u8Z val_ref;
13678         val_ref.datalen = (*env)->GetArrayLength(env, val);
13679         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
13680         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
13681         ErrorMessage_set_data(&this_ptr_conv, val_ref);
13682 }
13683
13684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray data_arg) {
13685         LDKThirtyTwoBytes channel_id_arg_ref;
13686         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13687         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13688         LDKCVec_u8Z data_arg_ref;
13689         data_arg_ref.datalen = (*env)->GetArrayLength(env, data_arg);
13690         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
13691         (*env)->GetByteArrayRegion(env, data_arg, 0, data_arg_ref.datalen, data_arg_ref.data);
13692         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
13693         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13694         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13695         long ret_ref = (long)ret_var.inner;
13696         if (ret_var.is_owned) {
13697                 ret_ref |= 1;
13698         }
13699         return ret_ref;
13700 }
13701
13702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13703         LDKErrorMessage orig_conv;
13704         orig_conv.inner = (void*)(orig & (~1));
13705         orig_conv.is_owned = false;
13706         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
13707         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13708         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13709         long ret_ref = (long)ret_var.inner;
13710         if (ret_var.is_owned) {
13711                 ret_ref |= 1;
13712         }
13713         return ret_ref;
13714 }
13715
13716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13717         LDKPing this_obj_conv;
13718         this_obj_conv.inner = (void*)(this_obj & (~1));
13719         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13720         Ping_free(this_obj_conv);
13721 }
13722
13723 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
13724         LDKPing this_ptr_conv;
13725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13726         this_ptr_conv.is_owned = false;
13727         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
13728         return ret_val;
13729 }
13730
13731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13732         LDKPing this_ptr_conv;
13733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13734         this_ptr_conv.is_owned = false;
13735         Ping_set_ponglen(&this_ptr_conv, val);
13736 }
13737
13738 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
13739         LDKPing this_ptr_conv;
13740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13741         this_ptr_conv.is_owned = false;
13742         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
13743         return ret_val;
13744 }
13745
13746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13747         LDKPing this_ptr_conv;
13748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13749         this_ptr_conv.is_owned = false;
13750         Ping_set_byteslen(&this_ptr_conv, val);
13751 }
13752
13753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
13754         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
13755         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13756         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13757         long ret_ref = (long)ret_var.inner;
13758         if (ret_var.is_owned) {
13759                 ret_ref |= 1;
13760         }
13761         return ret_ref;
13762 }
13763
13764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13765         LDKPing orig_conv;
13766         orig_conv.inner = (void*)(orig & (~1));
13767         orig_conv.is_owned = false;
13768         LDKPing ret_var = Ping_clone(&orig_conv);
13769         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13770         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13771         long ret_ref = (long)ret_var.inner;
13772         if (ret_var.is_owned) {
13773                 ret_ref |= 1;
13774         }
13775         return ret_ref;
13776 }
13777
13778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13779         LDKPong this_obj_conv;
13780         this_obj_conv.inner = (void*)(this_obj & (~1));
13781         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13782         Pong_free(this_obj_conv);
13783 }
13784
13785 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
13786         LDKPong this_ptr_conv;
13787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13788         this_ptr_conv.is_owned = false;
13789         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
13790         return ret_val;
13791 }
13792
13793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13794         LDKPong this_ptr_conv;
13795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13796         this_ptr_conv.is_owned = false;
13797         Pong_set_byteslen(&this_ptr_conv, val);
13798 }
13799
13800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
13801         LDKPong ret_var = Pong_new(byteslen_arg);
13802         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13803         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13804         long ret_ref = (long)ret_var.inner;
13805         if (ret_var.is_owned) {
13806                 ret_ref |= 1;
13807         }
13808         return ret_ref;
13809 }
13810
13811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13812         LDKPong orig_conv;
13813         orig_conv.inner = (void*)(orig & (~1));
13814         orig_conv.is_owned = false;
13815         LDKPong ret_var = Pong_clone(&orig_conv);
13816         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13817         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13818         long ret_ref = (long)ret_var.inner;
13819         if (ret_var.is_owned) {
13820                 ret_ref |= 1;
13821         }
13822         return ret_ref;
13823 }
13824
13825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13826         LDKOpenChannel this_obj_conv;
13827         this_obj_conv.inner = (void*)(this_obj & (~1));
13828         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13829         OpenChannel_free(this_obj_conv);
13830 }
13831
13832 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
13833         LDKOpenChannel this_ptr_conv;
13834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13835         this_ptr_conv.is_owned = false;
13836         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13837         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
13838         return ret_arr;
13839 }
13840
13841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13842         LDKOpenChannel this_ptr_conv;
13843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13844         this_ptr_conv.is_owned = false;
13845         LDKThirtyTwoBytes val_ref;
13846         CHECK((*env)->GetArrayLength(env, val) == 32);
13847         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13848         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
13849 }
13850
13851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13852         LDKOpenChannel this_ptr_conv;
13853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13854         this_ptr_conv.is_owned = false;
13855         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13856         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
13857         return ret_arr;
13858 }
13859
13860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13861         LDKOpenChannel this_ptr_conv;
13862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13863         this_ptr_conv.is_owned = false;
13864         LDKThirtyTwoBytes val_ref;
13865         CHECK((*env)->GetArrayLength(env, val) == 32);
13866         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13867         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
13868 }
13869
13870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13871         LDKOpenChannel this_ptr_conv;
13872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13873         this_ptr_conv.is_owned = false;
13874         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
13875         return ret_val;
13876 }
13877
13878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13879         LDKOpenChannel this_ptr_conv;
13880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13881         this_ptr_conv.is_owned = false;
13882         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
13883 }
13884
13885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13886         LDKOpenChannel this_ptr_conv;
13887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13888         this_ptr_conv.is_owned = false;
13889         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
13890         return ret_val;
13891 }
13892
13893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13894         LDKOpenChannel this_ptr_conv;
13895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13896         this_ptr_conv.is_owned = false;
13897         OpenChannel_set_push_msat(&this_ptr_conv, val);
13898 }
13899
13900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13901         LDKOpenChannel this_ptr_conv;
13902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13903         this_ptr_conv.is_owned = false;
13904         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
13905         return ret_val;
13906 }
13907
13908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13909         LDKOpenChannel this_ptr_conv;
13910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13911         this_ptr_conv.is_owned = false;
13912         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
13913 }
13914
13915 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) {
13916         LDKOpenChannel this_ptr_conv;
13917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13918         this_ptr_conv.is_owned = false;
13919         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
13920         return ret_val;
13921 }
13922
13923 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) {
13924         LDKOpenChannel this_ptr_conv;
13925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13926         this_ptr_conv.is_owned = false;
13927         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13928 }
13929
13930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13931         LDKOpenChannel this_ptr_conv;
13932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13933         this_ptr_conv.is_owned = false;
13934         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
13935         return ret_val;
13936 }
13937
13938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13939         LDKOpenChannel this_ptr_conv;
13940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13941         this_ptr_conv.is_owned = false;
13942         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
13943 }
13944
13945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13946         LDKOpenChannel this_ptr_conv;
13947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13948         this_ptr_conv.is_owned = false;
13949         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
13950         return ret_val;
13951 }
13952
13953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13954         LDKOpenChannel this_ptr_conv;
13955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13956         this_ptr_conv.is_owned = false;
13957         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
13958 }
13959
13960 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
13961         LDKOpenChannel this_ptr_conv;
13962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13963         this_ptr_conv.is_owned = false;
13964         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
13965         return ret_val;
13966 }
13967
13968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13969         LDKOpenChannel this_ptr_conv;
13970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13971         this_ptr_conv.is_owned = false;
13972         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
13973 }
13974
13975 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13976         LDKOpenChannel this_ptr_conv;
13977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13978         this_ptr_conv.is_owned = false;
13979         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
13980         return ret_val;
13981 }
13982
13983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13984         LDKOpenChannel this_ptr_conv;
13985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13986         this_ptr_conv.is_owned = false;
13987         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
13988 }
13989
13990 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13991         LDKOpenChannel this_ptr_conv;
13992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13993         this_ptr_conv.is_owned = false;
13994         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
13995         return ret_val;
13996 }
13997
13998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13999         LDKOpenChannel this_ptr_conv;
14000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14001         this_ptr_conv.is_owned = false;
14002         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
14003 }
14004
14005 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14006         LDKOpenChannel this_ptr_conv;
14007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14008         this_ptr_conv.is_owned = false;
14009         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14010         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
14011         return ret_arr;
14012 }
14013
14014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14015         LDKOpenChannel this_ptr_conv;
14016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14017         this_ptr_conv.is_owned = false;
14018         LDKPublicKey val_ref;
14019         CHECK((*env)->GetArrayLength(env, val) == 33);
14020         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14021         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
14022 }
14023
14024 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14025         LDKOpenChannel this_ptr_conv;
14026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14027         this_ptr_conv.is_owned = false;
14028         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14029         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
14030         return ret_arr;
14031 }
14032
14033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14034         LDKOpenChannel this_ptr_conv;
14035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14036         this_ptr_conv.is_owned = false;
14037         LDKPublicKey val_ref;
14038         CHECK((*env)->GetArrayLength(env, val) == 33);
14039         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14040         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
14041 }
14042
14043 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14044         LDKOpenChannel this_ptr_conv;
14045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14046         this_ptr_conv.is_owned = false;
14047         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14048         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
14049         return ret_arr;
14050 }
14051
14052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14053         LDKOpenChannel this_ptr_conv;
14054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14055         this_ptr_conv.is_owned = false;
14056         LDKPublicKey val_ref;
14057         CHECK((*env)->GetArrayLength(env, val) == 33);
14058         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14059         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
14060 }
14061
14062 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14063         LDKOpenChannel this_ptr_conv;
14064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14065         this_ptr_conv.is_owned = false;
14066         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14067         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
14068         return ret_arr;
14069 }
14070
14071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14072         LDKOpenChannel this_ptr_conv;
14073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14074         this_ptr_conv.is_owned = false;
14075         LDKPublicKey val_ref;
14076         CHECK((*env)->GetArrayLength(env, val) == 33);
14077         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14078         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
14079 }
14080
14081 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14082         LDKOpenChannel this_ptr_conv;
14083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14084         this_ptr_conv.is_owned = false;
14085         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14086         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
14087         return ret_arr;
14088 }
14089
14090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14091         LDKOpenChannel this_ptr_conv;
14092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14093         this_ptr_conv.is_owned = false;
14094         LDKPublicKey val_ref;
14095         CHECK((*env)->GetArrayLength(env, val) == 33);
14096         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14097         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
14098 }
14099
14100 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14101         LDKOpenChannel this_ptr_conv;
14102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14103         this_ptr_conv.is_owned = false;
14104         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14105         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
14106         return ret_arr;
14107 }
14108
14109 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) {
14110         LDKOpenChannel this_ptr_conv;
14111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14112         this_ptr_conv.is_owned = false;
14113         LDKPublicKey val_ref;
14114         CHECK((*env)->GetArrayLength(env, val) == 33);
14115         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14116         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
14117 }
14118
14119 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
14120         LDKOpenChannel this_ptr_conv;
14121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14122         this_ptr_conv.is_owned = false;
14123         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
14124         return ret_val;
14125 }
14126
14127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
14128         LDKOpenChannel this_ptr_conv;
14129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14130         this_ptr_conv.is_owned = false;
14131         OpenChannel_set_channel_flags(&this_ptr_conv, val);
14132 }
14133
14134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14135         LDKOpenChannel orig_conv;
14136         orig_conv.inner = (void*)(orig & (~1));
14137         orig_conv.is_owned = false;
14138         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
14139         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14140         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14141         long ret_ref = (long)ret_var.inner;
14142         if (ret_var.is_owned) {
14143                 ret_ref |= 1;
14144         }
14145         return ret_ref;
14146 }
14147
14148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14149         LDKAcceptChannel this_obj_conv;
14150         this_obj_conv.inner = (void*)(this_obj & (~1));
14151         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14152         AcceptChannel_free(this_obj_conv);
14153 }
14154
14155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14156         LDKAcceptChannel this_ptr_conv;
14157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14158         this_ptr_conv.is_owned = false;
14159         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14160         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
14161         return ret_arr;
14162 }
14163
14164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14165         LDKAcceptChannel this_ptr_conv;
14166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14167         this_ptr_conv.is_owned = false;
14168         LDKThirtyTwoBytes val_ref;
14169         CHECK((*env)->GetArrayLength(env, val) == 32);
14170         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14171         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
14172 }
14173
14174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14175         LDKAcceptChannel this_ptr_conv;
14176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14177         this_ptr_conv.is_owned = false;
14178         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
14179         return ret_val;
14180 }
14181
14182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14183         LDKAcceptChannel this_ptr_conv;
14184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14185         this_ptr_conv.is_owned = false;
14186         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
14187 }
14188
14189 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) {
14190         LDKAcceptChannel this_ptr_conv;
14191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14192         this_ptr_conv.is_owned = false;
14193         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
14194         return ret_val;
14195 }
14196
14197 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) {
14198         LDKAcceptChannel this_ptr_conv;
14199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14200         this_ptr_conv.is_owned = false;
14201         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
14202 }
14203
14204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14205         LDKAcceptChannel this_ptr_conv;
14206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14207         this_ptr_conv.is_owned = false;
14208         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
14209         return ret_val;
14210 }
14211
14212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14213         LDKAcceptChannel this_ptr_conv;
14214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14215         this_ptr_conv.is_owned = false;
14216         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
14217 }
14218
14219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14220         LDKAcceptChannel this_ptr_conv;
14221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14222         this_ptr_conv.is_owned = false;
14223         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
14224         return ret_val;
14225 }
14226
14227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14228         LDKAcceptChannel this_ptr_conv;
14229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14230         this_ptr_conv.is_owned = false;
14231         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
14232 }
14233
14234 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
14235         LDKAcceptChannel this_ptr_conv;
14236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14237         this_ptr_conv.is_owned = false;
14238         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
14239         return ret_val;
14240 }
14241
14242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14243         LDKAcceptChannel this_ptr_conv;
14244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14245         this_ptr_conv.is_owned = false;
14246         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
14247 }
14248
14249 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
14250         LDKAcceptChannel this_ptr_conv;
14251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14252         this_ptr_conv.is_owned = false;
14253         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
14254         return ret_val;
14255 }
14256
14257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14258         LDKAcceptChannel this_ptr_conv;
14259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14260         this_ptr_conv.is_owned = false;
14261         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
14262 }
14263
14264 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
14265         LDKAcceptChannel this_ptr_conv;
14266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14267         this_ptr_conv.is_owned = false;
14268         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
14269         return ret_val;
14270 }
14271
14272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14273         LDKAcceptChannel this_ptr_conv;
14274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14275         this_ptr_conv.is_owned = false;
14276         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
14277 }
14278
14279 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14280         LDKAcceptChannel this_ptr_conv;
14281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14282         this_ptr_conv.is_owned = false;
14283         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14284         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
14285         return ret_arr;
14286 }
14287
14288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14289         LDKAcceptChannel this_ptr_conv;
14290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14291         this_ptr_conv.is_owned = false;
14292         LDKPublicKey val_ref;
14293         CHECK((*env)->GetArrayLength(env, val) == 33);
14294         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14295         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
14296 }
14297
14298 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14299         LDKAcceptChannel this_ptr_conv;
14300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14301         this_ptr_conv.is_owned = false;
14302         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14303         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
14304         return ret_arr;
14305 }
14306
14307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14308         LDKAcceptChannel this_ptr_conv;
14309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14310         this_ptr_conv.is_owned = false;
14311         LDKPublicKey val_ref;
14312         CHECK((*env)->GetArrayLength(env, val) == 33);
14313         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14314         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
14315 }
14316
14317 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14318         LDKAcceptChannel this_ptr_conv;
14319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14320         this_ptr_conv.is_owned = false;
14321         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14322         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
14323         return ret_arr;
14324 }
14325
14326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14327         LDKAcceptChannel this_ptr_conv;
14328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14329         this_ptr_conv.is_owned = false;
14330         LDKPublicKey val_ref;
14331         CHECK((*env)->GetArrayLength(env, val) == 33);
14332         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14333         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
14334 }
14335
14336 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14337         LDKAcceptChannel this_ptr_conv;
14338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14339         this_ptr_conv.is_owned = false;
14340         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14341         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
14342         return ret_arr;
14343 }
14344
14345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14346         LDKAcceptChannel this_ptr_conv;
14347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14348         this_ptr_conv.is_owned = false;
14349         LDKPublicKey val_ref;
14350         CHECK((*env)->GetArrayLength(env, val) == 33);
14351         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14352         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
14353 }
14354
14355 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14356         LDKAcceptChannel this_ptr_conv;
14357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14358         this_ptr_conv.is_owned = false;
14359         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14360         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
14361         return ret_arr;
14362 }
14363
14364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14365         LDKAcceptChannel this_ptr_conv;
14366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14367         this_ptr_conv.is_owned = false;
14368         LDKPublicKey val_ref;
14369         CHECK((*env)->GetArrayLength(env, val) == 33);
14370         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14371         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
14372 }
14373
14374 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14375         LDKAcceptChannel this_ptr_conv;
14376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14377         this_ptr_conv.is_owned = false;
14378         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14379         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
14380         return ret_arr;
14381 }
14382
14383 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) {
14384         LDKAcceptChannel this_ptr_conv;
14385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14386         this_ptr_conv.is_owned = false;
14387         LDKPublicKey val_ref;
14388         CHECK((*env)->GetArrayLength(env, val) == 33);
14389         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14390         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
14391 }
14392
14393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14394         LDKAcceptChannel orig_conv;
14395         orig_conv.inner = (void*)(orig & (~1));
14396         orig_conv.is_owned = false;
14397         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
14398         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14399         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14400         long ret_ref = (long)ret_var.inner;
14401         if (ret_var.is_owned) {
14402                 ret_ref |= 1;
14403         }
14404         return ret_ref;
14405 }
14406
14407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14408         LDKFundingCreated this_obj_conv;
14409         this_obj_conv.inner = (void*)(this_obj & (~1));
14410         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14411         FundingCreated_free(this_obj_conv);
14412 }
14413
14414 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14415         LDKFundingCreated this_ptr_conv;
14416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14417         this_ptr_conv.is_owned = false;
14418         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14419         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
14420         return ret_arr;
14421 }
14422
14423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14424         LDKFundingCreated this_ptr_conv;
14425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14426         this_ptr_conv.is_owned = false;
14427         LDKThirtyTwoBytes val_ref;
14428         CHECK((*env)->GetArrayLength(env, val) == 32);
14429         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14430         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
14431 }
14432
14433 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
14434         LDKFundingCreated this_ptr_conv;
14435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14436         this_ptr_conv.is_owned = false;
14437         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14438         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
14439         return ret_arr;
14440 }
14441
14442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14443         LDKFundingCreated this_ptr_conv;
14444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14445         this_ptr_conv.is_owned = false;
14446         LDKThirtyTwoBytes val_ref;
14447         CHECK((*env)->GetArrayLength(env, val) == 32);
14448         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14449         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
14450 }
14451
14452 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
14453         LDKFundingCreated this_ptr_conv;
14454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14455         this_ptr_conv.is_owned = false;
14456         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
14457         return ret_val;
14458 }
14459
14460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14461         LDKFundingCreated this_ptr_conv;
14462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14463         this_ptr_conv.is_owned = false;
14464         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
14465 }
14466
14467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14468         LDKFundingCreated this_ptr_conv;
14469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14470         this_ptr_conv.is_owned = false;
14471         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14472         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
14473         return ret_arr;
14474 }
14475
14476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14477         LDKFundingCreated this_ptr_conv;
14478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14479         this_ptr_conv.is_owned = false;
14480         LDKSignature val_ref;
14481         CHECK((*env)->GetArrayLength(env, val) == 64);
14482         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14483         FundingCreated_set_signature(&this_ptr_conv, val_ref);
14484 }
14485
14486 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) {
14487         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
14488         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
14489         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
14490         LDKThirtyTwoBytes funding_txid_arg_ref;
14491         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
14492         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
14493         LDKSignature signature_arg_ref;
14494         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
14495         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
14496         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
14497         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14498         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14499         long ret_ref = (long)ret_var.inner;
14500         if (ret_var.is_owned) {
14501                 ret_ref |= 1;
14502         }
14503         return ret_ref;
14504 }
14505
14506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14507         LDKFundingCreated orig_conv;
14508         orig_conv.inner = (void*)(orig & (~1));
14509         orig_conv.is_owned = false;
14510         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
14511         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14512         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14513         long ret_ref = (long)ret_var.inner;
14514         if (ret_var.is_owned) {
14515                 ret_ref |= 1;
14516         }
14517         return ret_ref;
14518 }
14519
14520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14521         LDKFundingSigned this_obj_conv;
14522         this_obj_conv.inner = (void*)(this_obj & (~1));
14523         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14524         FundingSigned_free(this_obj_conv);
14525 }
14526
14527 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14528         LDKFundingSigned this_ptr_conv;
14529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14530         this_ptr_conv.is_owned = false;
14531         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14532         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
14533         return ret_arr;
14534 }
14535
14536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14537         LDKFundingSigned this_ptr_conv;
14538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14539         this_ptr_conv.is_owned = false;
14540         LDKThirtyTwoBytes val_ref;
14541         CHECK((*env)->GetArrayLength(env, val) == 32);
14542         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14543         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
14544 }
14545
14546 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14547         LDKFundingSigned this_ptr_conv;
14548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14549         this_ptr_conv.is_owned = false;
14550         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14551         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
14552         return ret_arr;
14553 }
14554
14555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14556         LDKFundingSigned this_ptr_conv;
14557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14558         this_ptr_conv.is_owned = false;
14559         LDKSignature val_ref;
14560         CHECK((*env)->GetArrayLength(env, val) == 64);
14561         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14562         FundingSigned_set_signature(&this_ptr_conv, val_ref);
14563 }
14564
14565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
14566         LDKThirtyTwoBytes channel_id_arg_ref;
14567         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14568         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14569         LDKSignature signature_arg_ref;
14570         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
14571         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
14572         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
14573         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14574         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14575         long ret_ref = (long)ret_var.inner;
14576         if (ret_var.is_owned) {
14577                 ret_ref |= 1;
14578         }
14579         return ret_ref;
14580 }
14581
14582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14583         LDKFundingSigned orig_conv;
14584         orig_conv.inner = (void*)(orig & (~1));
14585         orig_conv.is_owned = false;
14586         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
14587         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14588         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14589         long ret_ref = (long)ret_var.inner;
14590         if (ret_var.is_owned) {
14591                 ret_ref |= 1;
14592         }
14593         return ret_ref;
14594 }
14595
14596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14597         LDKFundingLocked this_obj_conv;
14598         this_obj_conv.inner = (void*)(this_obj & (~1));
14599         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14600         FundingLocked_free(this_obj_conv);
14601 }
14602
14603 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14604         LDKFundingLocked this_ptr_conv;
14605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14606         this_ptr_conv.is_owned = false;
14607         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14608         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
14609         return ret_arr;
14610 }
14611
14612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14613         LDKFundingLocked this_ptr_conv;
14614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14615         this_ptr_conv.is_owned = false;
14616         LDKThirtyTwoBytes val_ref;
14617         CHECK((*env)->GetArrayLength(env, val) == 32);
14618         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14619         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
14620 }
14621
14622 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14623         LDKFundingLocked this_ptr_conv;
14624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14625         this_ptr_conv.is_owned = false;
14626         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14627         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
14628         return ret_arr;
14629 }
14630
14631 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) {
14632         LDKFundingLocked this_ptr_conv;
14633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14634         this_ptr_conv.is_owned = false;
14635         LDKPublicKey val_ref;
14636         CHECK((*env)->GetArrayLength(env, val) == 33);
14637         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14638         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
14639 }
14640
14641 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) {
14642         LDKThirtyTwoBytes channel_id_arg_ref;
14643         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14644         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14645         LDKPublicKey next_per_commitment_point_arg_ref;
14646         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
14647         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
14648         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
14649         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14650         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14651         long ret_ref = (long)ret_var.inner;
14652         if (ret_var.is_owned) {
14653                 ret_ref |= 1;
14654         }
14655         return ret_ref;
14656 }
14657
14658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14659         LDKFundingLocked orig_conv;
14660         orig_conv.inner = (void*)(orig & (~1));
14661         orig_conv.is_owned = false;
14662         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
14663         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14664         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14665         long ret_ref = (long)ret_var.inner;
14666         if (ret_var.is_owned) {
14667                 ret_ref |= 1;
14668         }
14669         return ret_ref;
14670 }
14671
14672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14673         LDKShutdown this_obj_conv;
14674         this_obj_conv.inner = (void*)(this_obj & (~1));
14675         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14676         Shutdown_free(this_obj_conv);
14677 }
14678
14679 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14680         LDKShutdown this_ptr_conv;
14681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14682         this_ptr_conv.is_owned = false;
14683         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14684         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
14685         return ret_arr;
14686 }
14687
14688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14689         LDKShutdown this_ptr_conv;
14690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14691         this_ptr_conv.is_owned = false;
14692         LDKThirtyTwoBytes val_ref;
14693         CHECK((*env)->GetArrayLength(env, val) == 32);
14694         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14695         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
14696 }
14697
14698 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14699         LDKShutdown this_ptr_conv;
14700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14701         this_ptr_conv.is_owned = false;
14702         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
14703         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14704         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14705         return ret_arr;
14706 }
14707
14708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14709         LDKShutdown this_ptr_conv;
14710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14711         this_ptr_conv.is_owned = false;
14712         LDKCVec_u8Z val_ref;
14713         val_ref.datalen = (*env)->GetArrayLength(env, val);
14714         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14715         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
14716         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
14717 }
14718
14719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
14720         LDKThirtyTwoBytes channel_id_arg_ref;
14721         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14722         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14723         LDKCVec_u8Z scriptpubkey_arg_ref;
14724         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
14725         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14726         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
14727         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
14728         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14729         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14730         long ret_ref = (long)ret_var.inner;
14731         if (ret_var.is_owned) {
14732                 ret_ref |= 1;
14733         }
14734         return ret_ref;
14735 }
14736
14737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14738         LDKShutdown orig_conv;
14739         orig_conv.inner = (void*)(orig & (~1));
14740         orig_conv.is_owned = false;
14741         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
14742         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14743         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14744         long ret_ref = (long)ret_var.inner;
14745         if (ret_var.is_owned) {
14746                 ret_ref |= 1;
14747         }
14748         return ret_ref;
14749 }
14750
14751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14752         LDKClosingSigned this_obj_conv;
14753         this_obj_conv.inner = (void*)(this_obj & (~1));
14754         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14755         ClosingSigned_free(this_obj_conv);
14756 }
14757
14758 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14759         LDKClosingSigned this_ptr_conv;
14760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14761         this_ptr_conv.is_owned = false;
14762         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14763         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
14764         return ret_arr;
14765 }
14766
14767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14768         LDKClosingSigned this_ptr_conv;
14769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14770         this_ptr_conv.is_owned = false;
14771         LDKThirtyTwoBytes val_ref;
14772         CHECK((*env)->GetArrayLength(env, val) == 32);
14773         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14774         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
14775 }
14776
14777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14778         LDKClosingSigned this_ptr_conv;
14779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14780         this_ptr_conv.is_owned = false;
14781         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
14782         return ret_val;
14783 }
14784
14785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14786         LDKClosingSigned this_ptr_conv;
14787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14788         this_ptr_conv.is_owned = false;
14789         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
14790 }
14791
14792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14793         LDKClosingSigned this_ptr_conv;
14794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14795         this_ptr_conv.is_owned = false;
14796         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14797         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
14798         return ret_arr;
14799 }
14800
14801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14802         LDKClosingSigned this_ptr_conv;
14803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14804         this_ptr_conv.is_owned = false;
14805         LDKSignature val_ref;
14806         CHECK((*env)->GetArrayLength(env, val) == 64);
14807         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14808         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
14809 }
14810
14811 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) {
14812         LDKThirtyTwoBytes channel_id_arg_ref;
14813         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14814         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14815         LDKSignature signature_arg_ref;
14816         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
14817         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
14818         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
14819         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14820         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14821         long ret_ref = (long)ret_var.inner;
14822         if (ret_var.is_owned) {
14823                 ret_ref |= 1;
14824         }
14825         return ret_ref;
14826 }
14827
14828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14829         LDKClosingSigned orig_conv;
14830         orig_conv.inner = (void*)(orig & (~1));
14831         orig_conv.is_owned = false;
14832         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
14833         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14834         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14835         long ret_ref = (long)ret_var.inner;
14836         if (ret_var.is_owned) {
14837                 ret_ref |= 1;
14838         }
14839         return ret_ref;
14840 }
14841
14842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14843         LDKUpdateAddHTLC this_obj_conv;
14844         this_obj_conv.inner = (void*)(this_obj & (~1));
14845         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14846         UpdateAddHTLC_free(this_obj_conv);
14847 }
14848
14849 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14850         LDKUpdateAddHTLC this_ptr_conv;
14851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14852         this_ptr_conv.is_owned = false;
14853         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14854         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
14855         return ret_arr;
14856 }
14857
14858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14859         LDKUpdateAddHTLC this_ptr_conv;
14860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14861         this_ptr_conv.is_owned = false;
14862         LDKThirtyTwoBytes val_ref;
14863         CHECK((*env)->GetArrayLength(env, val) == 32);
14864         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14865         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
14866 }
14867
14868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14869         LDKUpdateAddHTLC this_ptr_conv;
14870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14871         this_ptr_conv.is_owned = false;
14872         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
14873         return ret_val;
14874 }
14875
14876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14877         LDKUpdateAddHTLC this_ptr_conv;
14878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14879         this_ptr_conv.is_owned = false;
14880         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
14881 }
14882
14883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14884         LDKUpdateAddHTLC this_ptr_conv;
14885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14886         this_ptr_conv.is_owned = false;
14887         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
14888         return ret_val;
14889 }
14890
14891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14892         LDKUpdateAddHTLC this_ptr_conv;
14893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14894         this_ptr_conv.is_owned = false;
14895         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
14896 }
14897
14898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14899         LDKUpdateAddHTLC this_ptr_conv;
14900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14901         this_ptr_conv.is_owned = false;
14902         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14903         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
14904         return ret_arr;
14905 }
14906
14907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14908         LDKUpdateAddHTLC this_ptr_conv;
14909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14910         this_ptr_conv.is_owned = false;
14911         LDKThirtyTwoBytes val_ref;
14912         CHECK((*env)->GetArrayLength(env, val) == 32);
14913         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14914         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
14915 }
14916
14917 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
14918         LDKUpdateAddHTLC this_ptr_conv;
14919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14920         this_ptr_conv.is_owned = false;
14921         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
14922         return ret_val;
14923 }
14924
14925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14926         LDKUpdateAddHTLC this_ptr_conv;
14927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14928         this_ptr_conv.is_owned = false;
14929         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
14930 }
14931
14932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14933         LDKUpdateAddHTLC orig_conv;
14934         orig_conv.inner = (void*)(orig & (~1));
14935         orig_conv.is_owned = false;
14936         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
14937         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14938         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14939         long ret_ref = (long)ret_var.inner;
14940         if (ret_var.is_owned) {
14941                 ret_ref |= 1;
14942         }
14943         return ret_ref;
14944 }
14945
14946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14947         LDKUpdateFulfillHTLC this_obj_conv;
14948         this_obj_conv.inner = (void*)(this_obj & (~1));
14949         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14950         UpdateFulfillHTLC_free(this_obj_conv);
14951 }
14952
14953 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14954         LDKUpdateFulfillHTLC this_ptr_conv;
14955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14956         this_ptr_conv.is_owned = false;
14957         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14958         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
14959         return ret_arr;
14960 }
14961
14962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14963         LDKUpdateFulfillHTLC this_ptr_conv;
14964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14965         this_ptr_conv.is_owned = false;
14966         LDKThirtyTwoBytes val_ref;
14967         CHECK((*env)->GetArrayLength(env, val) == 32);
14968         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14969         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
14970 }
14971
14972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14973         LDKUpdateFulfillHTLC this_ptr_conv;
14974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14975         this_ptr_conv.is_owned = false;
14976         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
14977         return ret_val;
14978 }
14979
14980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14981         LDKUpdateFulfillHTLC this_ptr_conv;
14982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14983         this_ptr_conv.is_owned = false;
14984         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
14985 }
14986
14987 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
14988         LDKUpdateFulfillHTLC this_ptr_conv;
14989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14990         this_ptr_conv.is_owned = false;
14991         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14992         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
14993         return ret_arr;
14994 }
14995
14996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14997         LDKUpdateFulfillHTLC this_ptr_conv;
14998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14999         this_ptr_conv.is_owned = false;
15000         LDKThirtyTwoBytes val_ref;
15001         CHECK((*env)->GetArrayLength(env, val) == 32);
15002         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15003         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
15004 }
15005
15006 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) {
15007         LDKThirtyTwoBytes channel_id_arg_ref;
15008         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
15009         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
15010         LDKThirtyTwoBytes payment_preimage_arg_ref;
15011         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
15012         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
15013         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
15014         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15015         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15016         long ret_ref = (long)ret_var.inner;
15017         if (ret_var.is_owned) {
15018                 ret_ref |= 1;
15019         }
15020         return ret_ref;
15021 }
15022
15023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15024         LDKUpdateFulfillHTLC orig_conv;
15025         orig_conv.inner = (void*)(orig & (~1));
15026         orig_conv.is_owned = false;
15027         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
15028         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15029         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15030         long ret_ref = (long)ret_var.inner;
15031         if (ret_var.is_owned) {
15032                 ret_ref |= 1;
15033         }
15034         return ret_ref;
15035 }
15036
15037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15038         LDKUpdateFailHTLC this_obj_conv;
15039         this_obj_conv.inner = (void*)(this_obj & (~1));
15040         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15041         UpdateFailHTLC_free(this_obj_conv);
15042 }
15043
15044 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15045         LDKUpdateFailHTLC this_ptr_conv;
15046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15047         this_ptr_conv.is_owned = false;
15048         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15049         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
15050         return ret_arr;
15051 }
15052
15053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15054         LDKUpdateFailHTLC this_ptr_conv;
15055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15056         this_ptr_conv.is_owned = false;
15057         LDKThirtyTwoBytes val_ref;
15058         CHECK((*env)->GetArrayLength(env, val) == 32);
15059         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15060         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
15061 }
15062
15063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15064         LDKUpdateFailHTLC this_ptr_conv;
15065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15066         this_ptr_conv.is_owned = false;
15067         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
15068         return ret_val;
15069 }
15070
15071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15072         LDKUpdateFailHTLC this_ptr_conv;
15073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15074         this_ptr_conv.is_owned = false;
15075         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
15076 }
15077
15078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15079         LDKUpdateFailHTLC orig_conv;
15080         orig_conv.inner = (void*)(orig & (~1));
15081         orig_conv.is_owned = false;
15082         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
15083         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15084         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15085         long ret_ref = (long)ret_var.inner;
15086         if (ret_var.is_owned) {
15087                 ret_ref |= 1;
15088         }
15089         return ret_ref;
15090 }
15091
15092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15093         LDKUpdateFailMalformedHTLC this_obj_conv;
15094         this_obj_conv.inner = (void*)(this_obj & (~1));
15095         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15096         UpdateFailMalformedHTLC_free(this_obj_conv);
15097 }
15098
15099 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15100         LDKUpdateFailMalformedHTLC this_ptr_conv;
15101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15102         this_ptr_conv.is_owned = false;
15103         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15104         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
15105         return ret_arr;
15106 }
15107
15108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15109         LDKUpdateFailMalformedHTLC this_ptr_conv;
15110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15111         this_ptr_conv.is_owned = false;
15112         LDKThirtyTwoBytes val_ref;
15113         CHECK((*env)->GetArrayLength(env, val) == 32);
15114         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15115         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
15116 }
15117
15118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15119         LDKUpdateFailMalformedHTLC this_ptr_conv;
15120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15121         this_ptr_conv.is_owned = false;
15122         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
15123         return ret_val;
15124 }
15125
15126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15127         LDKUpdateFailMalformedHTLC this_ptr_conv;
15128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15129         this_ptr_conv.is_owned = false;
15130         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
15131 }
15132
15133 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
15134         LDKUpdateFailMalformedHTLC this_ptr_conv;
15135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15136         this_ptr_conv.is_owned = false;
15137         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
15138         return ret_val;
15139 }
15140
15141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15142         LDKUpdateFailMalformedHTLC this_ptr_conv;
15143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15144         this_ptr_conv.is_owned = false;
15145         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
15146 }
15147
15148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15149         LDKUpdateFailMalformedHTLC orig_conv;
15150         orig_conv.inner = (void*)(orig & (~1));
15151         orig_conv.is_owned = false;
15152         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
15153         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15154         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15155         long ret_ref = (long)ret_var.inner;
15156         if (ret_var.is_owned) {
15157                 ret_ref |= 1;
15158         }
15159         return ret_ref;
15160 }
15161
15162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15163         LDKCommitmentSigned this_obj_conv;
15164         this_obj_conv.inner = (void*)(this_obj & (~1));
15165         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15166         CommitmentSigned_free(this_obj_conv);
15167 }
15168
15169 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15170         LDKCommitmentSigned this_ptr_conv;
15171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15172         this_ptr_conv.is_owned = false;
15173         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15174         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
15175         return ret_arr;
15176 }
15177
15178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15179         LDKCommitmentSigned this_ptr_conv;
15180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15181         this_ptr_conv.is_owned = false;
15182         LDKThirtyTwoBytes val_ref;
15183         CHECK((*env)->GetArrayLength(env, val) == 32);
15184         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15185         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
15186 }
15187
15188 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15189         LDKCommitmentSigned this_ptr_conv;
15190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15191         this_ptr_conv.is_owned = false;
15192         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15193         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
15194         return ret_arr;
15195 }
15196
15197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15198         LDKCommitmentSigned this_ptr_conv;
15199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15200         this_ptr_conv.is_owned = false;
15201         LDKSignature val_ref;
15202         CHECK((*env)->GetArrayLength(env, val) == 64);
15203         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15204         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
15205 }
15206
15207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
15208         LDKCommitmentSigned this_ptr_conv;
15209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15210         this_ptr_conv.is_owned = false;
15211         LDKCVec_SignatureZ val_constr;
15212         val_constr.datalen = (*env)->GetArrayLength(env, val);
15213         if (val_constr.datalen > 0)
15214                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15215         else
15216                 val_constr.data = NULL;
15217         for (size_t i = 0; i < val_constr.datalen; i++) {
15218                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
15219                 LDKSignature val_conv_8_ref;
15220                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
15221                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
15222                 val_constr.data[i] = val_conv_8_ref;
15223         }
15224         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
15225 }
15226
15227 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) {
15228         LDKThirtyTwoBytes channel_id_arg_ref;
15229         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
15230         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
15231         LDKSignature signature_arg_ref;
15232         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
15233         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
15234         LDKCVec_SignatureZ htlc_signatures_arg_constr;
15235         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
15236         if (htlc_signatures_arg_constr.datalen > 0)
15237                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15238         else
15239                 htlc_signatures_arg_constr.data = NULL;
15240         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
15241                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
15242                 LDKSignature htlc_signatures_arg_conv_8_ref;
15243                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
15244                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
15245                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
15246         }
15247         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
15248         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15249         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15250         long ret_ref = (long)ret_var.inner;
15251         if (ret_var.is_owned) {
15252                 ret_ref |= 1;
15253         }
15254         return ret_ref;
15255 }
15256
15257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15258         LDKCommitmentSigned orig_conv;
15259         orig_conv.inner = (void*)(orig & (~1));
15260         orig_conv.is_owned = false;
15261         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
15262         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15263         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15264         long ret_ref = (long)ret_var.inner;
15265         if (ret_var.is_owned) {
15266                 ret_ref |= 1;
15267         }
15268         return ret_ref;
15269 }
15270
15271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15272         LDKRevokeAndACK this_obj_conv;
15273         this_obj_conv.inner = (void*)(this_obj & (~1));
15274         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15275         RevokeAndACK_free(this_obj_conv);
15276 }
15277
15278 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15279         LDKRevokeAndACK this_ptr_conv;
15280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15281         this_ptr_conv.is_owned = false;
15282         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15283         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
15284         return ret_arr;
15285 }
15286
15287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15288         LDKRevokeAndACK this_ptr_conv;
15289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15290         this_ptr_conv.is_owned = false;
15291         LDKThirtyTwoBytes val_ref;
15292         CHECK((*env)->GetArrayLength(env, val) == 32);
15293         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15294         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
15295 }
15296
15297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
15298         LDKRevokeAndACK this_ptr_conv;
15299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15300         this_ptr_conv.is_owned = false;
15301         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15302         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
15303         return ret_arr;
15304 }
15305
15306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15307         LDKRevokeAndACK this_ptr_conv;
15308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15309         this_ptr_conv.is_owned = false;
15310         LDKThirtyTwoBytes val_ref;
15311         CHECK((*env)->GetArrayLength(env, val) == 32);
15312         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15313         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
15314 }
15315
15316 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
15317         LDKRevokeAndACK this_ptr_conv;
15318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15319         this_ptr_conv.is_owned = false;
15320         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15321         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
15322         return ret_arr;
15323 }
15324
15325 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) {
15326         LDKRevokeAndACK this_ptr_conv;
15327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15328         this_ptr_conv.is_owned = false;
15329         LDKPublicKey val_ref;
15330         CHECK((*env)->GetArrayLength(env, val) == 33);
15331         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15332         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
15333 }
15334
15335 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) {
15336         LDKThirtyTwoBytes channel_id_arg_ref;
15337         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
15338         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
15339         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
15340         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
15341         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
15342         LDKPublicKey next_per_commitment_point_arg_ref;
15343         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
15344         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
15345         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
15346         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15347         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15348         long ret_ref = (long)ret_var.inner;
15349         if (ret_var.is_owned) {
15350                 ret_ref |= 1;
15351         }
15352         return ret_ref;
15353 }
15354
15355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15356         LDKRevokeAndACK orig_conv;
15357         orig_conv.inner = (void*)(orig & (~1));
15358         orig_conv.is_owned = false;
15359         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
15360         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15361         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15362         long ret_ref = (long)ret_var.inner;
15363         if (ret_var.is_owned) {
15364                 ret_ref |= 1;
15365         }
15366         return ret_ref;
15367 }
15368
15369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15370         LDKUpdateFee this_obj_conv;
15371         this_obj_conv.inner = (void*)(this_obj & (~1));
15372         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15373         UpdateFee_free(this_obj_conv);
15374 }
15375
15376 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15377         LDKUpdateFee this_ptr_conv;
15378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15379         this_ptr_conv.is_owned = false;
15380         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15381         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
15382         return ret_arr;
15383 }
15384
15385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15386         LDKUpdateFee this_ptr_conv;
15387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15388         this_ptr_conv.is_owned = false;
15389         LDKThirtyTwoBytes val_ref;
15390         CHECK((*env)->GetArrayLength(env, val) == 32);
15391         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15392         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
15393 }
15394
15395 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
15396         LDKUpdateFee this_ptr_conv;
15397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15398         this_ptr_conv.is_owned = false;
15399         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
15400         return ret_val;
15401 }
15402
15403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15404         LDKUpdateFee this_ptr_conv;
15405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15406         this_ptr_conv.is_owned = false;
15407         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
15408 }
15409
15410 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) {
15411         LDKThirtyTwoBytes channel_id_arg_ref;
15412         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
15413         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
15414         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
15415         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15416         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15417         long ret_ref = (long)ret_var.inner;
15418         if (ret_var.is_owned) {
15419                 ret_ref |= 1;
15420         }
15421         return ret_ref;
15422 }
15423
15424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15425         LDKUpdateFee orig_conv;
15426         orig_conv.inner = (void*)(orig & (~1));
15427         orig_conv.is_owned = false;
15428         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
15429         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15430         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15431         long ret_ref = (long)ret_var.inner;
15432         if (ret_var.is_owned) {
15433                 ret_ref |= 1;
15434         }
15435         return ret_ref;
15436 }
15437
15438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15439         LDKDataLossProtect this_obj_conv;
15440         this_obj_conv.inner = (void*)(this_obj & (~1));
15441         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15442         DataLossProtect_free(this_obj_conv);
15443 }
15444
15445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
15446         LDKDataLossProtect this_ptr_conv;
15447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15448         this_ptr_conv.is_owned = false;
15449         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15450         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
15451         return ret_arr;
15452 }
15453
15454 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) {
15455         LDKDataLossProtect this_ptr_conv;
15456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15457         this_ptr_conv.is_owned = false;
15458         LDKThirtyTwoBytes val_ref;
15459         CHECK((*env)->GetArrayLength(env, val) == 32);
15460         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15461         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
15462 }
15463
15464 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
15465         LDKDataLossProtect this_ptr_conv;
15466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15467         this_ptr_conv.is_owned = false;
15468         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15469         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
15470         return ret_arr;
15471 }
15472
15473 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) {
15474         LDKDataLossProtect this_ptr_conv;
15475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15476         this_ptr_conv.is_owned = false;
15477         LDKPublicKey val_ref;
15478         CHECK((*env)->GetArrayLength(env, val) == 33);
15479         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15480         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
15481 }
15482
15483 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) {
15484         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
15485         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
15486         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
15487         LDKPublicKey my_current_per_commitment_point_arg_ref;
15488         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
15489         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
15490         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
15491         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15492         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15493         long ret_ref = (long)ret_var.inner;
15494         if (ret_var.is_owned) {
15495                 ret_ref |= 1;
15496         }
15497         return ret_ref;
15498 }
15499
15500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15501         LDKDataLossProtect orig_conv;
15502         orig_conv.inner = (void*)(orig & (~1));
15503         orig_conv.is_owned = false;
15504         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
15505         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15506         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15507         long ret_ref = (long)ret_var.inner;
15508         if (ret_var.is_owned) {
15509                 ret_ref |= 1;
15510         }
15511         return ret_ref;
15512 }
15513
15514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15515         LDKChannelReestablish this_obj_conv;
15516         this_obj_conv.inner = (void*)(this_obj & (~1));
15517         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15518         ChannelReestablish_free(this_obj_conv);
15519 }
15520
15521 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15522         LDKChannelReestablish this_ptr_conv;
15523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15524         this_ptr_conv.is_owned = false;
15525         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15526         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
15527         return ret_arr;
15528 }
15529
15530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15531         LDKChannelReestablish this_ptr_conv;
15532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15533         this_ptr_conv.is_owned = false;
15534         LDKThirtyTwoBytes val_ref;
15535         CHECK((*env)->GetArrayLength(env, val) == 32);
15536         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15537         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
15538 }
15539
15540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
15541         LDKChannelReestablish this_ptr_conv;
15542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15543         this_ptr_conv.is_owned = false;
15544         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
15545         return ret_val;
15546 }
15547
15548 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) {
15549         LDKChannelReestablish this_ptr_conv;
15550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15551         this_ptr_conv.is_owned = false;
15552         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
15553 }
15554
15555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
15556         LDKChannelReestablish this_ptr_conv;
15557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15558         this_ptr_conv.is_owned = false;
15559         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
15560         return ret_val;
15561 }
15562
15563 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) {
15564         LDKChannelReestablish this_ptr_conv;
15565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15566         this_ptr_conv.is_owned = false;
15567         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
15568 }
15569
15570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15571         LDKChannelReestablish orig_conv;
15572         orig_conv.inner = (void*)(orig & (~1));
15573         orig_conv.is_owned = false;
15574         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
15575         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15576         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15577         long ret_ref = (long)ret_var.inner;
15578         if (ret_var.is_owned) {
15579                 ret_ref |= 1;
15580         }
15581         return ret_ref;
15582 }
15583
15584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15585         LDKAnnouncementSignatures this_obj_conv;
15586         this_obj_conv.inner = (void*)(this_obj & (~1));
15587         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15588         AnnouncementSignatures_free(this_obj_conv);
15589 }
15590
15591 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15592         LDKAnnouncementSignatures this_ptr_conv;
15593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15594         this_ptr_conv.is_owned = false;
15595         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15596         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
15597         return ret_arr;
15598 }
15599
15600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15601         LDKAnnouncementSignatures this_ptr_conv;
15602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15603         this_ptr_conv.is_owned = false;
15604         LDKThirtyTwoBytes val_ref;
15605         CHECK((*env)->GetArrayLength(env, val) == 32);
15606         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15607         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
15608 }
15609
15610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15611         LDKAnnouncementSignatures this_ptr_conv;
15612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15613         this_ptr_conv.is_owned = false;
15614         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
15615         return ret_val;
15616 }
15617
15618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15619         LDKAnnouncementSignatures this_ptr_conv;
15620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15621         this_ptr_conv.is_owned = false;
15622         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
15623 }
15624
15625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15626         LDKAnnouncementSignatures this_ptr_conv;
15627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15628         this_ptr_conv.is_owned = false;
15629         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15630         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
15631         return ret_arr;
15632 }
15633
15634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15635         LDKAnnouncementSignatures this_ptr_conv;
15636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15637         this_ptr_conv.is_owned = false;
15638         LDKSignature val_ref;
15639         CHECK((*env)->GetArrayLength(env, val) == 64);
15640         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15641         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
15642 }
15643
15644 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15645         LDKAnnouncementSignatures this_ptr_conv;
15646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15647         this_ptr_conv.is_owned = false;
15648         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15649         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
15650         return ret_arr;
15651 }
15652
15653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15654         LDKAnnouncementSignatures this_ptr_conv;
15655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15656         this_ptr_conv.is_owned = false;
15657         LDKSignature val_ref;
15658         CHECK((*env)->GetArrayLength(env, val) == 64);
15659         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15660         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
15661 }
15662
15663 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) {
15664         LDKThirtyTwoBytes channel_id_arg_ref;
15665         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
15666         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
15667         LDKSignature node_signature_arg_ref;
15668         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
15669         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
15670         LDKSignature bitcoin_signature_arg_ref;
15671         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
15672         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
15673         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
15674         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15675         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15676         long ret_ref = (long)ret_var.inner;
15677         if (ret_var.is_owned) {
15678                 ret_ref |= 1;
15679         }
15680         return ret_ref;
15681 }
15682
15683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15684         LDKAnnouncementSignatures orig_conv;
15685         orig_conv.inner = (void*)(orig & (~1));
15686         orig_conv.is_owned = false;
15687         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
15688         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15689         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15690         long ret_ref = (long)ret_var.inner;
15691         if (ret_var.is_owned) {
15692                 ret_ref |= 1;
15693         }
15694         return ret_ref;
15695 }
15696
15697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15698         if ((this_ptr & 1) != 0) return;
15699         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
15700         FREE((void*)this_ptr);
15701         NetAddress_free(this_ptr_conv);
15702 }
15703
15704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15705         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
15706         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
15707         *ret_copy = NetAddress_clone(orig_conv);
15708         long ret_ref = (long)ret_copy;
15709         return ret_ref;
15710 }
15711
15712 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
15713         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
15714         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
15715         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15716         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15717         CVec_u8Z_free(ret_var);
15718         return ret_arr;
15719 }
15720
15721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15722         LDKu8slice ser_ref;
15723         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15724         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15725         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
15726         *ret_conv = Result_read(ser_ref);
15727         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15728         return (long)ret_conv;
15729 }
15730
15731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15732         LDKUnsignedNodeAnnouncement this_obj_conv;
15733         this_obj_conv.inner = (void*)(this_obj & (~1));
15734         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15735         UnsignedNodeAnnouncement_free(this_obj_conv);
15736 }
15737
15738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
15739         LDKUnsignedNodeAnnouncement this_ptr_conv;
15740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15741         this_ptr_conv.is_owned = false;
15742         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
15743         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15744         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15745         long ret_ref = (long)ret_var.inner;
15746         if (ret_var.is_owned) {
15747                 ret_ref |= 1;
15748         }
15749         return ret_ref;
15750 }
15751
15752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15753         LDKUnsignedNodeAnnouncement this_ptr_conv;
15754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15755         this_ptr_conv.is_owned = false;
15756         LDKNodeFeatures val_conv;
15757         val_conv.inner = (void*)(val & (~1));
15758         val_conv.is_owned = (val & 1) || (val == 0);
15759         val_conv = NodeFeatures_clone(&val_conv);
15760         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
15761 }
15762
15763 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
15764         LDKUnsignedNodeAnnouncement this_ptr_conv;
15765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15766         this_ptr_conv.is_owned = false;
15767         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
15768         return ret_val;
15769 }
15770
15771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15772         LDKUnsignedNodeAnnouncement this_ptr_conv;
15773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15774         this_ptr_conv.is_owned = false;
15775         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
15776 }
15777
15778 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15779         LDKUnsignedNodeAnnouncement this_ptr_conv;
15780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15781         this_ptr_conv.is_owned = false;
15782         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15783         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
15784         return ret_arr;
15785 }
15786
15787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15788         LDKUnsignedNodeAnnouncement this_ptr_conv;
15789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15790         this_ptr_conv.is_owned = false;
15791         LDKPublicKey val_ref;
15792         CHECK((*env)->GetArrayLength(env, val) == 33);
15793         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15794         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
15795 }
15796
15797 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
15798         LDKUnsignedNodeAnnouncement this_ptr_conv;
15799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15800         this_ptr_conv.is_owned = false;
15801         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
15802         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
15803         return ret_arr;
15804 }
15805
15806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15807         LDKUnsignedNodeAnnouncement this_ptr_conv;
15808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15809         this_ptr_conv.is_owned = false;
15810         LDKThreeBytes val_ref;
15811         CHECK((*env)->GetArrayLength(env, val) == 3);
15812         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
15813         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
15814 }
15815
15816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
15817         LDKUnsignedNodeAnnouncement this_ptr_conv;
15818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15819         this_ptr_conv.is_owned = false;
15820         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15821         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
15822         return ret_arr;
15823 }
15824
15825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15826         LDKUnsignedNodeAnnouncement this_ptr_conv;
15827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15828         this_ptr_conv.is_owned = false;
15829         LDKThirtyTwoBytes val_ref;
15830         CHECK((*env)->GetArrayLength(env, val) == 32);
15831         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15832         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
15833 }
15834
15835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
15836         LDKUnsignedNodeAnnouncement this_ptr_conv;
15837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15838         this_ptr_conv.is_owned = false;
15839         LDKCVec_NetAddressZ val_constr;
15840         val_constr.datalen = (*env)->GetArrayLength(env, val);
15841         if (val_constr.datalen > 0)
15842                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15843         else
15844                 val_constr.data = NULL;
15845         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
15846         for (size_t m = 0; m < val_constr.datalen; m++) {
15847                 int64_t val_conv_12 = val_vals[m];
15848                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
15849                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
15850                 val_constr.data[m] = val_conv_12_conv;
15851         }
15852         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
15853         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
15854 }
15855
15856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15857         LDKUnsignedNodeAnnouncement orig_conv;
15858         orig_conv.inner = (void*)(orig & (~1));
15859         orig_conv.is_owned = false;
15860         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
15861         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15862         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15863         long ret_ref = (long)ret_var.inner;
15864         if (ret_var.is_owned) {
15865                 ret_ref |= 1;
15866         }
15867         return ret_ref;
15868 }
15869
15870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15871         LDKNodeAnnouncement this_obj_conv;
15872         this_obj_conv.inner = (void*)(this_obj & (~1));
15873         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15874         NodeAnnouncement_free(this_obj_conv);
15875 }
15876
15877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15878         LDKNodeAnnouncement this_ptr_conv;
15879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15880         this_ptr_conv.is_owned = false;
15881         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15882         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
15883         return ret_arr;
15884 }
15885
15886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15887         LDKNodeAnnouncement this_ptr_conv;
15888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15889         this_ptr_conv.is_owned = false;
15890         LDKSignature val_ref;
15891         CHECK((*env)->GetArrayLength(env, val) == 64);
15892         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15893         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
15894 }
15895
15896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
15897         LDKNodeAnnouncement this_ptr_conv;
15898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15899         this_ptr_conv.is_owned = false;
15900         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
15901         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15902         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15903         long ret_ref = (long)ret_var.inner;
15904         if (ret_var.is_owned) {
15905                 ret_ref |= 1;
15906         }
15907         return ret_ref;
15908 }
15909
15910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15911         LDKNodeAnnouncement this_ptr_conv;
15912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15913         this_ptr_conv.is_owned = false;
15914         LDKUnsignedNodeAnnouncement val_conv;
15915         val_conv.inner = (void*)(val & (~1));
15916         val_conv.is_owned = (val & 1) || (val == 0);
15917         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
15918         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
15919 }
15920
15921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
15922         LDKSignature signature_arg_ref;
15923         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
15924         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
15925         LDKUnsignedNodeAnnouncement contents_arg_conv;
15926         contents_arg_conv.inner = (void*)(contents_arg & (~1));
15927         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
15928         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
15929         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
15930         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15931         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15932         long ret_ref = (long)ret_var.inner;
15933         if (ret_var.is_owned) {
15934                 ret_ref |= 1;
15935         }
15936         return ret_ref;
15937 }
15938
15939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15940         LDKNodeAnnouncement orig_conv;
15941         orig_conv.inner = (void*)(orig & (~1));
15942         orig_conv.is_owned = false;
15943         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
15944         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15945         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15946         long ret_ref = (long)ret_var.inner;
15947         if (ret_var.is_owned) {
15948                 ret_ref |= 1;
15949         }
15950         return ret_ref;
15951 }
15952
15953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15954         LDKUnsignedChannelAnnouncement this_obj_conv;
15955         this_obj_conv.inner = (void*)(this_obj & (~1));
15956         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15957         UnsignedChannelAnnouncement_free(this_obj_conv);
15958 }
15959
15960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
15961         LDKUnsignedChannelAnnouncement this_ptr_conv;
15962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15963         this_ptr_conv.is_owned = false;
15964         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
15965         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15966         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15967         long ret_ref = (long)ret_var.inner;
15968         if (ret_var.is_owned) {
15969                 ret_ref |= 1;
15970         }
15971         return ret_ref;
15972 }
15973
15974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15975         LDKUnsignedChannelAnnouncement this_ptr_conv;
15976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15977         this_ptr_conv.is_owned = false;
15978         LDKChannelFeatures val_conv;
15979         val_conv.inner = (void*)(val & (~1));
15980         val_conv.is_owned = (val & 1) || (val == 0);
15981         val_conv = ChannelFeatures_clone(&val_conv);
15982         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
15983 }
15984
15985 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15986         LDKUnsignedChannelAnnouncement this_ptr_conv;
15987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15988         this_ptr_conv.is_owned = false;
15989         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15990         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
15991         return ret_arr;
15992 }
15993
15994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15995         LDKUnsignedChannelAnnouncement this_ptr_conv;
15996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15997         this_ptr_conv.is_owned = false;
15998         LDKThirtyTwoBytes val_ref;
15999         CHECK((*env)->GetArrayLength(env, val) == 32);
16000         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16001         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
16002 }
16003
16004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16005         LDKUnsignedChannelAnnouncement this_ptr_conv;
16006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16007         this_ptr_conv.is_owned = false;
16008         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
16009         return ret_val;
16010 }
16011
16012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16013         LDKUnsignedChannelAnnouncement this_ptr_conv;
16014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16015         this_ptr_conv.is_owned = false;
16016         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
16017 }
16018
16019 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
16020         LDKUnsignedChannelAnnouncement this_ptr_conv;
16021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16022         this_ptr_conv.is_owned = false;
16023         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16024         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
16025         return ret_arr;
16026 }
16027
16028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16029         LDKUnsignedChannelAnnouncement this_ptr_conv;
16030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16031         this_ptr_conv.is_owned = false;
16032         LDKPublicKey val_ref;
16033         CHECK((*env)->GetArrayLength(env, val) == 33);
16034         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16035         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
16036 }
16037
16038 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
16039         LDKUnsignedChannelAnnouncement this_ptr_conv;
16040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16041         this_ptr_conv.is_owned = false;
16042         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16043         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
16044         return ret_arr;
16045 }
16046
16047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16048         LDKUnsignedChannelAnnouncement this_ptr_conv;
16049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16050         this_ptr_conv.is_owned = false;
16051         LDKPublicKey val_ref;
16052         CHECK((*env)->GetArrayLength(env, val) == 33);
16053         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16054         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
16055 }
16056
16057 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
16058         LDKUnsignedChannelAnnouncement this_ptr_conv;
16059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16060         this_ptr_conv.is_owned = false;
16061         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16062         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
16063         return ret_arr;
16064 }
16065
16066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16067         LDKUnsignedChannelAnnouncement this_ptr_conv;
16068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16069         this_ptr_conv.is_owned = false;
16070         LDKPublicKey val_ref;
16071         CHECK((*env)->GetArrayLength(env, val) == 33);
16072         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16073         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
16074 }
16075
16076 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
16077         LDKUnsignedChannelAnnouncement this_ptr_conv;
16078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16079         this_ptr_conv.is_owned = false;
16080         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16081         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
16082         return ret_arr;
16083 }
16084
16085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16086         LDKUnsignedChannelAnnouncement this_ptr_conv;
16087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16088         this_ptr_conv.is_owned = false;
16089         LDKPublicKey val_ref;
16090         CHECK((*env)->GetArrayLength(env, val) == 33);
16091         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16092         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
16093 }
16094
16095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16096         LDKUnsignedChannelAnnouncement orig_conv;
16097         orig_conv.inner = (void*)(orig & (~1));
16098         orig_conv.is_owned = false;
16099         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
16100         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16101         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16102         long ret_ref = (long)ret_var.inner;
16103         if (ret_var.is_owned) {
16104                 ret_ref |= 1;
16105         }
16106         return ret_ref;
16107 }
16108
16109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16110         LDKChannelAnnouncement this_obj_conv;
16111         this_obj_conv.inner = (void*)(this_obj & (~1));
16112         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16113         ChannelAnnouncement_free(this_obj_conv);
16114 }
16115
16116 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
16117         LDKChannelAnnouncement this_ptr_conv;
16118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16119         this_ptr_conv.is_owned = false;
16120         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
16121         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
16122         return ret_arr;
16123 }
16124
16125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16126         LDKChannelAnnouncement this_ptr_conv;
16127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16128         this_ptr_conv.is_owned = false;
16129         LDKSignature val_ref;
16130         CHECK((*env)->GetArrayLength(env, val) == 64);
16131         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
16132         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
16133 }
16134
16135 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
16136         LDKChannelAnnouncement this_ptr_conv;
16137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16138         this_ptr_conv.is_owned = false;
16139         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
16140         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
16141         return ret_arr;
16142 }
16143
16144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16145         LDKChannelAnnouncement this_ptr_conv;
16146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16147         this_ptr_conv.is_owned = false;
16148         LDKSignature val_ref;
16149         CHECK((*env)->GetArrayLength(env, val) == 64);
16150         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
16151         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
16152 }
16153
16154 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
16155         LDKChannelAnnouncement this_ptr_conv;
16156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16157         this_ptr_conv.is_owned = false;
16158         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
16159         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
16160         return ret_arr;
16161 }
16162
16163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16164         LDKChannelAnnouncement this_ptr_conv;
16165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16166         this_ptr_conv.is_owned = false;
16167         LDKSignature val_ref;
16168         CHECK((*env)->GetArrayLength(env, val) == 64);
16169         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
16170         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
16171 }
16172
16173 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
16174         LDKChannelAnnouncement this_ptr_conv;
16175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16176         this_ptr_conv.is_owned = false;
16177         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
16178         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
16179         return ret_arr;
16180 }
16181
16182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16183         LDKChannelAnnouncement this_ptr_conv;
16184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16185         this_ptr_conv.is_owned = false;
16186         LDKSignature val_ref;
16187         CHECK((*env)->GetArrayLength(env, val) == 64);
16188         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
16189         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
16190 }
16191
16192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
16193         LDKChannelAnnouncement this_ptr_conv;
16194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16195         this_ptr_conv.is_owned = false;
16196         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
16197         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16198         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16199         long ret_ref = (long)ret_var.inner;
16200         if (ret_var.is_owned) {
16201                 ret_ref |= 1;
16202         }
16203         return ret_ref;
16204 }
16205
16206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16207         LDKChannelAnnouncement this_ptr_conv;
16208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16209         this_ptr_conv.is_owned = false;
16210         LDKUnsignedChannelAnnouncement val_conv;
16211         val_conv.inner = (void*)(val & (~1));
16212         val_conv.is_owned = (val & 1) || (val == 0);
16213         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
16214         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
16215 }
16216
16217 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) {
16218         LDKSignature node_signature_1_arg_ref;
16219         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
16220         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
16221         LDKSignature node_signature_2_arg_ref;
16222         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
16223         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
16224         LDKSignature bitcoin_signature_1_arg_ref;
16225         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
16226         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
16227         LDKSignature bitcoin_signature_2_arg_ref;
16228         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
16229         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
16230         LDKUnsignedChannelAnnouncement contents_arg_conv;
16231         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16232         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16233         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
16234         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);
16235         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16236         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16237         long ret_ref = (long)ret_var.inner;
16238         if (ret_var.is_owned) {
16239                 ret_ref |= 1;
16240         }
16241         return ret_ref;
16242 }
16243
16244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16245         LDKChannelAnnouncement orig_conv;
16246         orig_conv.inner = (void*)(orig & (~1));
16247         orig_conv.is_owned = false;
16248         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
16249         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16250         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16251         long ret_ref = (long)ret_var.inner;
16252         if (ret_var.is_owned) {
16253                 ret_ref |= 1;
16254         }
16255         return ret_ref;
16256 }
16257
16258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16259         LDKUnsignedChannelUpdate this_obj_conv;
16260         this_obj_conv.inner = (void*)(this_obj & (~1));
16261         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16262         UnsignedChannelUpdate_free(this_obj_conv);
16263 }
16264
16265 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16266         LDKUnsignedChannelUpdate this_ptr_conv;
16267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16268         this_ptr_conv.is_owned = false;
16269         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16270         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
16271         return ret_arr;
16272 }
16273
16274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16275         LDKUnsignedChannelUpdate this_ptr_conv;
16276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16277         this_ptr_conv.is_owned = false;
16278         LDKThirtyTwoBytes val_ref;
16279         CHECK((*env)->GetArrayLength(env, val) == 32);
16280         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16281         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
16282 }
16283
16284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16285         LDKUnsignedChannelUpdate this_ptr_conv;
16286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16287         this_ptr_conv.is_owned = false;
16288         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
16289         return ret_val;
16290 }
16291
16292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16293         LDKUnsignedChannelUpdate this_ptr_conv;
16294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16295         this_ptr_conv.is_owned = false;
16296         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
16297 }
16298
16299 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
16300         LDKUnsignedChannelUpdate this_ptr_conv;
16301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16302         this_ptr_conv.is_owned = false;
16303         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
16304         return ret_val;
16305 }
16306
16307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16308         LDKUnsignedChannelUpdate this_ptr_conv;
16309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16310         this_ptr_conv.is_owned = false;
16311         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
16312 }
16313
16314 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
16315         LDKUnsignedChannelUpdate this_ptr_conv;
16316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16317         this_ptr_conv.is_owned = false;
16318         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
16319         return ret_val;
16320 }
16321
16322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
16323         LDKUnsignedChannelUpdate this_ptr_conv;
16324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16325         this_ptr_conv.is_owned = false;
16326         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
16327 }
16328
16329 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
16330         LDKUnsignedChannelUpdate this_ptr_conv;
16331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16332         this_ptr_conv.is_owned = false;
16333         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
16334         return ret_val;
16335 }
16336
16337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16338         LDKUnsignedChannelUpdate this_ptr_conv;
16339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16340         this_ptr_conv.is_owned = false;
16341         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
16342 }
16343
16344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16345         LDKUnsignedChannelUpdate this_ptr_conv;
16346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16347         this_ptr_conv.is_owned = false;
16348         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
16349         return ret_val;
16350 }
16351
16352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16353         LDKUnsignedChannelUpdate this_ptr_conv;
16354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16355         this_ptr_conv.is_owned = false;
16356         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
16357 }
16358
16359 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16360         LDKUnsignedChannelUpdate this_ptr_conv;
16361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16362         this_ptr_conv.is_owned = false;
16363         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
16364         return ret_val;
16365 }
16366
16367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16368         LDKUnsignedChannelUpdate this_ptr_conv;
16369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16370         this_ptr_conv.is_owned = false;
16371         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
16372 }
16373
16374 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
16375         LDKUnsignedChannelUpdate this_ptr_conv;
16376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16377         this_ptr_conv.is_owned = false;
16378         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
16379         return ret_val;
16380 }
16381
16382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16383         LDKUnsignedChannelUpdate this_ptr_conv;
16384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16385         this_ptr_conv.is_owned = false;
16386         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
16387 }
16388
16389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16390         LDKUnsignedChannelUpdate orig_conv;
16391         orig_conv.inner = (void*)(orig & (~1));
16392         orig_conv.is_owned = false;
16393         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
16394         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16395         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16396         long ret_ref = (long)ret_var.inner;
16397         if (ret_var.is_owned) {
16398                 ret_ref |= 1;
16399         }
16400         return ret_ref;
16401 }
16402
16403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16404         LDKChannelUpdate this_obj_conv;
16405         this_obj_conv.inner = (void*)(this_obj & (~1));
16406         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16407         ChannelUpdate_free(this_obj_conv);
16408 }
16409
16410 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
16411         LDKChannelUpdate this_ptr_conv;
16412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16413         this_ptr_conv.is_owned = false;
16414         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
16415         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
16416         return ret_arr;
16417 }
16418
16419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16420         LDKChannelUpdate this_ptr_conv;
16421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16422         this_ptr_conv.is_owned = false;
16423         LDKSignature val_ref;
16424         CHECK((*env)->GetArrayLength(env, val) == 64);
16425         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
16426         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
16427 }
16428
16429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
16430         LDKChannelUpdate this_ptr_conv;
16431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16432         this_ptr_conv.is_owned = false;
16433         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
16434         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16435         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16436         long ret_ref = (long)ret_var.inner;
16437         if (ret_var.is_owned) {
16438                 ret_ref |= 1;
16439         }
16440         return ret_ref;
16441 }
16442
16443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16444         LDKChannelUpdate this_ptr_conv;
16445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16446         this_ptr_conv.is_owned = false;
16447         LDKUnsignedChannelUpdate val_conv;
16448         val_conv.inner = (void*)(val & (~1));
16449         val_conv.is_owned = (val & 1) || (val == 0);
16450         val_conv = UnsignedChannelUpdate_clone(&val_conv);
16451         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
16452 }
16453
16454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
16455         LDKSignature signature_arg_ref;
16456         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
16457         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
16458         LDKUnsignedChannelUpdate contents_arg_conv;
16459         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16460         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16461         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
16462         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
16463         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16464         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16465         long ret_ref = (long)ret_var.inner;
16466         if (ret_var.is_owned) {
16467                 ret_ref |= 1;
16468         }
16469         return ret_ref;
16470 }
16471
16472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16473         LDKChannelUpdate orig_conv;
16474         orig_conv.inner = (void*)(orig & (~1));
16475         orig_conv.is_owned = false;
16476         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
16477         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16478         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16479         long ret_ref = (long)ret_var.inner;
16480         if (ret_var.is_owned) {
16481                 ret_ref |= 1;
16482         }
16483         return ret_ref;
16484 }
16485
16486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16487         LDKQueryChannelRange this_obj_conv;
16488         this_obj_conv.inner = (void*)(this_obj & (~1));
16489         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16490         QueryChannelRange_free(this_obj_conv);
16491 }
16492
16493 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16494         LDKQueryChannelRange this_ptr_conv;
16495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16496         this_ptr_conv.is_owned = false;
16497         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16498         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
16499         return ret_arr;
16500 }
16501
16502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16503         LDKQueryChannelRange this_ptr_conv;
16504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16505         this_ptr_conv.is_owned = false;
16506         LDKThirtyTwoBytes val_ref;
16507         CHECK((*env)->GetArrayLength(env, val) == 32);
16508         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16509         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
16510 }
16511
16512 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
16513         LDKQueryChannelRange this_ptr_conv;
16514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16515         this_ptr_conv.is_owned = false;
16516         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
16517         return ret_val;
16518 }
16519
16520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16521         LDKQueryChannelRange this_ptr_conv;
16522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16523         this_ptr_conv.is_owned = false;
16524         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
16525 }
16526
16527 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
16528         LDKQueryChannelRange this_ptr_conv;
16529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16530         this_ptr_conv.is_owned = false;
16531         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
16532         return ret_val;
16533 }
16534
16535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16536         LDKQueryChannelRange this_ptr_conv;
16537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16538         this_ptr_conv.is_owned = false;
16539         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
16540 }
16541
16542 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) {
16543         LDKThirtyTwoBytes chain_hash_arg_ref;
16544         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16545         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16546         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
16547         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16548         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16549         long ret_ref = (long)ret_var.inner;
16550         if (ret_var.is_owned) {
16551                 ret_ref |= 1;
16552         }
16553         return ret_ref;
16554 }
16555
16556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16557         LDKQueryChannelRange orig_conv;
16558         orig_conv.inner = (void*)(orig & (~1));
16559         orig_conv.is_owned = false;
16560         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
16561         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16562         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16563         long ret_ref = (long)ret_var.inner;
16564         if (ret_var.is_owned) {
16565                 ret_ref |= 1;
16566         }
16567         return ret_ref;
16568 }
16569
16570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16571         LDKReplyChannelRange this_obj_conv;
16572         this_obj_conv.inner = (void*)(this_obj & (~1));
16573         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16574         ReplyChannelRange_free(this_obj_conv);
16575 }
16576
16577 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16578         LDKReplyChannelRange this_ptr_conv;
16579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16580         this_ptr_conv.is_owned = false;
16581         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16582         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
16583         return ret_arr;
16584 }
16585
16586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16587         LDKReplyChannelRange this_ptr_conv;
16588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16589         this_ptr_conv.is_owned = false;
16590         LDKThirtyTwoBytes val_ref;
16591         CHECK((*env)->GetArrayLength(env, val) == 32);
16592         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16593         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
16594 }
16595
16596 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
16597         LDKReplyChannelRange this_ptr_conv;
16598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16599         this_ptr_conv.is_owned = false;
16600         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
16601         return ret_val;
16602 }
16603
16604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16605         LDKReplyChannelRange this_ptr_conv;
16606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16607         this_ptr_conv.is_owned = false;
16608         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
16609 }
16610
16611 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
16612         LDKReplyChannelRange this_ptr_conv;
16613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16614         this_ptr_conv.is_owned = false;
16615         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
16616         return ret_val;
16617 }
16618
16619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16620         LDKReplyChannelRange this_ptr_conv;
16621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16622         this_ptr_conv.is_owned = false;
16623         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
16624 }
16625
16626 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
16627         LDKReplyChannelRange this_ptr_conv;
16628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16629         this_ptr_conv.is_owned = false;
16630         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
16631         return ret_val;
16632 }
16633
16634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16635         LDKReplyChannelRange this_ptr_conv;
16636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16637         this_ptr_conv.is_owned = false;
16638         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
16639 }
16640
16641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16642         LDKReplyChannelRange this_ptr_conv;
16643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16644         this_ptr_conv.is_owned = false;
16645         LDKCVec_u64Z val_constr;
16646         val_constr.datalen = (*env)->GetArrayLength(env, val);
16647         if (val_constr.datalen > 0)
16648                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16649         else
16650                 val_constr.data = NULL;
16651         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16652         for (size_t g = 0; g < val_constr.datalen; g++) {
16653                 int64_t val_conv_6 = val_vals[g];
16654                 val_constr.data[g] = val_conv_6;
16655         }
16656         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16657         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
16658 }
16659
16660 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) {
16661         LDKThirtyTwoBytes chain_hash_arg_ref;
16662         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16663         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16664         LDKCVec_u64Z short_channel_ids_arg_constr;
16665         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
16666         if (short_channel_ids_arg_constr.datalen > 0)
16667                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16668         else
16669                 short_channel_ids_arg_constr.data = NULL;
16670         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
16671         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
16672                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
16673                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
16674         }
16675         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
16676         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
16677         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16678         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16679         long ret_ref = (long)ret_var.inner;
16680         if (ret_var.is_owned) {
16681                 ret_ref |= 1;
16682         }
16683         return ret_ref;
16684 }
16685
16686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16687         LDKReplyChannelRange orig_conv;
16688         orig_conv.inner = (void*)(orig & (~1));
16689         orig_conv.is_owned = false;
16690         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
16691         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16692         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16693         long ret_ref = (long)ret_var.inner;
16694         if (ret_var.is_owned) {
16695                 ret_ref |= 1;
16696         }
16697         return ret_ref;
16698 }
16699
16700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16701         LDKQueryShortChannelIds this_obj_conv;
16702         this_obj_conv.inner = (void*)(this_obj & (~1));
16703         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16704         QueryShortChannelIds_free(this_obj_conv);
16705 }
16706
16707 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16708         LDKQueryShortChannelIds this_ptr_conv;
16709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16710         this_ptr_conv.is_owned = false;
16711         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16712         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
16713         return ret_arr;
16714 }
16715
16716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16717         LDKQueryShortChannelIds this_ptr_conv;
16718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16719         this_ptr_conv.is_owned = false;
16720         LDKThirtyTwoBytes val_ref;
16721         CHECK((*env)->GetArrayLength(env, val) == 32);
16722         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16723         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
16724 }
16725
16726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
16727         LDKQueryShortChannelIds this_ptr_conv;
16728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16729         this_ptr_conv.is_owned = false;
16730         LDKCVec_u64Z val_constr;
16731         val_constr.datalen = (*env)->GetArrayLength(env, val);
16732         if (val_constr.datalen > 0)
16733                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16734         else
16735                 val_constr.data = NULL;
16736         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
16737         for (size_t g = 0; g < val_constr.datalen; g++) {
16738                 int64_t val_conv_6 = val_vals[g];
16739                 val_constr.data[g] = val_conv_6;
16740         }
16741         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
16742         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
16743 }
16744
16745 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) {
16746         LDKThirtyTwoBytes chain_hash_arg_ref;
16747         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16748         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16749         LDKCVec_u64Z short_channel_ids_arg_constr;
16750         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
16751         if (short_channel_ids_arg_constr.datalen > 0)
16752                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16753         else
16754                 short_channel_ids_arg_constr.data = NULL;
16755         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
16756         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
16757                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
16758                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
16759         }
16760         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
16761         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
16762         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16763         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16764         long ret_ref = (long)ret_var.inner;
16765         if (ret_var.is_owned) {
16766                 ret_ref |= 1;
16767         }
16768         return ret_ref;
16769 }
16770
16771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16772         LDKQueryShortChannelIds orig_conv;
16773         orig_conv.inner = (void*)(orig & (~1));
16774         orig_conv.is_owned = false;
16775         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
16776         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16777         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16778         long ret_ref = (long)ret_var.inner;
16779         if (ret_var.is_owned) {
16780                 ret_ref |= 1;
16781         }
16782         return ret_ref;
16783 }
16784
16785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16786         LDKReplyShortChannelIdsEnd this_obj_conv;
16787         this_obj_conv.inner = (void*)(this_obj & (~1));
16788         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16789         ReplyShortChannelIdsEnd_free(this_obj_conv);
16790 }
16791
16792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16793         LDKReplyShortChannelIdsEnd this_ptr_conv;
16794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16795         this_ptr_conv.is_owned = false;
16796         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16797         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
16798         return ret_arr;
16799 }
16800
16801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16802         LDKReplyShortChannelIdsEnd this_ptr_conv;
16803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16804         this_ptr_conv.is_owned = false;
16805         LDKThirtyTwoBytes val_ref;
16806         CHECK((*env)->GetArrayLength(env, val) == 32);
16807         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16808         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
16809 }
16810
16811 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
16812         LDKReplyShortChannelIdsEnd this_ptr_conv;
16813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16814         this_ptr_conv.is_owned = false;
16815         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
16816         return ret_val;
16817 }
16818
16819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16820         LDKReplyShortChannelIdsEnd this_ptr_conv;
16821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16822         this_ptr_conv.is_owned = false;
16823         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
16824 }
16825
16826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
16827         LDKThirtyTwoBytes chain_hash_arg_ref;
16828         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16829         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16830         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
16831         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16832         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16833         long ret_ref = (long)ret_var.inner;
16834         if (ret_var.is_owned) {
16835                 ret_ref |= 1;
16836         }
16837         return ret_ref;
16838 }
16839
16840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16841         LDKReplyShortChannelIdsEnd orig_conv;
16842         orig_conv.inner = (void*)(orig & (~1));
16843         orig_conv.is_owned = false;
16844         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
16845         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16846         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16847         long ret_ref = (long)ret_var.inner;
16848         if (ret_var.is_owned) {
16849                 ret_ref |= 1;
16850         }
16851         return ret_ref;
16852 }
16853
16854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16855         LDKGossipTimestampFilter this_obj_conv;
16856         this_obj_conv.inner = (void*)(this_obj & (~1));
16857         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16858         GossipTimestampFilter_free(this_obj_conv);
16859 }
16860
16861 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16862         LDKGossipTimestampFilter this_ptr_conv;
16863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16864         this_ptr_conv.is_owned = false;
16865         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16866         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
16867         return ret_arr;
16868 }
16869
16870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16871         LDKGossipTimestampFilter this_ptr_conv;
16872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16873         this_ptr_conv.is_owned = false;
16874         LDKThirtyTwoBytes val_ref;
16875         CHECK((*env)->GetArrayLength(env, val) == 32);
16876         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16877         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
16878 }
16879
16880 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
16881         LDKGossipTimestampFilter this_ptr_conv;
16882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16883         this_ptr_conv.is_owned = false;
16884         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
16885         return ret_val;
16886 }
16887
16888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16889         LDKGossipTimestampFilter this_ptr_conv;
16890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16891         this_ptr_conv.is_owned = false;
16892         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
16893 }
16894
16895 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
16896         LDKGossipTimestampFilter this_ptr_conv;
16897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16898         this_ptr_conv.is_owned = false;
16899         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
16900         return ret_val;
16901 }
16902
16903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16904         LDKGossipTimestampFilter this_ptr_conv;
16905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16906         this_ptr_conv.is_owned = false;
16907         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
16908 }
16909
16910 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) {
16911         LDKThirtyTwoBytes chain_hash_arg_ref;
16912         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
16913         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
16914         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
16915         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16916         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16917         long ret_ref = (long)ret_var.inner;
16918         if (ret_var.is_owned) {
16919                 ret_ref |= 1;
16920         }
16921         return ret_ref;
16922 }
16923
16924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16925         LDKGossipTimestampFilter orig_conv;
16926         orig_conv.inner = (void*)(orig & (~1));
16927         orig_conv.is_owned = false;
16928         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
16929         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16930         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16931         long ret_ref = (long)ret_var.inner;
16932         if (ret_var.is_owned) {
16933                 ret_ref |= 1;
16934         }
16935         return ret_ref;
16936 }
16937
16938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16939         if ((this_ptr & 1) != 0) return;
16940         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
16941         FREE((void*)this_ptr);
16942         ErrorAction_free(this_ptr_conv);
16943 }
16944
16945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16946         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
16947         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
16948         *ret_copy = ErrorAction_clone(orig_conv);
16949         long ret_ref = (long)ret_copy;
16950         return ret_ref;
16951 }
16952
16953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16954         LDKLightningError this_obj_conv;
16955         this_obj_conv.inner = (void*)(this_obj & (~1));
16956         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16957         LightningError_free(this_obj_conv);
16958 }
16959
16960 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
16961         LDKLightningError this_ptr_conv;
16962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16963         this_ptr_conv.is_owned = false;
16964         LDKStr _str = LightningError_get_err(&this_ptr_conv);
16965         jstring _conv = str_ref_to_java(env, _str.chars, _str.len);
16966         return _conv;
16967 }
16968
16969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16970         LDKLightningError this_ptr_conv;
16971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16972         this_ptr_conv.is_owned = false;
16973         LDKCVec_u8Z val_ref;
16974         val_ref.datalen = (*env)->GetArrayLength(env, val);
16975         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
16976         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
16977         LightningError_set_err(&this_ptr_conv, val_ref);
16978 }
16979
16980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
16981         LDKLightningError this_ptr_conv;
16982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16983         this_ptr_conv.is_owned = false;
16984         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
16985         *ret_copy = LightningError_get_action(&this_ptr_conv);
16986         long ret_ref = (long)ret_copy;
16987         return ret_ref;
16988 }
16989
16990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16991         LDKLightningError this_ptr_conv;
16992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16993         this_ptr_conv.is_owned = false;
16994         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
16995         FREE((void*)val);
16996         LightningError_set_action(&this_ptr_conv, val_conv);
16997 }
16998
16999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, int8_tArray err_arg, int64_t action_arg) {
17000         LDKCVec_u8Z err_arg_ref;
17001         err_arg_ref.datalen = (*env)->GetArrayLength(env, err_arg);
17002         err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
17003         (*env)->GetByteArrayRegion(env, err_arg, 0, err_arg_ref.datalen, err_arg_ref.data);
17004         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
17005         FREE((void*)action_arg);
17006         LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
17007         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17008         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17009         long ret_ref = (long)ret_var.inner;
17010         if (ret_var.is_owned) {
17011                 ret_ref |= 1;
17012         }
17013         return ret_ref;
17014 }
17015
17016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17017         LDKLightningError orig_conv;
17018         orig_conv.inner = (void*)(orig & (~1));
17019         orig_conv.is_owned = false;
17020         LDKLightningError ret_var = LightningError_clone(&orig_conv);
17021         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17022         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17023         long ret_ref = (long)ret_var.inner;
17024         if (ret_var.is_owned) {
17025                 ret_ref |= 1;
17026         }
17027         return ret_ref;
17028 }
17029
17030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17031         LDKCommitmentUpdate this_obj_conv;
17032         this_obj_conv.inner = (void*)(this_obj & (~1));
17033         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17034         CommitmentUpdate_free(this_obj_conv);
17035 }
17036
17037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
17038         LDKCommitmentUpdate this_ptr_conv;
17039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17040         this_ptr_conv.is_owned = false;
17041         LDKCVec_UpdateAddHTLCZ val_constr;
17042         val_constr.datalen = (*env)->GetArrayLength(env, val);
17043         if (val_constr.datalen > 0)
17044                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17045         else
17046                 val_constr.data = NULL;
17047         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
17048         for (size_t p = 0; p < val_constr.datalen; p++) {
17049                 int64_t val_conv_15 = val_vals[p];
17050                 LDKUpdateAddHTLC val_conv_15_conv;
17051                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
17052                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
17053                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
17054                 val_constr.data[p] = val_conv_15_conv;
17055         }
17056         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
17057         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
17058 }
17059
17060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
17061         LDKCommitmentUpdate this_ptr_conv;
17062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17063         this_ptr_conv.is_owned = false;
17064         LDKCVec_UpdateFulfillHTLCZ val_constr;
17065         val_constr.datalen = (*env)->GetArrayLength(env, val);
17066         if (val_constr.datalen > 0)
17067                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17068         else
17069                 val_constr.data = NULL;
17070         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
17071         for (size_t t = 0; t < val_constr.datalen; t++) {
17072                 int64_t val_conv_19 = val_vals[t];
17073                 LDKUpdateFulfillHTLC val_conv_19_conv;
17074                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
17075                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
17076                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
17077                 val_constr.data[t] = val_conv_19_conv;
17078         }
17079         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
17080         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
17081 }
17082
17083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
17084         LDKCommitmentUpdate this_ptr_conv;
17085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17086         this_ptr_conv.is_owned = false;
17087         LDKCVec_UpdateFailHTLCZ val_constr;
17088         val_constr.datalen = (*env)->GetArrayLength(env, val);
17089         if (val_constr.datalen > 0)
17090                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17091         else
17092                 val_constr.data = NULL;
17093         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
17094         for (size_t q = 0; q < val_constr.datalen; q++) {
17095                 int64_t val_conv_16 = val_vals[q];
17096                 LDKUpdateFailHTLC val_conv_16_conv;
17097                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
17098                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
17099                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
17100                 val_constr.data[q] = val_conv_16_conv;
17101         }
17102         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
17103         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
17104 }
17105
17106 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) {
17107         LDKCommitmentUpdate this_ptr_conv;
17108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17109         this_ptr_conv.is_owned = false;
17110         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
17111         val_constr.datalen = (*env)->GetArrayLength(env, val);
17112         if (val_constr.datalen > 0)
17113                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17114         else
17115                 val_constr.data = NULL;
17116         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
17117         for (size_t z = 0; z < val_constr.datalen; z++) {
17118                 int64_t val_conv_25 = val_vals[z];
17119                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
17120                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
17121                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
17122                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
17123                 val_constr.data[z] = val_conv_25_conv;
17124         }
17125         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
17126         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
17127 }
17128
17129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
17130         LDKCommitmentUpdate this_ptr_conv;
17131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17132         this_ptr_conv.is_owned = false;
17133         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
17134         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17135         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17136         long ret_ref = (long)ret_var.inner;
17137         if (ret_var.is_owned) {
17138                 ret_ref |= 1;
17139         }
17140         return ret_ref;
17141 }
17142
17143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17144         LDKCommitmentUpdate this_ptr_conv;
17145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17146         this_ptr_conv.is_owned = false;
17147         LDKUpdateFee val_conv;
17148         val_conv.inner = (void*)(val & (~1));
17149         val_conv.is_owned = (val & 1) || (val == 0);
17150         val_conv = UpdateFee_clone(&val_conv);
17151         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
17152 }
17153
17154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
17155         LDKCommitmentUpdate this_ptr_conv;
17156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17157         this_ptr_conv.is_owned = false;
17158         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
17159         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17160         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17161         long ret_ref = (long)ret_var.inner;
17162         if (ret_var.is_owned) {
17163                 ret_ref |= 1;
17164         }
17165         return ret_ref;
17166 }
17167
17168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17169         LDKCommitmentUpdate this_ptr_conv;
17170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17171         this_ptr_conv.is_owned = false;
17172         LDKCommitmentSigned val_conv;
17173         val_conv.inner = (void*)(val & (~1));
17174         val_conv.is_owned = (val & 1) || (val == 0);
17175         val_conv = CommitmentSigned_clone(&val_conv);
17176         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
17177 }
17178
17179 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) {
17180         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
17181         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
17182         if (update_add_htlcs_arg_constr.datalen > 0)
17183                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17184         else
17185                 update_add_htlcs_arg_constr.data = NULL;
17186         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
17187         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
17188                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
17189                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
17190                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
17191                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
17192                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
17193                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
17194         }
17195         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
17196         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
17197         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
17198         if (update_fulfill_htlcs_arg_constr.datalen > 0)
17199                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17200         else
17201                 update_fulfill_htlcs_arg_constr.data = NULL;
17202         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
17203         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
17204                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
17205                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
17206                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
17207                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
17208                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
17209                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
17210         }
17211         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
17212         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
17213         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
17214         if (update_fail_htlcs_arg_constr.datalen > 0)
17215                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17216         else
17217                 update_fail_htlcs_arg_constr.data = NULL;
17218         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
17219         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
17220                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
17221                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
17222                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
17223                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
17224                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
17225                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
17226         }
17227         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
17228         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
17229         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
17230         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
17231                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17232         else
17233                 update_fail_malformed_htlcs_arg_constr.data = NULL;
17234         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
17235         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
17236                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
17237                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
17238                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
17239                 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);
17240                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
17241                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
17242         }
17243         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
17244         LDKUpdateFee update_fee_arg_conv;
17245         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
17246         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
17247         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
17248         LDKCommitmentSigned commitment_signed_arg_conv;
17249         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
17250         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
17251         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
17252         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);
17253         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17254         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17255         long ret_ref = (long)ret_var.inner;
17256         if (ret_var.is_owned) {
17257                 ret_ref |= 1;
17258         }
17259         return ret_ref;
17260 }
17261
17262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17263         LDKCommitmentUpdate orig_conv;
17264         orig_conv.inner = (void*)(orig & (~1));
17265         orig_conv.is_owned = false;
17266         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
17267         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17268         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17269         long ret_ref = (long)ret_var.inner;
17270         if (ret_var.is_owned) {
17271                 ret_ref |= 1;
17272         }
17273         return ret_ref;
17274 }
17275
17276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17277         if ((this_ptr & 1) != 0) return;
17278         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
17279         FREE((void*)this_ptr);
17280         HTLCFailChannelUpdate_free(this_ptr_conv);
17281 }
17282
17283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17284         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
17285         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
17286         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
17287         long ret_ref = (long)ret_copy;
17288         return ret_ref;
17289 }
17290
17291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17292         if ((this_ptr & 1) != 0) return;
17293         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
17294         FREE((void*)this_ptr);
17295         ChannelMessageHandler_free(this_ptr_conv);
17296 }
17297
17298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17299         if ((this_ptr & 1) != 0) return;
17300         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
17301         FREE((void*)this_ptr);
17302         RoutingMessageHandler_free(this_ptr_conv);
17303 }
17304
17305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
17306         LDKAcceptChannel obj_conv;
17307         obj_conv.inner = (void*)(obj & (~1));
17308         obj_conv.is_owned = false;
17309         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
17310         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17311         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17312         CVec_u8Z_free(ret_var);
17313         return ret_arr;
17314 }
17315
17316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17317         LDKu8slice ser_ref;
17318         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17319         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17320         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17321         *ret_conv = AcceptChannel_read(ser_ref);
17322         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17323         return (long)ret_conv;
17324 }
17325
17326 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
17327         LDKAnnouncementSignatures obj_conv;
17328         obj_conv.inner = (void*)(obj & (~1));
17329         obj_conv.is_owned = false;
17330         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
17331         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17332         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17333         CVec_u8Z_free(ret_var);
17334         return ret_arr;
17335 }
17336
17337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17338         LDKu8slice ser_ref;
17339         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17340         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17341         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17342         *ret_conv = AnnouncementSignatures_read(ser_ref);
17343         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17344         return (long)ret_conv;
17345 }
17346
17347 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
17348         LDKChannelReestablish obj_conv;
17349         obj_conv.inner = (void*)(obj & (~1));
17350         obj_conv.is_owned = false;
17351         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
17352         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17353         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17354         CVec_u8Z_free(ret_var);
17355         return ret_arr;
17356 }
17357
17358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17359         LDKu8slice ser_ref;
17360         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17361         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17362         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17363         *ret_conv = ChannelReestablish_read(ser_ref);
17364         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17365         return (long)ret_conv;
17366 }
17367
17368 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
17369         LDKClosingSigned obj_conv;
17370         obj_conv.inner = (void*)(obj & (~1));
17371         obj_conv.is_owned = false;
17372         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
17373         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17374         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17375         CVec_u8Z_free(ret_var);
17376         return ret_arr;
17377 }
17378
17379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17380         LDKu8slice ser_ref;
17381         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17382         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17383         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17384         *ret_conv = ClosingSigned_read(ser_ref);
17385         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17386         return (long)ret_conv;
17387 }
17388
17389 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
17390         LDKCommitmentSigned obj_conv;
17391         obj_conv.inner = (void*)(obj & (~1));
17392         obj_conv.is_owned = false;
17393         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
17394         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17395         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17396         CVec_u8Z_free(ret_var);
17397         return ret_arr;
17398 }
17399
17400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17401         LDKu8slice ser_ref;
17402         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17403         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17404         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17405         *ret_conv = CommitmentSigned_read(ser_ref);
17406         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17407         return (long)ret_conv;
17408 }
17409
17410 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
17411         LDKFundingCreated obj_conv;
17412         obj_conv.inner = (void*)(obj & (~1));
17413         obj_conv.is_owned = false;
17414         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
17415         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17416         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17417         CVec_u8Z_free(ret_var);
17418         return ret_arr;
17419 }
17420
17421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17422         LDKu8slice ser_ref;
17423         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17424         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17425         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17426         *ret_conv = FundingCreated_read(ser_ref);
17427         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17428         return (long)ret_conv;
17429 }
17430
17431 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
17432         LDKFundingSigned obj_conv;
17433         obj_conv.inner = (void*)(obj & (~1));
17434         obj_conv.is_owned = false;
17435         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
17436         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17437         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17438         CVec_u8Z_free(ret_var);
17439         return ret_arr;
17440 }
17441
17442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17443         LDKu8slice ser_ref;
17444         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17445         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17446         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17447         *ret_conv = FundingSigned_read(ser_ref);
17448         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17449         return (long)ret_conv;
17450 }
17451
17452 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
17453         LDKFundingLocked obj_conv;
17454         obj_conv.inner = (void*)(obj & (~1));
17455         obj_conv.is_owned = false;
17456         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
17457         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17458         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17459         CVec_u8Z_free(ret_var);
17460         return ret_arr;
17461 }
17462
17463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17464         LDKu8slice ser_ref;
17465         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17466         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17467         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17468         *ret_conv = FundingLocked_read(ser_ref);
17469         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17470         return (long)ret_conv;
17471 }
17472
17473 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
17474         LDKInit obj_conv;
17475         obj_conv.inner = (void*)(obj & (~1));
17476         obj_conv.is_owned = false;
17477         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
17478         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17479         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17480         CVec_u8Z_free(ret_var);
17481         return ret_arr;
17482 }
17483
17484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17485         LDKu8slice ser_ref;
17486         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17487         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17488         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17489         *ret_conv = Init_read(ser_ref);
17490         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17491         return (long)ret_conv;
17492 }
17493
17494 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
17495         LDKOpenChannel obj_conv;
17496         obj_conv.inner = (void*)(obj & (~1));
17497         obj_conv.is_owned = false;
17498         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
17499         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17500         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17501         CVec_u8Z_free(ret_var);
17502         return ret_arr;
17503 }
17504
17505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17506         LDKu8slice ser_ref;
17507         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17508         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17509         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17510         *ret_conv = OpenChannel_read(ser_ref);
17511         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17512         return (long)ret_conv;
17513 }
17514
17515 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
17516         LDKRevokeAndACK obj_conv;
17517         obj_conv.inner = (void*)(obj & (~1));
17518         obj_conv.is_owned = false;
17519         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
17520         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17521         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17522         CVec_u8Z_free(ret_var);
17523         return ret_arr;
17524 }
17525
17526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17527         LDKu8slice ser_ref;
17528         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17529         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17530         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17531         *ret_conv = RevokeAndACK_read(ser_ref);
17532         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17533         return (long)ret_conv;
17534 }
17535
17536 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
17537         LDKShutdown obj_conv;
17538         obj_conv.inner = (void*)(obj & (~1));
17539         obj_conv.is_owned = false;
17540         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
17541         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17542         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17543         CVec_u8Z_free(ret_var);
17544         return ret_arr;
17545 }
17546
17547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17548         LDKu8slice ser_ref;
17549         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17550         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17551         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17552         *ret_conv = Shutdown_read(ser_ref);
17553         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17554         return (long)ret_conv;
17555 }
17556
17557 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
17558         LDKUpdateFailHTLC obj_conv;
17559         obj_conv.inner = (void*)(obj & (~1));
17560         obj_conv.is_owned = false;
17561         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
17562         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17563         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17564         CVec_u8Z_free(ret_var);
17565         return ret_arr;
17566 }
17567
17568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17569         LDKu8slice ser_ref;
17570         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17571         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17572         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
17573         *ret_conv = UpdateFailHTLC_read(ser_ref);
17574         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17575         return (long)ret_conv;
17576 }
17577
17578 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
17579         LDKUpdateFailMalformedHTLC obj_conv;
17580         obj_conv.inner = (void*)(obj & (~1));
17581         obj_conv.is_owned = false;
17582         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
17583         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17584         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17585         CVec_u8Z_free(ret_var);
17586         return ret_arr;
17587 }
17588
17589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17590         LDKu8slice ser_ref;
17591         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17592         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17593         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
17594         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
17595         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17596         return (long)ret_conv;
17597 }
17598
17599 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
17600         LDKUpdateFee obj_conv;
17601         obj_conv.inner = (void*)(obj & (~1));
17602         obj_conv.is_owned = false;
17603         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
17604         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17605         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17606         CVec_u8Z_free(ret_var);
17607         return ret_arr;
17608 }
17609
17610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17611         LDKu8slice ser_ref;
17612         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17613         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17614         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
17615         *ret_conv = UpdateFee_read(ser_ref);
17616         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17617         return (long)ret_conv;
17618 }
17619
17620 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
17621         LDKUpdateFulfillHTLC obj_conv;
17622         obj_conv.inner = (void*)(obj & (~1));
17623         obj_conv.is_owned = false;
17624         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
17625         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17626         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17627         CVec_u8Z_free(ret_var);
17628         return ret_arr;
17629 }
17630
17631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17632         LDKu8slice ser_ref;
17633         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17634         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17635         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
17636         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
17637         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17638         return (long)ret_conv;
17639 }
17640
17641 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
17642         LDKUpdateAddHTLC obj_conv;
17643         obj_conv.inner = (void*)(obj & (~1));
17644         obj_conv.is_owned = false;
17645         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
17646         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17647         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17648         CVec_u8Z_free(ret_var);
17649         return ret_arr;
17650 }
17651
17652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17653         LDKu8slice ser_ref;
17654         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17655         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17656         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
17657         *ret_conv = UpdateAddHTLC_read(ser_ref);
17658         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17659         return (long)ret_conv;
17660 }
17661
17662 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
17663         LDKPing obj_conv;
17664         obj_conv.inner = (void*)(obj & (~1));
17665         obj_conv.is_owned = false;
17666         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
17667         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17668         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17669         CVec_u8Z_free(ret_var);
17670         return ret_arr;
17671 }
17672
17673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17674         LDKu8slice ser_ref;
17675         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17676         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17677         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
17678         *ret_conv = Ping_read(ser_ref);
17679         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17680         return (long)ret_conv;
17681 }
17682
17683 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
17684         LDKPong obj_conv;
17685         obj_conv.inner = (void*)(obj & (~1));
17686         obj_conv.is_owned = false;
17687         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
17688         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17689         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17690         CVec_u8Z_free(ret_var);
17691         return ret_arr;
17692 }
17693
17694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17695         LDKu8slice ser_ref;
17696         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17697         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17698         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
17699         *ret_conv = Pong_read(ser_ref);
17700         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17701         return (long)ret_conv;
17702 }
17703
17704 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17705         LDKUnsignedChannelAnnouncement obj_conv;
17706         obj_conv.inner = (void*)(obj & (~1));
17707         obj_conv.is_owned = false;
17708         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
17709         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17710         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17711         CVec_u8Z_free(ret_var);
17712         return ret_arr;
17713 }
17714
17715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17716         LDKu8slice ser_ref;
17717         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17718         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17719         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
17720         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
17721         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17722         return (long)ret_conv;
17723 }
17724
17725 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17726         LDKChannelAnnouncement obj_conv;
17727         obj_conv.inner = (void*)(obj & (~1));
17728         obj_conv.is_owned = false;
17729         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
17730         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17731         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17732         CVec_u8Z_free(ret_var);
17733         return ret_arr;
17734 }
17735
17736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17737         LDKu8slice ser_ref;
17738         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17739         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17740         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
17741         *ret_conv = ChannelAnnouncement_read(ser_ref);
17742         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17743         return (long)ret_conv;
17744 }
17745
17746 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
17747         LDKUnsignedChannelUpdate obj_conv;
17748         obj_conv.inner = (void*)(obj & (~1));
17749         obj_conv.is_owned = false;
17750         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
17751         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17752         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17753         CVec_u8Z_free(ret_var);
17754         return ret_arr;
17755 }
17756
17757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17758         LDKu8slice ser_ref;
17759         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17760         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17761         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
17762         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
17763         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17764         return (long)ret_conv;
17765 }
17766
17767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
17768         LDKChannelUpdate obj_conv;
17769         obj_conv.inner = (void*)(obj & (~1));
17770         obj_conv.is_owned = false;
17771         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
17772         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17773         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17774         CVec_u8Z_free(ret_var);
17775         return ret_arr;
17776 }
17777
17778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17779         LDKu8slice ser_ref;
17780         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17781         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17782         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
17783         *ret_conv = ChannelUpdate_read(ser_ref);
17784         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17785         return (long)ret_conv;
17786 }
17787
17788 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
17789         LDKErrorMessage obj_conv;
17790         obj_conv.inner = (void*)(obj & (~1));
17791         obj_conv.is_owned = false;
17792         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
17793         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17794         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17795         CVec_u8Z_free(ret_var);
17796         return ret_arr;
17797 }
17798
17799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17800         LDKu8slice ser_ref;
17801         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17802         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17803         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
17804         *ret_conv = ErrorMessage_read(ser_ref);
17805         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17806         return (long)ret_conv;
17807 }
17808
17809 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17810         LDKUnsignedNodeAnnouncement obj_conv;
17811         obj_conv.inner = (void*)(obj & (~1));
17812         obj_conv.is_owned = false;
17813         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
17814         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17815         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17816         CVec_u8Z_free(ret_var);
17817         return ret_arr;
17818 }
17819
17820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17821         LDKu8slice ser_ref;
17822         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17823         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17824         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
17825         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
17826         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17827         return (long)ret_conv;
17828 }
17829
17830 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
17831         LDKNodeAnnouncement obj_conv;
17832         obj_conv.inner = (void*)(obj & (~1));
17833         obj_conv.is_owned = false;
17834         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
17835         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17836         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17837         CVec_u8Z_free(ret_var);
17838         return ret_arr;
17839 }
17840
17841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17842         LDKu8slice ser_ref;
17843         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17844         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17845         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
17846         *ret_conv = NodeAnnouncement_read(ser_ref);
17847         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17848         return (long)ret_conv;
17849 }
17850
17851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17852         LDKu8slice ser_ref;
17853         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17854         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17855         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
17856         *ret_conv = QueryShortChannelIds_read(ser_ref);
17857         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17858         return (long)ret_conv;
17859 }
17860
17861 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
17862         LDKQueryShortChannelIds obj_conv;
17863         obj_conv.inner = (void*)(obj & (~1));
17864         obj_conv.is_owned = false;
17865         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
17866         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17867         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17868         CVec_u8Z_free(ret_var);
17869         return ret_arr;
17870 }
17871
17872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17873         LDKu8slice ser_ref;
17874         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17875         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17876         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
17877         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
17878         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17879         return (long)ret_conv;
17880 }
17881
17882 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
17883         LDKReplyShortChannelIdsEnd obj_conv;
17884         obj_conv.inner = (void*)(obj & (~1));
17885         obj_conv.is_owned = false;
17886         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
17887         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17888         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17889         CVec_u8Z_free(ret_var);
17890         return ret_arr;
17891 }
17892
17893 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
17894         LDKQueryChannelRange this_arg_conv;
17895         this_arg_conv.inner = (void*)(this_arg & (~1));
17896         this_arg_conv.is_owned = false;
17897         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
17898         return ret_val;
17899 }
17900
17901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17902         LDKu8slice ser_ref;
17903         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17904         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17905         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
17906         *ret_conv = QueryChannelRange_read(ser_ref);
17907         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17908         return (long)ret_conv;
17909 }
17910
17911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
17912         LDKQueryChannelRange obj_conv;
17913         obj_conv.inner = (void*)(obj & (~1));
17914         obj_conv.is_owned = false;
17915         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
17916         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17917         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17918         CVec_u8Z_free(ret_var);
17919         return ret_arr;
17920 }
17921
17922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17923         LDKu8slice ser_ref;
17924         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17925         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17926         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
17927         *ret_conv = ReplyChannelRange_read(ser_ref);
17928         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17929         return (long)ret_conv;
17930 }
17931
17932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
17933         LDKReplyChannelRange obj_conv;
17934         obj_conv.inner = (void*)(obj & (~1));
17935         obj_conv.is_owned = false;
17936         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
17937         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17938         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17939         CVec_u8Z_free(ret_var);
17940         return ret_arr;
17941 }
17942
17943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17944         LDKu8slice ser_ref;
17945         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17946         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17947         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
17948         *ret_conv = GossipTimestampFilter_read(ser_ref);
17949         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17950         return (long)ret_conv;
17951 }
17952
17953 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
17954         LDKGossipTimestampFilter obj_conv;
17955         obj_conv.inner = (void*)(obj & (~1));
17956         obj_conv.is_owned = false;
17957         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
17958         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17959         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17960         CVec_u8Z_free(ret_var);
17961         return ret_arr;
17962 }
17963
17964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17965         LDKIgnoringMessageHandler this_obj_conv;
17966         this_obj_conv.inner = (void*)(this_obj & (~1));
17967         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17968         IgnoringMessageHandler_free(this_obj_conv);
17969 }
17970
17971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
17972         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
17973         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17974         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17975         long ret_ref = (long)ret_var.inner;
17976         if (ret_var.is_owned) {
17977                 ret_ref |= 1;
17978         }
17979         return ret_ref;
17980 }
17981
17982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17983         LDKIgnoringMessageHandler this_arg_conv;
17984         this_arg_conv.inner = (void*)(this_arg & (~1));
17985         this_arg_conv.is_owned = false;
17986         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
17987         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
17988         return (long)ret;
17989 }
17990
17991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
17992         LDKIgnoringMessageHandler this_arg_conv;
17993         this_arg_conv.inner = (void*)(this_arg & (~1));
17994         this_arg_conv.is_owned = false;
17995         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
17996         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
17997         return (long)ret;
17998 }
17999
18000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18001         LDKErroringMessageHandler this_obj_conv;
18002         this_obj_conv.inner = (void*)(this_obj & (~1));
18003         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18004         ErroringMessageHandler_free(this_obj_conv);
18005 }
18006
18007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
18008         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
18009         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18010         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18011         long ret_ref = (long)ret_var.inner;
18012         if (ret_var.is_owned) {
18013                 ret_ref |= 1;
18014         }
18015         return ret_ref;
18016 }
18017
18018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
18019         LDKErroringMessageHandler this_arg_conv;
18020         this_arg_conv.inner = (void*)(this_arg & (~1));
18021         this_arg_conv.is_owned = false;
18022         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
18023         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
18024         return (long)ret;
18025 }
18026
18027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
18028         LDKErroringMessageHandler this_arg_conv;
18029         this_arg_conv.inner = (void*)(this_arg & (~1));
18030         this_arg_conv.is_owned = false;
18031         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
18032         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
18033         return (long)ret;
18034 }
18035
18036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18037         LDKMessageHandler this_obj_conv;
18038         this_obj_conv.inner = (void*)(this_obj & (~1));
18039         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18040         MessageHandler_free(this_obj_conv);
18041 }
18042
18043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
18044         LDKMessageHandler this_ptr_conv;
18045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18046         this_ptr_conv.is_owned = false;
18047         long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
18048         return ret_ret;
18049 }
18050
18051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18052         LDKMessageHandler this_ptr_conv;
18053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18054         this_ptr_conv.is_owned = false;
18055         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
18056         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
18057                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18058                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
18059         }
18060         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
18061 }
18062
18063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
18064         LDKMessageHandler this_ptr_conv;
18065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18066         this_ptr_conv.is_owned = false;
18067         long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
18068         return ret_ret;
18069 }
18070
18071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18072         LDKMessageHandler this_ptr_conv;
18073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18074         this_ptr_conv.is_owned = false;
18075         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
18076         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
18077                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18078                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
18079         }
18080         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
18081 }
18082
18083 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) {
18084         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
18085         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
18086                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18087                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
18088         }
18089         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
18090         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
18091                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18092                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
18093         }
18094         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
18095         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18096         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18097         long ret_ref = (long)ret_var.inner;
18098         if (ret_var.is_owned) {
18099                 ret_ref |= 1;
18100         }
18101         return ret_ref;
18102 }
18103
18104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18105         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
18106         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
18107         *ret = SocketDescriptor_clone(orig_conv);
18108         return (long)ret;
18109 }
18110
18111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18112         if ((this_ptr & 1) != 0) return;
18113         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
18114         FREE((void*)this_ptr);
18115         SocketDescriptor_free(this_ptr_conv);
18116 }
18117
18118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18119         LDKPeerHandleError this_obj_conv;
18120         this_obj_conv.inner = (void*)(this_obj & (~1));
18121         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18122         PeerHandleError_free(this_obj_conv);
18123 }
18124
18125 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
18126         LDKPeerHandleError this_ptr_conv;
18127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18128         this_ptr_conv.is_owned = false;
18129         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
18130         return ret_val;
18131 }
18132
18133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18134         LDKPeerHandleError this_ptr_conv;
18135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18136         this_ptr_conv.is_owned = false;
18137         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
18138 }
18139
18140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
18141         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
18142         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18143         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18144         long ret_ref = (long)ret_var.inner;
18145         if (ret_var.is_owned) {
18146                 ret_ref |= 1;
18147         }
18148         return ret_ref;
18149 }
18150
18151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18152         LDKPeerHandleError orig_conv;
18153         orig_conv.inner = (void*)(orig & (~1));
18154         orig_conv.is_owned = false;
18155         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
18156         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18157         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18158         long ret_ref = (long)ret_var.inner;
18159         if (ret_var.is_owned) {
18160                 ret_ref |= 1;
18161         }
18162         return ret_ref;
18163 }
18164
18165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18166         LDKPeerManager this_obj_conv;
18167         this_obj_conv.inner = (void*)(this_obj & (~1));
18168         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18169         PeerManager_free(this_obj_conv);
18170 }
18171
18172 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) {
18173         LDKMessageHandler message_handler_conv;
18174         message_handler_conv.inner = (void*)(message_handler & (~1));
18175         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
18176         // Warning: we need a move here but no clone is available for LDKMessageHandler
18177         LDKSecretKey our_node_secret_ref;
18178         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
18179         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
18180         unsigned char ephemeral_random_data_arr[32];
18181         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
18182         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
18183         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
18184         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18185         if (logger_conv.free == LDKLogger_JCalls_free) {
18186                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18187                 LDKLogger_JCalls_clone(logger_conv.this_arg);
18188         }
18189         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
18190         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18191         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18192         long ret_ref = (long)ret_var.inner;
18193         if (ret_var.is_owned) {
18194                 ret_ref |= 1;
18195         }
18196         return ret_ref;
18197 }
18198
18199 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
18200         LDKPeerManager this_arg_conv;
18201         this_arg_conv.inner = (void*)(this_arg & (~1));
18202         this_arg_conv.is_owned = false;
18203         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
18204         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
18205         ;
18206         for (size_t i = 0; i < ret_var.datalen; i++) {
18207                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
18208                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
18209                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
18210         }
18211         FREE(ret_var.data);
18212         return ret_arr;
18213 }
18214
18215 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) {
18216         LDKPeerManager this_arg_conv;
18217         this_arg_conv.inner = (void*)(this_arg & (~1));
18218         this_arg_conv.is_owned = false;
18219         LDKPublicKey their_node_id_ref;
18220         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
18221         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
18222         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18223         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
18224                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18225                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
18226         }
18227         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18228         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
18229         return (long)ret_conv;
18230 }
18231
18232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
18233         LDKPeerManager this_arg_conv;
18234         this_arg_conv.inner = (void*)(this_arg & (~1));
18235         this_arg_conv.is_owned = false;
18236         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18237         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
18238                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18239                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
18240         }
18241         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18242         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
18243         return (long)ret_conv;
18244 }
18245
18246 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) {
18247         LDKPeerManager this_arg_conv;
18248         this_arg_conv.inner = (void*)(this_arg & (~1));
18249         this_arg_conv.is_owned = false;
18250         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18251         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18252         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
18253         return (long)ret_conv;
18254 }
18255
18256 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) {
18257         LDKPeerManager this_arg_conv;
18258         this_arg_conv.inner = (void*)(this_arg & (~1));
18259         this_arg_conv.is_owned = false;
18260         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
18261         LDKu8slice data_ref;
18262         data_ref.datalen = (*env)->GetArrayLength(env, data);
18263         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
18264         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18265         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
18266         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
18267         return (long)ret_conv;
18268 }
18269
18270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
18271         LDKPeerManager this_arg_conv;
18272         this_arg_conv.inner = (void*)(this_arg & (~1));
18273         this_arg_conv.is_owned = false;
18274         PeerManager_process_events(&this_arg_conv);
18275 }
18276
18277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
18278         LDKPeerManager this_arg_conv;
18279         this_arg_conv.inner = (void*)(this_arg & (~1));
18280         this_arg_conv.is_owned = false;
18281         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18282         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
18283 }
18284
18285 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) {
18286         LDKPeerManager this_arg_conv;
18287         this_arg_conv.inner = (void*)(this_arg & (~1));
18288         this_arg_conv.is_owned = false;
18289         LDKPublicKey node_id_ref;
18290         CHECK((*env)->GetArrayLength(env, node_id) == 33);
18291         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
18292         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
18293 }
18294
18295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
18296         LDKPeerManager this_arg_conv;
18297         this_arg_conv.inner = (void*)(this_arg & (~1));
18298         this_arg_conv.is_owned = false;
18299         PeerManager_timer_tick_occurred(&this_arg_conv);
18300 }
18301
18302 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
18303         unsigned char commitment_seed_arr[32];
18304         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
18305         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
18306         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
18307         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18308         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
18309         return ret_arr;
18310 }
18311
18312 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) {
18313         LDKPublicKey per_commitment_point_ref;
18314         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
18315         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
18316         unsigned char base_secret_arr[32];
18317         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
18318         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
18319         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
18320         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
18321         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
18322         return (long)ret_conv;
18323 }
18324
18325 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) {
18326         LDKPublicKey per_commitment_point_ref;
18327         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
18328         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
18329         LDKPublicKey base_point_ref;
18330         CHECK((*env)->GetArrayLength(env, base_point) == 33);
18331         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
18332         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
18333         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
18334         return (long)ret_conv;
18335 }
18336
18337 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) {
18338         unsigned char per_commitment_secret_arr[32];
18339         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
18340         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
18341         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
18342         unsigned char countersignatory_revocation_base_secret_arr[32];
18343         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
18344         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
18345         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
18346         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
18347         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
18348         return (long)ret_conv;
18349 }
18350
18351 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) {
18352         LDKPublicKey per_commitment_point_ref;
18353         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
18354         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
18355         LDKPublicKey countersignatory_revocation_base_point_ref;
18356         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
18357         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
18358         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
18359         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
18360         return (long)ret_conv;
18361 }
18362
18363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18364         LDKTxCreationKeys this_obj_conv;
18365         this_obj_conv.inner = (void*)(this_obj & (~1));
18366         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18367         TxCreationKeys_free(this_obj_conv);
18368 }
18369
18370 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18371         LDKTxCreationKeys this_ptr_conv;
18372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18373         this_ptr_conv.is_owned = false;
18374         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18375         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
18376         return ret_arr;
18377 }
18378
18379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18380         LDKTxCreationKeys this_ptr_conv;
18381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18382         this_ptr_conv.is_owned = false;
18383         LDKPublicKey val_ref;
18384         CHECK((*env)->GetArrayLength(env, val) == 33);
18385         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18386         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
18387 }
18388
18389 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18390         LDKTxCreationKeys this_ptr_conv;
18391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18392         this_ptr_conv.is_owned = false;
18393         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18394         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
18395         return ret_arr;
18396 }
18397
18398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18399         LDKTxCreationKeys this_ptr_conv;
18400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18401         this_ptr_conv.is_owned = false;
18402         LDKPublicKey val_ref;
18403         CHECK((*env)->GetArrayLength(env, val) == 33);
18404         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18405         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
18406 }
18407
18408 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18409         LDKTxCreationKeys this_ptr_conv;
18410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18411         this_ptr_conv.is_owned = false;
18412         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18413         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
18414         return ret_arr;
18415 }
18416
18417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18418         LDKTxCreationKeys this_ptr_conv;
18419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18420         this_ptr_conv.is_owned = false;
18421         LDKPublicKey val_ref;
18422         CHECK((*env)->GetArrayLength(env, val) == 33);
18423         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18424         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
18425 }
18426
18427 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18428         LDKTxCreationKeys this_ptr_conv;
18429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18430         this_ptr_conv.is_owned = false;
18431         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18432         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
18433         return ret_arr;
18434 }
18435
18436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18437         LDKTxCreationKeys this_ptr_conv;
18438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18439         this_ptr_conv.is_owned = false;
18440         LDKPublicKey val_ref;
18441         CHECK((*env)->GetArrayLength(env, val) == 33);
18442         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18443         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
18444 }
18445
18446 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18447         LDKTxCreationKeys this_ptr_conv;
18448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18449         this_ptr_conv.is_owned = false;
18450         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18451         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
18452         return ret_arr;
18453 }
18454
18455 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) {
18456         LDKTxCreationKeys this_ptr_conv;
18457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18458         this_ptr_conv.is_owned = false;
18459         LDKPublicKey val_ref;
18460         CHECK((*env)->GetArrayLength(env, val) == 33);
18461         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18462         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
18463 }
18464
18465 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) {
18466         LDKPublicKey per_commitment_point_arg_ref;
18467         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
18468         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
18469         LDKPublicKey revocation_key_arg_ref;
18470         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
18471         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
18472         LDKPublicKey broadcaster_htlc_key_arg_ref;
18473         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
18474         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
18475         LDKPublicKey countersignatory_htlc_key_arg_ref;
18476         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
18477         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
18478         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
18479         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
18480         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
18481         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);
18482         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18483         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18484         long ret_ref = (long)ret_var.inner;
18485         if (ret_var.is_owned) {
18486                 ret_ref |= 1;
18487         }
18488         return ret_ref;
18489 }
18490
18491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18492         LDKTxCreationKeys orig_conv;
18493         orig_conv.inner = (void*)(orig & (~1));
18494         orig_conv.is_owned = false;
18495         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
18496         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18497         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18498         long ret_ref = (long)ret_var.inner;
18499         if (ret_var.is_owned) {
18500                 ret_ref |= 1;
18501         }
18502         return ret_ref;
18503 }
18504
18505 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
18506         LDKTxCreationKeys obj_conv;
18507         obj_conv.inner = (void*)(obj & (~1));
18508         obj_conv.is_owned = false;
18509         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
18510         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18511         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18512         CVec_u8Z_free(ret_var);
18513         return ret_arr;
18514 }
18515
18516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18517         LDKu8slice ser_ref;
18518         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18519         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18520         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
18521         *ret_conv = TxCreationKeys_read(ser_ref);
18522         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18523         return (long)ret_conv;
18524 }
18525
18526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18527         LDKChannelPublicKeys this_obj_conv;
18528         this_obj_conv.inner = (void*)(this_obj & (~1));
18529         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18530         ChannelPublicKeys_free(this_obj_conv);
18531 }
18532
18533 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18534         LDKChannelPublicKeys this_ptr_conv;
18535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18536         this_ptr_conv.is_owned = false;
18537         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18538         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
18539         return ret_arr;
18540 }
18541
18542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18543         LDKChannelPublicKeys this_ptr_conv;
18544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18545         this_ptr_conv.is_owned = false;
18546         LDKPublicKey val_ref;
18547         CHECK((*env)->GetArrayLength(env, val) == 33);
18548         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18549         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
18550 }
18551
18552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18553         LDKChannelPublicKeys this_ptr_conv;
18554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18555         this_ptr_conv.is_owned = false;
18556         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18557         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
18558         return ret_arr;
18559 }
18560
18561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18562         LDKChannelPublicKeys this_ptr_conv;
18563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18564         this_ptr_conv.is_owned = false;
18565         LDKPublicKey val_ref;
18566         CHECK((*env)->GetArrayLength(env, val) == 33);
18567         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18568         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
18569 }
18570
18571 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18572         LDKChannelPublicKeys this_ptr_conv;
18573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18574         this_ptr_conv.is_owned = false;
18575         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18576         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
18577         return ret_arr;
18578 }
18579
18580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18581         LDKChannelPublicKeys this_ptr_conv;
18582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18583         this_ptr_conv.is_owned = false;
18584         LDKPublicKey val_ref;
18585         CHECK((*env)->GetArrayLength(env, val) == 33);
18586         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18587         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
18588 }
18589
18590 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18591         LDKChannelPublicKeys this_ptr_conv;
18592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18593         this_ptr_conv.is_owned = false;
18594         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18595         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
18596         return ret_arr;
18597 }
18598
18599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18600         LDKChannelPublicKeys this_ptr_conv;
18601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18602         this_ptr_conv.is_owned = false;
18603         LDKPublicKey val_ref;
18604         CHECK((*env)->GetArrayLength(env, val) == 33);
18605         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18606         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
18607 }
18608
18609 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18610         LDKChannelPublicKeys this_ptr_conv;
18611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18612         this_ptr_conv.is_owned = false;
18613         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18614         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
18615         return ret_arr;
18616 }
18617
18618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18619         LDKChannelPublicKeys this_ptr_conv;
18620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18621         this_ptr_conv.is_owned = false;
18622         LDKPublicKey val_ref;
18623         CHECK((*env)->GetArrayLength(env, val) == 33);
18624         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18625         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
18626 }
18627
18628 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) {
18629         LDKPublicKey funding_pubkey_arg_ref;
18630         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
18631         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
18632         LDKPublicKey revocation_basepoint_arg_ref;
18633         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
18634         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
18635         LDKPublicKey payment_point_arg_ref;
18636         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
18637         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
18638         LDKPublicKey delayed_payment_basepoint_arg_ref;
18639         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
18640         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
18641         LDKPublicKey htlc_basepoint_arg_ref;
18642         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
18643         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
18644         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);
18645         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18646         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18647         long ret_ref = (long)ret_var.inner;
18648         if (ret_var.is_owned) {
18649                 ret_ref |= 1;
18650         }
18651         return ret_ref;
18652 }
18653
18654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18655         LDKChannelPublicKeys orig_conv;
18656         orig_conv.inner = (void*)(orig & (~1));
18657         orig_conv.is_owned = false;
18658         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
18659         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18660         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18661         long ret_ref = (long)ret_var.inner;
18662         if (ret_var.is_owned) {
18663                 ret_ref |= 1;
18664         }
18665         return ret_ref;
18666 }
18667
18668 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
18669         LDKChannelPublicKeys obj_conv;
18670         obj_conv.inner = (void*)(obj & (~1));
18671         obj_conv.is_owned = false;
18672         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
18673         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18674         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18675         CVec_u8Z_free(ret_var);
18676         return ret_arr;
18677 }
18678
18679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18680         LDKu8slice ser_ref;
18681         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18682         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18683         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
18684         *ret_conv = ChannelPublicKeys_read(ser_ref);
18685         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18686         return (long)ret_conv;
18687 }
18688
18689 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) {
18690         LDKPublicKey per_commitment_point_ref;
18691         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
18692         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
18693         LDKPublicKey broadcaster_delayed_payment_base_ref;
18694         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
18695         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
18696         LDKPublicKey broadcaster_htlc_base_ref;
18697         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
18698         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
18699         LDKPublicKey countersignatory_revocation_base_ref;
18700         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
18701         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
18702         LDKPublicKey countersignatory_htlc_base_ref;
18703         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
18704         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
18705         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
18706         *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);
18707         return (long)ret_conv;
18708 }
18709
18710 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) {
18711         LDKPublicKey per_commitment_point_ref;
18712         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
18713         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
18714         LDKChannelPublicKeys broadcaster_keys_conv;
18715         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
18716         broadcaster_keys_conv.is_owned = false;
18717         LDKChannelPublicKeys countersignatory_keys_conv;
18718         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
18719         countersignatory_keys_conv.is_owned = false;
18720         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
18721         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
18722         return (long)ret_conv;
18723 }
18724
18725 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) {
18726         LDKPublicKey revocation_key_ref;
18727         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
18728         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
18729         LDKPublicKey broadcaster_delayed_payment_key_ref;
18730         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
18731         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
18732         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
18733         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18734         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18735         CVec_u8Z_free(ret_var);
18736         return ret_arr;
18737 }
18738
18739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18740         LDKHTLCOutputInCommitment this_obj_conv;
18741         this_obj_conv.inner = (void*)(this_obj & (~1));
18742         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18743         HTLCOutputInCommitment_free(this_obj_conv);
18744 }
18745
18746 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
18747         LDKHTLCOutputInCommitment this_ptr_conv;
18748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18749         this_ptr_conv.is_owned = false;
18750         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
18751         return ret_val;
18752 }
18753
18754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18755         LDKHTLCOutputInCommitment this_ptr_conv;
18756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18757         this_ptr_conv.is_owned = false;
18758         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
18759 }
18760
18761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18762         LDKHTLCOutputInCommitment this_ptr_conv;
18763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18764         this_ptr_conv.is_owned = false;
18765         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
18766         return ret_val;
18767 }
18768
18769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18770         LDKHTLCOutputInCommitment this_ptr_conv;
18771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18772         this_ptr_conv.is_owned = false;
18773         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
18774 }
18775
18776 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
18777         LDKHTLCOutputInCommitment this_ptr_conv;
18778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18779         this_ptr_conv.is_owned = false;
18780         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
18781         return ret_val;
18782 }
18783
18784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18785         LDKHTLCOutputInCommitment this_ptr_conv;
18786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18787         this_ptr_conv.is_owned = false;
18788         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
18789 }
18790
18791 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18792         LDKHTLCOutputInCommitment this_ptr_conv;
18793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18794         this_ptr_conv.is_owned = false;
18795         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18796         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
18797         return ret_arr;
18798 }
18799
18800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18801         LDKHTLCOutputInCommitment this_ptr_conv;
18802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18803         this_ptr_conv.is_owned = false;
18804         LDKThirtyTwoBytes val_ref;
18805         CHECK((*env)->GetArrayLength(env, val) == 32);
18806         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18807         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
18808 }
18809
18810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
18811         LDKHTLCOutputInCommitment this_ptr_conv;
18812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18813         this_ptr_conv.is_owned = false;
18814         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
18815         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
18816         long ret_ref = (long)ret_copy;
18817         return ret_ref;
18818 }
18819
18820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18821         LDKHTLCOutputInCommitment this_ptr_conv;
18822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18823         this_ptr_conv.is_owned = false;
18824         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
18825         FREE((void*)val);
18826         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
18827 }
18828
18829 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) {
18830         LDKThirtyTwoBytes payment_hash_arg_ref;
18831         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
18832         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
18833         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
18834         FREE((void*)transaction_output_index_arg);
18835         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
18836         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18837         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18838         long ret_ref = (long)ret_var.inner;
18839         if (ret_var.is_owned) {
18840                 ret_ref |= 1;
18841         }
18842         return ret_ref;
18843 }
18844
18845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18846         LDKHTLCOutputInCommitment orig_conv;
18847         orig_conv.inner = (void*)(orig & (~1));
18848         orig_conv.is_owned = false;
18849         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
18850         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18851         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18852         long ret_ref = (long)ret_var.inner;
18853         if (ret_var.is_owned) {
18854                 ret_ref |= 1;
18855         }
18856         return ret_ref;
18857 }
18858
18859 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
18860         LDKHTLCOutputInCommitment obj_conv;
18861         obj_conv.inner = (void*)(obj & (~1));
18862         obj_conv.is_owned = false;
18863         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
18864         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18865         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18866         CVec_u8Z_free(ret_var);
18867         return ret_arr;
18868 }
18869
18870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18871         LDKu8slice ser_ref;
18872         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18873         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18874         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
18875         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
18876         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18877         return (long)ret_conv;
18878 }
18879
18880 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
18881         LDKHTLCOutputInCommitment htlc_conv;
18882         htlc_conv.inner = (void*)(htlc & (~1));
18883         htlc_conv.is_owned = false;
18884         LDKTxCreationKeys keys_conv;
18885         keys_conv.inner = (void*)(keys & (~1));
18886         keys_conv.is_owned = false;
18887         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
18888         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18889         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18890         CVec_u8Z_free(ret_var);
18891         return ret_arr;
18892 }
18893
18894 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
18895         LDKPublicKey broadcaster_ref;
18896         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
18897         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
18898         LDKPublicKey countersignatory_ref;
18899         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
18900         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
18901         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
18902         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18903         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18904         CVec_u8Z_free(ret_var);
18905         return ret_arr;
18906 }
18907
18908 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) {
18909         unsigned char prev_hash_arr[32];
18910         CHECK((*env)->GetArrayLength(env, prev_hash) == 32);
18911         (*env)->GetByteArrayRegion(env, prev_hash, 0, 32, prev_hash_arr);
18912         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
18913         LDKHTLCOutputInCommitment htlc_conv;
18914         htlc_conv.inner = (void*)(htlc & (~1));
18915         htlc_conv.is_owned = false;
18916         LDKPublicKey broadcaster_delayed_payment_key_ref;
18917         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
18918         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
18919         LDKPublicKey revocation_key_ref;
18920         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
18921         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
18922         LDKTransaction ret_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
18923         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18924         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18925         Transaction_free(ret_var);
18926         return ret_arr;
18927 }
18928
18929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18930         LDKChannelTransactionParameters this_obj_conv;
18931         this_obj_conv.inner = (void*)(this_obj & (~1));
18932         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18933         ChannelTransactionParameters_free(this_obj_conv);
18934 }
18935
18936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
18937         LDKChannelTransactionParameters this_ptr_conv;
18938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18939         this_ptr_conv.is_owned = false;
18940         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
18941         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18942         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18943         long ret_ref = (long)ret_var.inner;
18944         if (ret_var.is_owned) {
18945                 ret_ref |= 1;
18946         }
18947         return ret_ref;
18948 }
18949
18950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18951         LDKChannelTransactionParameters this_ptr_conv;
18952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18953         this_ptr_conv.is_owned = false;
18954         LDKChannelPublicKeys val_conv;
18955         val_conv.inner = (void*)(val & (~1));
18956         val_conv.is_owned = (val & 1) || (val == 0);
18957         val_conv = ChannelPublicKeys_clone(&val_conv);
18958         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
18959 }
18960
18961 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
18962         LDKChannelTransactionParameters this_ptr_conv;
18963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18964         this_ptr_conv.is_owned = false;
18965         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
18966         return ret_val;
18967 }
18968
18969 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) {
18970         LDKChannelTransactionParameters this_ptr_conv;
18971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18972         this_ptr_conv.is_owned = false;
18973         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
18974 }
18975
18976 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
18977         LDKChannelTransactionParameters this_ptr_conv;
18978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18979         this_ptr_conv.is_owned = false;
18980         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
18981         return ret_val;
18982 }
18983
18984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18985         LDKChannelTransactionParameters this_ptr_conv;
18986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18987         this_ptr_conv.is_owned = false;
18988         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
18989 }
18990
18991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
18992         LDKChannelTransactionParameters this_ptr_conv;
18993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18994         this_ptr_conv.is_owned = false;
18995         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
18996         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18997         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18998         long ret_ref = (long)ret_var.inner;
18999         if (ret_var.is_owned) {
19000                 ret_ref |= 1;
19001         }
19002         return ret_ref;
19003 }
19004
19005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19006         LDKChannelTransactionParameters this_ptr_conv;
19007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19008         this_ptr_conv.is_owned = false;
19009         LDKCounterpartyChannelTransactionParameters val_conv;
19010         val_conv.inner = (void*)(val & (~1));
19011         val_conv.is_owned = (val & 1) || (val == 0);
19012         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
19013         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
19014 }
19015
19016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
19017         LDKChannelTransactionParameters this_ptr_conv;
19018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19019         this_ptr_conv.is_owned = false;
19020         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
19021         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19022         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19023         long ret_ref = (long)ret_var.inner;
19024         if (ret_var.is_owned) {
19025                 ret_ref |= 1;
19026         }
19027         return ret_ref;
19028 }
19029
19030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19031         LDKChannelTransactionParameters this_ptr_conv;
19032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19033         this_ptr_conv.is_owned = false;
19034         LDKOutPoint val_conv;
19035         val_conv.inner = (void*)(val & (~1));
19036         val_conv.is_owned = (val & 1) || (val == 0);
19037         val_conv = OutPoint_clone(&val_conv);
19038         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
19039 }
19040
19041 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) {
19042         LDKChannelPublicKeys holder_pubkeys_arg_conv;
19043         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
19044         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
19045         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
19046         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
19047         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
19048         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
19049         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
19050         LDKOutPoint funding_outpoint_arg_conv;
19051         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
19052         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
19053         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
19054         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);
19055         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19056         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19057         long ret_ref = (long)ret_var.inner;
19058         if (ret_var.is_owned) {
19059                 ret_ref |= 1;
19060         }
19061         return ret_ref;
19062 }
19063
19064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19065         LDKChannelTransactionParameters orig_conv;
19066         orig_conv.inner = (void*)(orig & (~1));
19067         orig_conv.is_owned = false;
19068         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
19069         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19070         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19071         long ret_ref = (long)ret_var.inner;
19072         if (ret_var.is_owned) {
19073                 ret_ref |= 1;
19074         }
19075         return ret_ref;
19076 }
19077
19078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19079         LDKCounterpartyChannelTransactionParameters this_obj_conv;
19080         this_obj_conv.inner = (void*)(this_obj & (~1));
19081         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19082         CounterpartyChannelTransactionParameters_free(this_obj_conv);
19083 }
19084
19085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
19086         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19088         this_ptr_conv.is_owned = false;
19089         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
19090         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19091         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19092         long ret_ref = (long)ret_var.inner;
19093         if (ret_var.is_owned) {
19094                 ret_ref |= 1;
19095         }
19096         return ret_ref;
19097 }
19098
19099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19100         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19102         this_ptr_conv.is_owned = false;
19103         LDKChannelPublicKeys val_conv;
19104         val_conv.inner = (void*)(val & (~1));
19105         val_conv.is_owned = (val & 1) || (val == 0);
19106         val_conv = ChannelPublicKeys_clone(&val_conv);
19107         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
19108 }
19109
19110 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
19111         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19113         this_ptr_conv.is_owned = false;
19114         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
19115         return ret_val;
19116 }
19117
19118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19119         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19121         this_ptr_conv.is_owned = false;
19122         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
19123 }
19124
19125 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) {
19126         LDKChannelPublicKeys pubkeys_arg_conv;
19127         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
19128         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
19129         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
19130         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
19131         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19132         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19133         long ret_ref = (long)ret_var.inner;
19134         if (ret_var.is_owned) {
19135                 ret_ref |= 1;
19136         }
19137         return ret_ref;
19138 }
19139
19140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19141         LDKCounterpartyChannelTransactionParameters orig_conv;
19142         orig_conv.inner = (void*)(orig & (~1));
19143         orig_conv.is_owned = false;
19144         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
19145         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19146         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19147         long ret_ref = (long)ret_var.inner;
19148         if (ret_var.is_owned) {
19149                 ret_ref |= 1;
19150         }
19151         return ret_ref;
19152 }
19153
19154 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
19155         LDKChannelTransactionParameters this_arg_conv;
19156         this_arg_conv.inner = (void*)(this_arg & (~1));
19157         this_arg_conv.is_owned = false;
19158         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
19159         return ret_val;
19160 }
19161
19162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
19163         LDKChannelTransactionParameters this_arg_conv;
19164         this_arg_conv.inner = (void*)(this_arg & (~1));
19165         this_arg_conv.is_owned = false;
19166         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
19167         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19168         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19169         long ret_ref = (long)ret_var.inner;
19170         if (ret_var.is_owned) {
19171                 ret_ref |= 1;
19172         }
19173         return ret_ref;
19174 }
19175
19176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
19177         LDKChannelTransactionParameters this_arg_conv;
19178         this_arg_conv.inner = (void*)(this_arg & (~1));
19179         this_arg_conv.is_owned = false;
19180         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
19181         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19182         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19183         long ret_ref = (long)ret_var.inner;
19184         if (ret_var.is_owned) {
19185                 ret_ref |= 1;
19186         }
19187         return ret_ref;
19188 }
19189
19190 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
19191         LDKCounterpartyChannelTransactionParameters obj_conv;
19192         obj_conv.inner = (void*)(obj & (~1));
19193         obj_conv.is_owned = false;
19194         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
19195         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19196         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19197         CVec_u8Z_free(ret_var);
19198         return ret_arr;
19199 }
19200
19201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19202         LDKu8slice ser_ref;
19203         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19204         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19205         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
19206         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
19207         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19208         return (long)ret_conv;
19209 }
19210
19211 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
19212         LDKChannelTransactionParameters obj_conv;
19213         obj_conv.inner = (void*)(obj & (~1));
19214         obj_conv.is_owned = false;
19215         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
19216         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19217         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19218         CVec_u8Z_free(ret_var);
19219         return ret_arr;
19220 }
19221
19222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19223         LDKu8slice ser_ref;
19224         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19225         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19226         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
19227         *ret_conv = ChannelTransactionParameters_read(ser_ref);
19228         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19229         return (long)ret_conv;
19230 }
19231
19232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19233         LDKDirectedChannelTransactionParameters this_obj_conv;
19234         this_obj_conv.inner = (void*)(this_obj & (~1));
19235         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19236         DirectedChannelTransactionParameters_free(this_obj_conv);
19237 }
19238
19239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
19240         LDKDirectedChannelTransactionParameters this_arg_conv;
19241         this_arg_conv.inner = (void*)(this_arg & (~1));
19242         this_arg_conv.is_owned = false;
19243         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
19244         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19245         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19246         long ret_ref = (long)ret_var.inner;
19247         if (ret_var.is_owned) {
19248                 ret_ref |= 1;
19249         }
19250         return ret_ref;
19251 }
19252
19253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
19254         LDKDirectedChannelTransactionParameters this_arg_conv;
19255         this_arg_conv.inner = (void*)(this_arg & (~1));
19256         this_arg_conv.is_owned = false;
19257         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
19258         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19259         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19260         long ret_ref = (long)ret_var.inner;
19261         if (ret_var.is_owned) {
19262                 ret_ref |= 1;
19263         }
19264         return ret_ref;
19265 }
19266
19267 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
19268         LDKDirectedChannelTransactionParameters this_arg_conv;
19269         this_arg_conv.inner = (void*)(this_arg & (~1));
19270         this_arg_conv.is_owned = false;
19271         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
19272         return ret_val;
19273 }
19274
19275 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
19276         LDKDirectedChannelTransactionParameters this_arg_conv;
19277         this_arg_conv.inner = (void*)(this_arg & (~1));
19278         this_arg_conv.is_owned = false;
19279         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
19280         return ret_val;
19281 }
19282
19283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
19284         LDKDirectedChannelTransactionParameters this_arg_conv;
19285         this_arg_conv.inner = (void*)(this_arg & (~1));
19286         this_arg_conv.is_owned = false;
19287         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
19288         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19289         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19290         long ret_ref = (long)ret_var.inner;
19291         if (ret_var.is_owned) {
19292                 ret_ref |= 1;
19293         }
19294         return ret_ref;
19295 }
19296
19297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19298         LDKHolderCommitmentTransaction this_obj_conv;
19299         this_obj_conv.inner = (void*)(this_obj & (~1));
19300         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19301         HolderCommitmentTransaction_free(this_obj_conv);
19302 }
19303
19304 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
19305         LDKHolderCommitmentTransaction this_ptr_conv;
19306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19307         this_ptr_conv.is_owned = false;
19308         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19309         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
19310         return ret_arr;
19311 }
19312
19313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19314         LDKHolderCommitmentTransaction this_ptr_conv;
19315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19316         this_ptr_conv.is_owned = false;
19317         LDKSignature val_ref;
19318         CHECK((*env)->GetArrayLength(env, val) == 64);
19319         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19320         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
19321 }
19322
19323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
19324         LDKHolderCommitmentTransaction this_ptr_conv;
19325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19326         this_ptr_conv.is_owned = false;
19327         LDKCVec_SignatureZ val_constr;
19328         val_constr.datalen = (*env)->GetArrayLength(env, val);
19329         if (val_constr.datalen > 0)
19330                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19331         else
19332                 val_constr.data = NULL;
19333         for (size_t i = 0; i < val_constr.datalen; i++) {
19334                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
19335                 LDKSignature val_conv_8_ref;
19336                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
19337                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
19338                 val_constr.data[i] = val_conv_8_ref;
19339         }
19340         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
19341 }
19342
19343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19344         LDKHolderCommitmentTransaction orig_conv;
19345         orig_conv.inner = (void*)(orig & (~1));
19346         orig_conv.is_owned = false;
19347         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
19348         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19349         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19350         long ret_ref = (long)ret_var.inner;
19351         if (ret_var.is_owned) {
19352                 ret_ref |= 1;
19353         }
19354         return ret_ref;
19355 }
19356
19357 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
19358         LDKHolderCommitmentTransaction obj_conv;
19359         obj_conv.inner = (void*)(obj & (~1));
19360         obj_conv.is_owned = false;
19361         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
19362         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19363         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19364         CVec_u8Z_free(ret_var);
19365         return ret_arr;
19366 }
19367
19368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19369         LDKu8slice ser_ref;
19370         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19371         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19372         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
19373         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
19374         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19375         return (long)ret_conv;
19376 }
19377
19378 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) {
19379         LDKCommitmentTransaction commitment_tx_conv;
19380         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
19381         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
19382         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
19383         LDKSignature counterparty_sig_ref;
19384         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
19385         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
19386         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
19387         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
19388         if (counterparty_htlc_sigs_constr.datalen > 0)
19389                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19390         else
19391                 counterparty_htlc_sigs_constr.data = NULL;
19392         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
19393                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
19394                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
19395                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
19396                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
19397                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
19398         }
19399         LDKPublicKey holder_funding_key_ref;
19400         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
19401         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
19402         LDKPublicKey counterparty_funding_key_ref;
19403         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
19404         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
19405         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
19406         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19407         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19408         long ret_ref = (long)ret_var.inner;
19409         if (ret_var.is_owned) {
19410                 ret_ref |= 1;
19411         }
19412         return ret_ref;
19413 }
19414
19415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19416         LDKBuiltCommitmentTransaction this_obj_conv;
19417         this_obj_conv.inner = (void*)(this_obj & (~1));
19418         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19419         BuiltCommitmentTransaction_free(this_obj_conv);
19420 }
19421
19422 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
19423         LDKBuiltCommitmentTransaction this_ptr_conv;
19424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19425         this_ptr_conv.is_owned = false;
19426         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
19427         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19428         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19429         Transaction_free(ret_var);
19430         return ret_arr;
19431 }
19432
19433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19434         LDKBuiltCommitmentTransaction this_ptr_conv;
19435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19436         this_ptr_conv.is_owned = false;
19437         LDKTransaction val_ref;
19438         val_ref.datalen = (*env)->GetArrayLength(env, val);
19439         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
19440         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
19441         val_ref.data_is_owned = true;
19442         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
19443 }
19444
19445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
19446         LDKBuiltCommitmentTransaction this_ptr_conv;
19447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19448         this_ptr_conv.is_owned = false;
19449         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19450         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
19451         return ret_arr;
19452 }
19453
19454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19455         LDKBuiltCommitmentTransaction this_ptr_conv;
19456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19457         this_ptr_conv.is_owned = false;
19458         LDKThirtyTwoBytes val_ref;
19459         CHECK((*env)->GetArrayLength(env, val) == 32);
19460         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19461         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
19462 }
19463
19464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
19465         LDKTransaction transaction_arg_ref;
19466         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
19467         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
19468         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
19469         transaction_arg_ref.data_is_owned = true;
19470         LDKThirtyTwoBytes txid_arg_ref;
19471         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
19472         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
19473         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
19474         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19475         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19476         long ret_ref = (long)ret_var.inner;
19477         if (ret_var.is_owned) {
19478                 ret_ref |= 1;
19479         }
19480         return ret_ref;
19481 }
19482
19483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19484         LDKBuiltCommitmentTransaction orig_conv;
19485         orig_conv.inner = (void*)(orig & (~1));
19486         orig_conv.is_owned = false;
19487         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
19488         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19489         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19490         long ret_ref = (long)ret_var.inner;
19491         if (ret_var.is_owned) {
19492                 ret_ref |= 1;
19493         }
19494         return ret_ref;
19495 }
19496
19497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
19498         LDKBuiltCommitmentTransaction obj_conv;
19499         obj_conv.inner = (void*)(obj & (~1));
19500         obj_conv.is_owned = false;
19501         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
19502         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19503         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19504         CVec_u8Z_free(ret_var);
19505         return ret_arr;
19506 }
19507
19508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19509         LDKu8slice ser_ref;
19510         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19511         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19512         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
19513         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
19514         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19515         return (long)ret_conv;
19516 }
19517
19518 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) {
19519         LDKBuiltCommitmentTransaction this_arg_conv;
19520         this_arg_conv.inner = (void*)(this_arg & (~1));
19521         this_arg_conv.is_owned = false;
19522         LDKu8slice funding_redeemscript_ref;
19523         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
19524         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
19525         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19526         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
19527         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
19528         return ret_arr;
19529 }
19530
19531 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) {
19532         LDKBuiltCommitmentTransaction this_arg_conv;
19533         this_arg_conv.inner = (void*)(this_arg & (~1));
19534         this_arg_conv.is_owned = false;
19535         unsigned char funding_key_arr[32];
19536         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
19537         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
19538         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
19539         LDKu8slice funding_redeemscript_ref;
19540         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
19541         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
19542         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19543         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
19544         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
19545         return ret_arr;
19546 }
19547
19548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19549         LDKCommitmentTransaction this_obj_conv;
19550         this_obj_conv.inner = (void*)(this_obj & (~1));
19551         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19552         CommitmentTransaction_free(this_obj_conv);
19553 }
19554
19555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19556         LDKCommitmentTransaction orig_conv;
19557         orig_conv.inner = (void*)(orig & (~1));
19558         orig_conv.is_owned = false;
19559         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
19560         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19561         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19562         long ret_ref = (long)ret_var.inner;
19563         if (ret_var.is_owned) {
19564                 ret_ref |= 1;
19565         }
19566         return ret_ref;
19567 }
19568
19569 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
19570         LDKCommitmentTransaction obj_conv;
19571         obj_conv.inner = (void*)(obj & (~1));
19572         obj_conv.is_owned = false;
19573         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
19574         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19575         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19576         CVec_u8Z_free(ret_var);
19577         return ret_arr;
19578 }
19579
19580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19581         LDKu8slice ser_ref;
19582         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19583         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19584         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
19585         *ret_conv = CommitmentTransaction_read(ser_ref);
19586         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19587         return (long)ret_conv;
19588 }
19589
19590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
19591         LDKCommitmentTransaction this_arg_conv;
19592         this_arg_conv.inner = (void*)(this_arg & (~1));
19593         this_arg_conv.is_owned = false;
19594         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
19595         return ret_val;
19596 }
19597
19598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
19599         LDKCommitmentTransaction this_arg_conv;
19600         this_arg_conv.inner = (void*)(this_arg & (~1));
19601         this_arg_conv.is_owned = false;
19602         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
19603         return ret_val;
19604 }
19605
19606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
19607         LDKCommitmentTransaction this_arg_conv;
19608         this_arg_conv.inner = (void*)(this_arg & (~1));
19609         this_arg_conv.is_owned = false;
19610         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
19611         return ret_val;
19612 }
19613
19614 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
19615         LDKCommitmentTransaction this_arg_conv;
19616         this_arg_conv.inner = (void*)(this_arg & (~1));
19617         this_arg_conv.is_owned = false;
19618         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
19619         return ret_val;
19620 }
19621
19622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
19623         LDKCommitmentTransaction this_arg_conv;
19624         this_arg_conv.inner = (void*)(this_arg & (~1));
19625         this_arg_conv.is_owned = false;
19626         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
19627         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19628         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19629         long ret_ref = (long)ret_var.inner;
19630         if (ret_var.is_owned) {
19631                 ret_ref |= 1;
19632         }
19633         return ret_ref;
19634 }
19635
19636 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) {
19637         LDKCommitmentTransaction this_arg_conv;
19638         this_arg_conv.inner = (void*)(this_arg & (~1));
19639         this_arg_conv.is_owned = false;
19640         LDKDirectedChannelTransactionParameters channel_parameters_conv;
19641         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
19642         channel_parameters_conv.is_owned = false;
19643         LDKChannelPublicKeys broadcaster_keys_conv;
19644         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
19645         broadcaster_keys_conv.is_owned = false;
19646         LDKChannelPublicKeys countersignatory_keys_conv;
19647         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
19648         countersignatory_keys_conv.is_owned = false;
19649         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
19650         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
19651         return (long)ret_conv;
19652 }
19653
19654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19655         LDKTrustedCommitmentTransaction this_obj_conv;
19656         this_obj_conv.inner = (void*)(this_obj & (~1));
19657         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19658         TrustedCommitmentTransaction_free(this_obj_conv);
19659 }
19660
19661 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
19662         LDKTrustedCommitmentTransaction this_arg_conv;
19663         this_arg_conv.inner = (void*)(this_arg & (~1));
19664         this_arg_conv.is_owned = false;
19665         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19666         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
19667         return ret_arr;
19668 }
19669
19670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
19671         LDKTrustedCommitmentTransaction this_arg_conv;
19672         this_arg_conv.inner = (void*)(this_arg & (~1));
19673         this_arg_conv.is_owned = false;
19674         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
19675         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19676         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19677         long ret_ref = (long)ret_var.inner;
19678         if (ret_var.is_owned) {
19679                 ret_ref |= 1;
19680         }
19681         return ret_ref;
19682 }
19683
19684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
19685         LDKTrustedCommitmentTransaction this_arg_conv;
19686         this_arg_conv.inner = (void*)(this_arg & (~1));
19687         this_arg_conv.is_owned = false;
19688         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
19689         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19690         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19691         long ret_ref = (long)ret_var.inner;
19692         if (ret_var.is_owned) {
19693                 ret_ref |= 1;
19694         }
19695         return ret_ref;
19696 }
19697
19698 JNIEXPORT 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) {
19699         LDKTrustedCommitmentTransaction this_arg_conv;
19700         this_arg_conv.inner = (void*)(this_arg & (~1));
19701         this_arg_conv.is_owned = false;
19702         unsigned char htlc_base_key_arr[32];
19703         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
19704         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
19705         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
19706         LDKDirectedChannelTransactionParameters channel_parameters_conv;
19707         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
19708         channel_parameters_conv.is_owned = false;
19709         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
19710         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
19711         return (long)ret_conv;
19712 }
19713
19714 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) {
19715         LDKPublicKey broadcaster_payment_basepoint_ref;
19716         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
19717         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
19718         LDKPublicKey countersignatory_payment_basepoint_ref;
19719         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
19720         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
19721         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
19722         return ret_val;
19723 }
19724
19725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19726         LDKInitFeatures orig_conv;
19727         orig_conv.inner = (void*)(orig & (~1));
19728         orig_conv.is_owned = false;
19729         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
19730         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19731         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19732         long ret_ref = (long)ret_var.inner;
19733         if (ret_var.is_owned) {
19734                 ret_ref |= 1;
19735         }
19736         return ret_ref;
19737 }
19738
19739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19740         LDKNodeFeatures orig_conv;
19741         orig_conv.inner = (void*)(orig & (~1));
19742         orig_conv.is_owned = false;
19743         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
19744         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19745         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19746         long ret_ref = (long)ret_var.inner;
19747         if (ret_var.is_owned) {
19748                 ret_ref |= 1;
19749         }
19750         return ret_ref;
19751 }
19752
19753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19754         LDKChannelFeatures orig_conv;
19755         orig_conv.inner = (void*)(orig & (~1));
19756         orig_conv.is_owned = false;
19757         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
19758         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19759         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19760         long ret_ref = (long)ret_var.inner;
19761         if (ret_var.is_owned) {
19762                 ret_ref |= 1;
19763         }
19764         return ret_ref;
19765 }
19766
19767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19768         LDKInvoiceFeatures orig_conv;
19769         orig_conv.inner = (void*)(orig & (~1));
19770         orig_conv.is_owned = false;
19771         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
19772         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19773         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19774         long ret_ref = (long)ret_var.inner;
19775         if (ret_var.is_owned) {
19776                 ret_ref |= 1;
19777         }
19778         return ret_ref;
19779 }
19780
19781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19782         LDKInitFeatures this_obj_conv;
19783         this_obj_conv.inner = (void*)(this_obj & (~1));
19784         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19785         InitFeatures_free(this_obj_conv);
19786 }
19787
19788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19789         LDKNodeFeatures this_obj_conv;
19790         this_obj_conv.inner = (void*)(this_obj & (~1));
19791         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19792         NodeFeatures_free(this_obj_conv);
19793 }
19794
19795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19796         LDKChannelFeatures this_obj_conv;
19797         this_obj_conv.inner = (void*)(this_obj & (~1));
19798         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19799         ChannelFeatures_free(this_obj_conv);
19800 }
19801
19802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19803         LDKInvoiceFeatures this_obj_conv;
19804         this_obj_conv.inner = (void*)(this_obj & (~1));
19805         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19806         InvoiceFeatures_free(this_obj_conv);
19807 }
19808
19809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
19810         LDKInitFeatures ret_var = InitFeatures_empty();
19811         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19812         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19813         long ret_ref = (long)ret_var.inner;
19814         if (ret_var.is_owned) {
19815                 ret_ref |= 1;
19816         }
19817         return ret_ref;
19818 }
19819
19820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
19821         LDKInitFeatures ret_var = InitFeatures_known();
19822         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19823         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19824         long ret_ref = (long)ret_var.inner;
19825         if (ret_var.is_owned) {
19826                 ret_ref |= 1;
19827         }
19828         return ret_ref;
19829 }
19830
19831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
19832         LDKNodeFeatures ret_var = NodeFeatures_empty();
19833         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19834         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19835         long ret_ref = (long)ret_var.inner;
19836         if (ret_var.is_owned) {
19837                 ret_ref |= 1;
19838         }
19839         return ret_ref;
19840 }
19841
19842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
19843         LDKNodeFeatures ret_var = NodeFeatures_known();
19844         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19845         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19846         long ret_ref = (long)ret_var.inner;
19847         if (ret_var.is_owned) {
19848                 ret_ref |= 1;
19849         }
19850         return ret_ref;
19851 }
19852
19853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
19854         LDKChannelFeatures ret_var = ChannelFeatures_empty();
19855         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19856         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19857         long ret_ref = (long)ret_var.inner;
19858         if (ret_var.is_owned) {
19859                 ret_ref |= 1;
19860         }
19861         return ret_ref;
19862 }
19863
19864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
19865         LDKChannelFeatures ret_var = ChannelFeatures_known();
19866         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19867         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19868         long ret_ref = (long)ret_var.inner;
19869         if (ret_var.is_owned) {
19870                 ret_ref |= 1;
19871         }
19872         return ret_ref;
19873 }
19874
19875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
19876         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
19877         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19878         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19879         long ret_ref = (long)ret_var.inner;
19880         if (ret_var.is_owned) {
19881                 ret_ref |= 1;
19882         }
19883         return ret_ref;
19884 }
19885
19886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
19887         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
19888         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19889         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19890         long ret_ref = (long)ret_var.inner;
19891         if (ret_var.is_owned) {
19892                 ret_ref |= 1;
19893         }
19894         return ret_ref;
19895 }
19896
19897 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19898         LDKInitFeatures obj_conv;
19899         obj_conv.inner = (void*)(obj & (~1));
19900         obj_conv.is_owned = false;
19901         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
19902         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19903         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19904         CVec_u8Z_free(ret_var);
19905         return ret_arr;
19906 }
19907
19908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19909         LDKNodeFeatures obj_conv;
19910         obj_conv.inner = (void*)(obj & (~1));
19911         obj_conv.is_owned = false;
19912         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
19913         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19914         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19915         CVec_u8Z_free(ret_var);
19916         return ret_arr;
19917 }
19918
19919 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19920         LDKChannelFeatures obj_conv;
19921         obj_conv.inner = (void*)(obj & (~1));
19922         obj_conv.is_owned = false;
19923         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
19924         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19925         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19926         CVec_u8Z_free(ret_var);
19927         return ret_arr;
19928 }
19929
19930 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19931         LDKInvoiceFeatures obj_conv;
19932         obj_conv.inner = (void*)(obj & (~1));
19933         obj_conv.is_owned = false;
19934         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
19935         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19936         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19937         CVec_u8Z_free(ret_var);
19938         return ret_arr;
19939 }
19940
19941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19942         LDKu8slice ser_ref;
19943         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19944         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19945         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
19946         *ret_conv = InitFeatures_read(ser_ref);
19947         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19948         return (long)ret_conv;
19949 }
19950
19951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19952         LDKu8slice ser_ref;
19953         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19954         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19955         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
19956         *ret_conv = NodeFeatures_read(ser_ref);
19957         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19958         return (long)ret_conv;
19959 }
19960
19961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19962         LDKu8slice ser_ref;
19963         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19964         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19965         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
19966         *ret_conv = ChannelFeatures_read(ser_ref);
19967         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19968         return (long)ret_conv;
19969 }
19970
19971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19972         LDKu8slice ser_ref;
19973         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19974         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19975         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
19976         *ret_conv = InvoiceFeatures_read(ser_ref);
19977         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19978         return (long)ret_conv;
19979 }
19980
19981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19982         LDKRouteHop this_obj_conv;
19983         this_obj_conv.inner = (void*)(this_obj & (~1));
19984         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19985         RouteHop_free(this_obj_conv);
19986 }
19987
19988 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
19989         LDKRouteHop this_ptr_conv;
19990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19991         this_ptr_conv.is_owned = false;
19992         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19993         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
19994         return ret_arr;
19995 }
19996
19997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19998         LDKRouteHop this_ptr_conv;
19999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20000         this_ptr_conv.is_owned = false;
20001         LDKPublicKey val_ref;
20002         CHECK((*env)->GetArrayLength(env, val) == 33);
20003         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20004         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
20005 }
20006
20007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20008         LDKRouteHop this_ptr_conv;
20009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20010         this_ptr_conv.is_owned = false;
20011         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
20012         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20013         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20014         long ret_ref = (long)ret_var.inner;
20015         if (ret_var.is_owned) {
20016                 ret_ref |= 1;
20017         }
20018         return ret_ref;
20019 }
20020
20021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20022         LDKRouteHop this_ptr_conv;
20023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20024         this_ptr_conv.is_owned = false;
20025         LDKNodeFeatures val_conv;
20026         val_conv.inner = (void*)(val & (~1));
20027         val_conv.is_owned = (val & 1) || (val == 0);
20028         val_conv = NodeFeatures_clone(&val_conv);
20029         RouteHop_set_node_features(&this_ptr_conv, val_conv);
20030 }
20031
20032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20033         LDKRouteHop this_ptr_conv;
20034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20035         this_ptr_conv.is_owned = false;
20036         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
20037         return ret_val;
20038 }
20039
20040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20041         LDKRouteHop this_ptr_conv;
20042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20043         this_ptr_conv.is_owned = false;
20044         RouteHop_set_short_channel_id(&this_ptr_conv, val);
20045 }
20046
20047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20048         LDKRouteHop this_ptr_conv;
20049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20050         this_ptr_conv.is_owned = false;
20051         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
20052         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20053         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20054         long ret_ref = (long)ret_var.inner;
20055         if (ret_var.is_owned) {
20056                 ret_ref |= 1;
20057         }
20058         return ret_ref;
20059 }
20060
20061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20062         LDKRouteHop this_ptr_conv;
20063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20064         this_ptr_conv.is_owned = false;
20065         LDKChannelFeatures val_conv;
20066         val_conv.inner = (void*)(val & (~1));
20067         val_conv.is_owned = (val & 1) || (val == 0);
20068         val_conv = ChannelFeatures_clone(&val_conv);
20069         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
20070 }
20071
20072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20073         LDKRouteHop this_ptr_conv;
20074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20075         this_ptr_conv.is_owned = false;
20076         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
20077         return ret_val;
20078 }
20079
20080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20081         LDKRouteHop this_ptr_conv;
20082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20083         this_ptr_conv.is_owned = false;
20084         RouteHop_set_fee_msat(&this_ptr_conv, val);
20085 }
20086
20087 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
20088         LDKRouteHop this_ptr_conv;
20089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20090         this_ptr_conv.is_owned = false;
20091         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
20092         return ret_val;
20093 }
20094
20095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20096         LDKRouteHop this_ptr_conv;
20097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20098         this_ptr_conv.is_owned = false;
20099         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
20100 }
20101
20102 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) {
20103         LDKPublicKey pubkey_arg_ref;
20104         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
20105         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
20106         LDKNodeFeatures node_features_arg_conv;
20107         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
20108         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
20109         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
20110         LDKChannelFeatures channel_features_arg_conv;
20111         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
20112         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
20113         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
20114         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);
20115         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20116         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20117         long ret_ref = (long)ret_var.inner;
20118         if (ret_var.is_owned) {
20119                 ret_ref |= 1;
20120         }
20121         return ret_ref;
20122 }
20123
20124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20125         LDKRouteHop orig_conv;
20126         orig_conv.inner = (void*)(orig & (~1));
20127         orig_conv.is_owned = false;
20128         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
20129         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20130         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20131         long ret_ref = (long)ret_var.inner;
20132         if (ret_var.is_owned) {
20133                 ret_ref |= 1;
20134         }
20135         return ret_ref;
20136 }
20137
20138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20139         LDKRoute this_obj_conv;
20140         this_obj_conv.inner = (void*)(this_obj & (~1));
20141         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20142         Route_free(this_obj_conv);
20143 }
20144
20145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
20146         LDKRoute this_ptr_conv;
20147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20148         this_ptr_conv.is_owned = false;
20149         LDKCVec_CVec_RouteHopZZ val_constr;
20150         val_constr.datalen = (*env)->GetArrayLength(env, val);
20151         if (val_constr.datalen > 0)
20152                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
20153         else
20154                 val_constr.data = NULL;
20155         for (size_t m = 0; m < val_constr.datalen; m++) {
20156                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
20157                 LDKCVec_RouteHopZ val_conv_12_constr;
20158                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
20159                 if (val_conv_12_constr.datalen > 0)
20160                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20161                 else
20162                         val_conv_12_constr.data = NULL;
20163                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
20164                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
20165                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
20166                         LDKRouteHop val_conv_12_conv_10_conv;
20167                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
20168                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
20169                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
20170                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
20171                 }
20172                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
20173                 val_constr.data[m] = val_conv_12_constr;
20174         }
20175         Route_set_paths(&this_ptr_conv, val_constr);
20176 }
20177
20178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
20179         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
20180         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
20181         if (paths_arg_constr.datalen > 0)
20182                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
20183         else
20184                 paths_arg_constr.data = NULL;
20185         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
20186                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
20187                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
20188                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
20189                 if (paths_arg_conv_12_constr.datalen > 0)
20190                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20191                 else
20192                         paths_arg_conv_12_constr.data = NULL;
20193                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
20194                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
20195                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
20196                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
20197                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
20198                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
20199                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
20200                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
20201                 }
20202                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
20203                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
20204         }
20205         LDKRoute ret_var = Route_new(paths_arg_constr);
20206         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20207         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20208         long ret_ref = (long)ret_var.inner;
20209         if (ret_var.is_owned) {
20210                 ret_ref |= 1;
20211         }
20212         return ret_ref;
20213 }
20214
20215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20216         LDKRoute orig_conv;
20217         orig_conv.inner = (void*)(orig & (~1));
20218         orig_conv.is_owned = false;
20219         LDKRoute ret_var = Route_clone(&orig_conv);
20220         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20221         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20222         long ret_ref = (long)ret_var.inner;
20223         if (ret_var.is_owned) {
20224                 ret_ref |= 1;
20225         }
20226         return ret_ref;
20227 }
20228
20229 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
20230         LDKRoute obj_conv;
20231         obj_conv.inner = (void*)(obj & (~1));
20232         obj_conv.is_owned = false;
20233         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
20234         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20235         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20236         CVec_u8Z_free(ret_var);
20237         return ret_arr;
20238 }
20239
20240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20241         LDKu8slice ser_ref;
20242         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20243         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20244         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
20245         *ret_conv = Route_read(ser_ref);
20246         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20247         return (long)ret_conv;
20248 }
20249
20250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20251         LDKRouteHint this_obj_conv;
20252         this_obj_conv.inner = (void*)(this_obj & (~1));
20253         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20254         RouteHint_free(this_obj_conv);
20255 }
20256
20257 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20258         LDKRouteHint this_ptr_conv;
20259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20260         this_ptr_conv.is_owned = false;
20261         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20262         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHint_get_src_node_id(&this_ptr_conv).compressed_form);
20263         return ret_arr;
20264 }
20265
20266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20267         LDKRouteHint this_ptr_conv;
20268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20269         this_ptr_conv.is_owned = false;
20270         LDKPublicKey val_ref;
20271         CHECK((*env)->GetArrayLength(env, val) == 33);
20272         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20273         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
20274 }
20275
20276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20277         LDKRouteHint this_ptr_conv;
20278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20279         this_ptr_conv.is_owned = false;
20280         int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
20281         return ret_val;
20282 }
20283
20284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20285         LDKRouteHint this_ptr_conv;
20286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20287         this_ptr_conv.is_owned = false;
20288         RouteHint_set_short_channel_id(&this_ptr_conv, val);
20289 }
20290
20291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
20292         LDKRouteHint this_ptr_conv;
20293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20294         this_ptr_conv.is_owned = false;
20295         LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
20296         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20297         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20298         long ret_ref = (long)ret_var.inner;
20299         if (ret_var.is_owned) {
20300                 ret_ref |= 1;
20301         }
20302         return ret_ref;
20303 }
20304
20305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20306         LDKRouteHint this_ptr_conv;
20307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20308         this_ptr_conv.is_owned = false;
20309         LDKRoutingFees val_conv;
20310         val_conv.inner = (void*)(val & (~1));
20311         val_conv.is_owned = (val & 1) || (val == 0);
20312         val_conv = RoutingFees_clone(&val_conv);
20313         RouteHint_set_fees(&this_ptr_conv, val_conv);
20314 }
20315
20316 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
20317         LDKRouteHint this_ptr_conv;
20318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20319         this_ptr_conv.is_owned = false;
20320         int16_t ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
20321         return ret_val;
20322 }
20323
20324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20325         LDKRouteHint this_ptr_conv;
20326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20327         this_ptr_conv.is_owned = false;
20328         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
20329 }
20330
20331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20332         LDKRouteHint this_ptr_conv;
20333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20334         this_ptr_conv.is_owned = false;
20335         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20336         *ret_copy = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
20337         long ret_ref = (long)ret_copy;
20338         return ret_ref;
20339 }
20340
20341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20342         LDKRouteHint this_ptr_conv;
20343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20344         this_ptr_conv.is_owned = false;
20345         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20346         FREE((void*)val);
20347         RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
20348 }
20349
20350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20351         LDKRouteHint this_ptr_conv;
20352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20353         this_ptr_conv.is_owned = false;
20354         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20355         *ret_copy = RouteHint_get_htlc_maximum_msat(&this_ptr_conv);
20356         long ret_ref = (long)ret_copy;
20357         return ret_ref;
20358 }
20359
20360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20361         LDKRouteHint this_ptr_conv;
20362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20363         this_ptr_conv.is_owned = false;
20364         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20365         FREE((void*)val);
20366         RouteHint_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
20367 }
20368
20369 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) {
20370         LDKPublicKey src_node_id_arg_ref;
20371         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
20372         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
20373         LDKRoutingFees fees_arg_conv;
20374         fees_arg_conv.inner = (void*)(fees_arg & (~1));
20375         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
20376         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
20377         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
20378         FREE((void*)htlc_minimum_msat_arg);
20379         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
20380         FREE((void*)htlc_maximum_msat_arg);
20381         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);
20382         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20383         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20384         long ret_ref = (long)ret_var.inner;
20385         if (ret_var.is_owned) {
20386                 ret_ref |= 1;
20387         }
20388         return ret_ref;
20389 }
20390
20391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20392         LDKRouteHint orig_conv;
20393         orig_conv.inner = (void*)(orig & (~1));
20394         orig_conv.is_owned = false;
20395         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
20396         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20397         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20398         long ret_ref = (long)ret_var.inner;
20399         if (ret_var.is_owned) {
20400                 ret_ref |= 1;
20401         }
20402         return ret_ref;
20403 }
20404
20405 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) {
20406         LDKPublicKey our_node_id_ref;
20407         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
20408         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
20409         LDKNetworkGraph network_conv;
20410         network_conv.inner = (void*)(network & (~1));
20411         network_conv.is_owned = false;
20412         LDKPublicKey payee_ref;
20413         CHECK((*env)->GetArrayLength(env, payee) == 33);
20414         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
20415         LDKInvoiceFeatures payee_features_conv;
20416         payee_features_conv.inner = (void*)(payee_features & (~1));
20417         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
20418         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
20419         LDKCVec_ChannelDetailsZ first_hops_constr;
20420         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
20421         if (first_hops_constr.datalen > 0)
20422                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
20423         else
20424                 first_hops_constr.data = NULL;
20425         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
20426         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
20427                 int64_t first_hops_conv_16 = first_hops_vals[q];
20428                 LDKChannelDetails first_hops_conv_16_conv;
20429                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
20430                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
20431                 first_hops_constr.data[q] = first_hops_conv_16_conv;
20432         }
20433         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
20434         LDKCVec_RouteHintZ last_hops_constr;
20435         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
20436         if (last_hops_constr.datalen > 0)
20437                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
20438         else
20439                 last_hops_constr.data = NULL;
20440         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
20441         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
20442                 int64_t last_hops_conv_11 = last_hops_vals[l];
20443                 LDKRouteHint last_hops_conv_11_conv;
20444                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
20445                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
20446                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
20447                 last_hops_constr.data[l] = last_hops_conv_11_conv;
20448         }
20449         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
20450         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20451         if (logger_conv.free == LDKLogger_JCalls_free) {
20452                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20453                 LDKLogger_JCalls_clone(logger_conv.this_arg);
20454         }
20455         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
20456         *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);
20457         FREE(first_hops_constr.data);
20458         return (long)ret_conv;
20459 }
20460
20461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20462         LDKNetworkGraph this_obj_conv;
20463         this_obj_conv.inner = (void*)(this_obj & (~1));
20464         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20465         NetworkGraph_free(this_obj_conv);
20466 }
20467
20468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20469         LDKNetworkGraph orig_conv;
20470         orig_conv.inner = (void*)(orig & (~1));
20471         orig_conv.is_owned = false;
20472         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
20473         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20474         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20475         long ret_ref = (long)ret_var.inner;
20476         if (ret_var.is_owned) {
20477                 ret_ref |= 1;
20478         }
20479         return ret_ref;
20480 }
20481
20482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20483         LDKLockedNetworkGraph this_obj_conv;
20484         this_obj_conv.inner = (void*)(this_obj & (~1));
20485         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20486         LockedNetworkGraph_free(this_obj_conv);
20487 }
20488
20489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20490         LDKNetGraphMsgHandler this_obj_conv;
20491         this_obj_conv.inner = (void*)(this_obj & (~1));
20492         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20493         NetGraphMsgHandler_free(this_obj_conv);
20494 }
20495
20496 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) {
20497         LDKThirtyTwoBytes genesis_hash_ref;
20498         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
20499         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
20500         LDKAccess *chain_access_conv_ptr = NULL;
20501         if (chain_access != 0) {
20502                 LDKAccess chain_access_conv;
20503                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20504                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
20505                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20506                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
20507                 }
20508                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20509                 *chain_access_conv_ptr = chain_access_conv;
20510         }
20511         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20512         if (logger_conv.free == LDKLogger_JCalls_free) {
20513                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20514                 LDKLogger_JCalls_clone(logger_conv.this_arg);
20515         }
20516         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
20517         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20518         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20519         long ret_ref = (long)ret_var.inner;
20520         if (ret_var.is_owned) {
20521                 ret_ref |= 1;
20522         }
20523         return ret_ref;
20524 }
20525
20526 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) {
20527         LDKAccess *chain_access_conv_ptr = NULL;
20528         if (chain_access != 0) {
20529                 LDKAccess chain_access_conv;
20530                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20531                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
20532                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20533                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
20534                 }
20535                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20536                 *chain_access_conv_ptr = chain_access_conv;
20537         }
20538         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20539         if (logger_conv.free == LDKLogger_JCalls_free) {
20540                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20541                 LDKLogger_JCalls_clone(logger_conv.this_arg);
20542         }
20543         LDKNetworkGraph network_graph_conv;
20544         network_graph_conv.inner = (void*)(network_graph & (~1));
20545         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
20546         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
20547         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
20548         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20549         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20550         long ret_ref = (long)ret_var.inner;
20551         if (ret_var.is_owned) {
20552                 ret_ref |= 1;
20553         }
20554         return ret_ref;
20555 }
20556
20557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
20558         LDKNetGraphMsgHandler this_arg_conv;
20559         this_arg_conv.inner = (void*)(this_arg & (~1));
20560         this_arg_conv.is_owned = false;
20561         LDKAccess *chain_access_conv_ptr = NULL;
20562         if (chain_access != 0) {
20563                 LDKAccess chain_access_conv;
20564                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20565                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
20566                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20567                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
20568                 }
20569                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20570                 *chain_access_conv_ptr = chain_access_conv;
20571         }
20572         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
20573 }
20574
20575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
20576         LDKNetGraphMsgHandler this_arg_conv;
20577         this_arg_conv.inner = (void*)(this_arg & (~1));
20578         this_arg_conv.is_owned = false;
20579         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
20580         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20581         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20582         long ret_ref = (long)ret_var.inner;
20583         if (ret_var.is_owned) {
20584                 ret_ref |= 1;
20585         }
20586         return ret_ref;
20587 }
20588
20589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
20590         LDKLockedNetworkGraph this_arg_conv;
20591         this_arg_conv.inner = (void*)(this_arg & (~1));
20592         this_arg_conv.is_owned = false;
20593         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
20594         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20595         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20596         long ret_ref = (long)ret_var.inner;
20597         if (ret_var.is_owned) {
20598                 ret_ref |= 1;
20599         }
20600         return ret_ref;
20601 }
20602
20603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
20604         LDKNetGraphMsgHandler this_arg_conv;
20605         this_arg_conv.inner = (void*)(this_arg & (~1));
20606         this_arg_conv.is_owned = false;
20607         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
20608         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
20609         return (long)ret;
20610 }
20611
20612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
20613         LDKNetGraphMsgHandler this_arg_conv;
20614         this_arg_conv.inner = (void*)(this_arg & (~1));
20615         this_arg_conv.is_owned = false;
20616         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20617         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
20618         return (long)ret;
20619 }
20620
20621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20622         LDKDirectionalChannelInfo this_obj_conv;
20623         this_obj_conv.inner = (void*)(this_obj & (~1));
20624         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20625         DirectionalChannelInfo_free(this_obj_conv);
20626 }
20627
20628 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
20629         LDKDirectionalChannelInfo this_ptr_conv;
20630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20631         this_ptr_conv.is_owned = false;
20632         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
20633         return ret_val;
20634 }
20635
20636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20637         LDKDirectionalChannelInfo this_ptr_conv;
20638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20639         this_ptr_conv.is_owned = false;
20640         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
20641 }
20642
20643 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
20644         LDKDirectionalChannelInfo this_ptr_conv;
20645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20646         this_ptr_conv.is_owned = false;
20647         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
20648         return ret_val;
20649 }
20650
20651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20652         LDKDirectionalChannelInfo this_ptr_conv;
20653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20654         this_ptr_conv.is_owned = false;
20655         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
20656 }
20657
20658 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
20659         LDKDirectionalChannelInfo this_ptr_conv;
20660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20661         this_ptr_conv.is_owned = false;
20662         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
20663         return ret_val;
20664 }
20665
20666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20667         LDKDirectionalChannelInfo this_ptr_conv;
20668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20669         this_ptr_conv.is_owned = false;
20670         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
20671 }
20672
20673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20674         LDKDirectionalChannelInfo this_ptr_conv;
20675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20676         this_ptr_conv.is_owned = false;
20677         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
20678         return ret_val;
20679 }
20680
20681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20682         LDKDirectionalChannelInfo this_ptr_conv;
20683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20684         this_ptr_conv.is_owned = false;
20685         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
20686 }
20687
20688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20689         LDKDirectionalChannelInfo this_ptr_conv;
20690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20691         this_ptr_conv.is_owned = false;
20692         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20693         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
20694         long ret_ref = (long)ret_copy;
20695         return ret_ref;
20696 }
20697
20698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20699         LDKDirectionalChannelInfo this_ptr_conv;
20700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20701         this_ptr_conv.is_owned = false;
20702         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20703         FREE((void*)val);
20704         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
20705 }
20706
20707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
20708         LDKDirectionalChannelInfo this_ptr_conv;
20709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20710         this_ptr_conv.is_owned = false;
20711         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
20712         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20713         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20714         long ret_ref = (long)ret_var.inner;
20715         if (ret_var.is_owned) {
20716                 ret_ref |= 1;
20717         }
20718         return ret_ref;
20719 }
20720
20721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20722         LDKDirectionalChannelInfo this_ptr_conv;
20723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20724         this_ptr_conv.is_owned = false;
20725         LDKRoutingFees val_conv;
20726         val_conv.inner = (void*)(val & (~1));
20727         val_conv.is_owned = (val & 1) || (val == 0);
20728         val_conv = RoutingFees_clone(&val_conv);
20729         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
20730 }
20731
20732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
20733         LDKDirectionalChannelInfo this_ptr_conv;
20734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20735         this_ptr_conv.is_owned = false;
20736         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
20737         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20738         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20739         long ret_ref = (long)ret_var.inner;
20740         if (ret_var.is_owned) {
20741                 ret_ref |= 1;
20742         }
20743         return ret_ref;
20744 }
20745
20746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20747         LDKDirectionalChannelInfo this_ptr_conv;
20748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20749         this_ptr_conv.is_owned = false;
20750         LDKChannelUpdate val_conv;
20751         val_conv.inner = (void*)(val & (~1));
20752         val_conv.is_owned = (val & 1) || (val == 0);
20753         val_conv = ChannelUpdate_clone(&val_conv);
20754         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
20755 }
20756
20757 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) {
20758         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
20759         FREE((void*)htlc_maximum_msat_arg);
20760         LDKRoutingFees fees_arg_conv;
20761         fees_arg_conv.inner = (void*)(fees_arg & (~1));
20762         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
20763         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
20764         LDKChannelUpdate last_update_message_arg_conv;
20765         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
20766         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
20767         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
20768         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);
20769         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20770         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20771         long ret_ref = (long)ret_var.inner;
20772         if (ret_var.is_owned) {
20773                 ret_ref |= 1;
20774         }
20775         return ret_ref;
20776 }
20777
20778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20779         LDKDirectionalChannelInfo orig_conv;
20780         orig_conv.inner = (void*)(orig & (~1));
20781         orig_conv.is_owned = false;
20782         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
20783         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20784         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20785         long ret_ref = (long)ret_var.inner;
20786         if (ret_var.is_owned) {
20787                 ret_ref |= 1;
20788         }
20789         return ret_ref;
20790 }
20791
20792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
20793         LDKDirectionalChannelInfo obj_conv;
20794         obj_conv.inner = (void*)(obj & (~1));
20795         obj_conv.is_owned = false;
20796         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
20797         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20798         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20799         CVec_u8Z_free(ret_var);
20800         return ret_arr;
20801 }
20802
20803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20804         LDKu8slice ser_ref;
20805         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20806         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20807         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
20808         *ret_conv = DirectionalChannelInfo_read(ser_ref);
20809         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20810         return (long)ret_conv;
20811 }
20812
20813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20814         LDKChannelInfo this_obj_conv;
20815         this_obj_conv.inner = (void*)(this_obj & (~1));
20816         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20817         ChannelInfo_free(this_obj_conv);
20818 }
20819
20820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20821         LDKChannelInfo this_ptr_conv;
20822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20823         this_ptr_conv.is_owned = false;
20824         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
20825         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20826         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20827         long ret_ref = (long)ret_var.inner;
20828         if (ret_var.is_owned) {
20829                 ret_ref |= 1;
20830         }
20831         return ret_ref;
20832 }
20833
20834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20835         LDKChannelInfo this_ptr_conv;
20836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20837         this_ptr_conv.is_owned = false;
20838         LDKChannelFeatures val_conv;
20839         val_conv.inner = (void*)(val & (~1));
20840         val_conv.is_owned = (val & 1) || (val == 0);
20841         val_conv = ChannelFeatures_clone(&val_conv);
20842         ChannelInfo_set_features(&this_ptr_conv, val_conv);
20843 }
20844
20845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
20846         LDKChannelInfo this_ptr_conv;
20847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20848         this_ptr_conv.is_owned = false;
20849         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20850         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
20851         return ret_arr;
20852 }
20853
20854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20855         LDKChannelInfo this_ptr_conv;
20856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20857         this_ptr_conv.is_owned = false;
20858         LDKPublicKey val_ref;
20859         CHECK((*env)->GetArrayLength(env, val) == 33);
20860         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20861         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
20862 }
20863
20864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
20865         LDKChannelInfo this_ptr_conv;
20866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20867         this_ptr_conv.is_owned = false;
20868         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
20869         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20870         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20871         long ret_ref = (long)ret_var.inner;
20872         if (ret_var.is_owned) {
20873                 ret_ref |= 1;
20874         }
20875         return ret_ref;
20876 }
20877
20878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20879         LDKChannelInfo this_ptr_conv;
20880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20881         this_ptr_conv.is_owned = false;
20882         LDKDirectionalChannelInfo val_conv;
20883         val_conv.inner = (void*)(val & (~1));
20884         val_conv.is_owned = (val & 1) || (val == 0);
20885         val_conv = DirectionalChannelInfo_clone(&val_conv);
20886         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
20887 }
20888
20889 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
20890         LDKChannelInfo this_ptr_conv;
20891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20892         this_ptr_conv.is_owned = false;
20893         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20894         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
20895         return ret_arr;
20896 }
20897
20898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20899         LDKChannelInfo this_ptr_conv;
20900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20901         this_ptr_conv.is_owned = false;
20902         LDKPublicKey val_ref;
20903         CHECK((*env)->GetArrayLength(env, val) == 33);
20904         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20905         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
20906 }
20907
20908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
20909         LDKChannelInfo this_ptr_conv;
20910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20911         this_ptr_conv.is_owned = false;
20912         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
20913         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20914         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20915         long ret_ref = (long)ret_var.inner;
20916         if (ret_var.is_owned) {
20917                 ret_ref |= 1;
20918         }
20919         return ret_ref;
20920 }
20921
20922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20923         LDKChannelInfo this_ptr_conv;
20924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20925         this_ptr_conv.is_owned = false;
20926         LDKDirectionalChannelInfo val_conv;
20927         val_conv.inner = (void*)(val & (~1));
20928         val_conv.is_owned = (val & 1) || (val == 0);
20929         val_conv = DirectionalChannelInfo_clone(&val_conv);
20930         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
20931 }
20932
20933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
20934         LDKChannelInfo this_ptr_conv;
20935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20936         this_ptr_conv.is_owned = false;
20937         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20938         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
20939         long ret_ref = (long)ret_copy;
20940         return ret_ref;
20941 }
20942
20943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20944         LDKChannelInfo this_ptr_conv;
20945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20946         this_ptr_conv.is_owned = false;
20947         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20948         FREE((void*)val);
20949         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
20950 }
20951
20952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
20953         LDKChannelInfo this_ptr_conv;
20954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20955         this_ptr_conv.is_owned = false;
20956         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
20957         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20958         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20959         long ret_ref = (long)ret_var.inner;
20960         if (ret_var.is_owned) {
20961                 ret_ref |= 1;
20962         }
20963         return ret_ref;
20964 }
20965
20966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20967         LDKChannelInfo this_ptr_conv;
20968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20969         this_ptr_conv.is_owned = false;
20970         LDKChannelAnnouncement val_conv;
20971         val_conv.inner = (void*)(val & (~1));
20972         val_conv.is_owned = (val & 1) || (val == 0);
20973         val_conv = ChannelAnnouncement_clone(&val_conv);
20974         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
20975 }
20976
20977 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) {
20978         LDKChannelFeatures features_arg_conv;
20979         features_arg_conv.inner = (void*)(features_arg & (~1));
20980         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
20981         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
20982         LDKPublicKey node_one_arg_ref;
20983         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
20984         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
20985         LDKDirectionalChannelInfo one_to_two_arg_conv;
20986         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
20987         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
20988         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
20989         LDKPublicKey node_two_arg_ref;
20990         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
20991         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
20992         LDKDirectionalChannelInfo two_to_one_arg_conv;
20993         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
20994         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
20995         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
20996         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
20997         FREE((void*)capacity_sats_arg);
20998         LDKChannelAnnouncement announcement_message_arg_conv;
20999         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
21000         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
21001         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
21002         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);
21003         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21004         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21005         long ret_ref = (long)ret_var.inner;
21006         if (ret_var.is_owned) {
21007                 ret_ref |= 1;
21008         }
21009         return ret_ref;
21010 }
21011
21012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21013         LDKChannelInfo orig_conv;
21014         orig_conv.inner = (void*)(orig & (~1));
21015         orig_conv.is_owned = false;
21016         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
21017         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21018         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21019         long ret_ref = (long)ret_var.inner;
21020         if (ret_var.is_owned) {
21021                 ret_ref |= 1;
21022         }
21023         return ret_ref;
21024 }
21025
21026 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
21027         LDKChannelInfo obj_conv;
21028         obj_conv.inner = (void*)(obj & (~1));
21029         obj_conv.is_owned = false;
21030         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
21031         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21032         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21033         CVec_u8Z_free(ret_var);
21034         return ret_arr;
21035 }
21036
21037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21038         LDKu8slice ser_ref;
21039         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21040         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21041         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
21042         *ret_conv = ChannelInfo_read(ser_ref);
21043         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21044         return (long)ret_conv;
21045 }
21046
21047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21048         LDKRoutingFees this_obj_conv;
21049         this_obj_conv.inner = (void*)(this_obj & (~1));
21050         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21051         RoutingFees_free(this_obj_conv);
21052 }
21053
21054 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21055         LDKRoutingFees this_ptr_conv;
21056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21057         this_ptr_conv.is_owned = false;
21058         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
21059         return ret_val;
21060 }
21061
21062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21063         LDKRoutingFees this_ptr_conv;
21064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21065         this_ptr_conv.is_owned = false;
21066         RoutingFees_set_base_msat(&this_ptr_conv, val);
21067 }
21068
21069 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
21070         LDKRoutingFees this_ptr_conv;
21071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21072         this_ptr_conv.is_owned = false;
21073         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
21074         return ret_val;
21075 }
21076
21077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21078         LDKRoutingFees this_ptr_conv;
21079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21080         this_ptr_conv.is_owned = false;
21081         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
21082 }
21083
21084 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) {
21085         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
21086         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21087         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21088         long ret_ref = (long)ret_var.inner;
21089         if (ret_var.is_owned) {
21090                 ret_ref |= 1;
21091         }
21092         return ret_ref;
21093 }
21094
21095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21096         LDKRoutingFees orig_conv;
21097         orig_conv.inner = (void*)(orig & (~1));
21098         orig_conv.is_owned = false;
21099         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
21100         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21101         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21102         long ret_ref = (long)ret_var.inner;
21103         if (ret_var.is_owned) {
21104                 ret_ref |= 1;
21105         }
21106         return ret_ref;
21107 }
21108
21109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21110         LDKu8slice ser_ref;
21111         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21112         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21113         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
21114         *ret_conv = RoutingFees_read(ser_ref);
21115         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21116         return (long)ret_conv;
21117 }
21118
21119 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
21120         LDKRoutingFees obj_conv;
21121         obj_conv.inner = (void*)(obj & (~1));
21122         obj_conv.is_owned = false;
21123         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
21124         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21125         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21126         CVec_u8Z_free(ret_var);
21127         return ret_arr;
21128 }
21129
21130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21131         LDKNodeAnnouncementInfo this_obj_conv;
21132         this_obj_conv.inner = (void*)(this_obj & (~1));
21133         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21134         NodeAnnouncementInfo_free(this_obj_conv);
21135 }
21136
21137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
21138         LDKNodeAnnouncementInfo this_ptr_conv;
21139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21140         this_ptr_conv.is_owned = false;
21141         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
21142         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21143         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21144         long ret_ref = (long)ret_var.inner;
21145         if (ret_var.is_owned) {
21146                 ret_ref |= 1;
21147         }
21148         return ret_ref;
21149 }
21150
21151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21152         LDKNodeAnnouncementInfo this_ptr_conv;
21153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21154         this_ptr_conv.is_owned = false;
21155         LDKNodeFeatures val_conv;
21156         val_conv.inner = (void*)(val & (~1));
21157         val_conv.is_owned = (val & 1) || (val == 0);
21158         val_conv = NodeFeatures_clone(&val_conv);
21159         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
21160 }
21161
21162 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
21163         LDKNodeAnnouncementInfo this_ptr_conv;
21164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21165         this_ptr_conv.is_owned = false;
21166         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
21167         return ret_val;
21168 }
21169
21170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21171         LDKNodeAnnouncementInfo this_ptr_conv;
21172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21173         this_ptr_conv.is_owned = false;
21174         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
21175 }
21176
21177 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
21178         LDKNodeAnnouncementInfo this_ptr_conv;
21179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21180         this_ptr_conv.is_owned = false;
21181         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
21182         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
21183         return ret_arr;
21184 }
21185
21186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21187         LDKNodeAnnouncementInfo this_ptr_conv;
21188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21189         this_ptr_conv.is_owned = false;
21190         LDKThreeBytes val_ref;
21191         CHECK((*env)->GetArrayLength(env, val) == 3);
21192         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
21193         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
21194 }
21195
21196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
21197         LDKNodeAnnouncementInfo this_ptr_conv;
21198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21199         this_ptr_conv.is_owned = false;
21200         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21201         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
21202         return ret_arr;
21203 }
21204
21205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21206         LDKNodeAnnouncementInfo this_ptr_conv;
21207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21208         this_ptr_conv.is_owned = false;
21209         LDKThirtyTwoBytes val_ref;
21210         CHECK((*env)->GetArrayLength(env, val) == 32);
21211         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21212         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
21213 }
21214
21215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
21216         LDKNodeAnnouncementInfo this_ptr_conv;
21217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21218         this_ptr_conv.is_owned = false;
21219         LDKCVec_NetAddressZ val_constr;
21220         val_constr.datalen = (*env)->GetArrayLength(env, val);
21221         if (val_constr.datalen > 0)
21222                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21223         else
21224                 val_constr.data = NULL;
21225         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
21226         for (size_t m = 0; m < val_constr.datalen; m++) {
21227                 int64_t val_conv_12 = val_vals[m];
21228                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
21229                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
21230                 val_constr.data[m] = val_conv_12_conv;
21231         }
21232         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
21233         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
21234 }
21235
21236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
21237         LDKNodeAnnouncementInfo this_ptr_conv;
21238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21239         this_ptr_conv.is_owned = false;
21240         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
21241         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21242         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21243         long ret_ref = (long)ret_var.inner;
21244         if (ret_var.is_owned) {
21245                 ret_ref |= 1;
21246         }
21247         return ret_ref;
21248 }
21249
21250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21251         LDKNodeAnnouncementInfo this_ptr_conv;
21252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21253         this_ptr_conv.is_owned = false;
21254         LDKNodeAnnouncement val_conv;
21255         val_conv.inner = (void*)(val & (~1));
21256         val_conv.is_owned = (val & 1) || (val == 0);
21257         val_conv = NodeAnnouncement_clone(&val_conv);
21258         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
21259 }
21260
21261 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) {
21262         LDKNodeFeatures features_arg_conv;
21263         features_arg_conv.inner = (void*)(features_arg & (~1));
21264         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
21265         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
21266         LDKThreeBytes rgb_arg_ref;
21267         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
21268         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
21269         LDKThirtyTwoBytes alias_arg_ref;
21270         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
21271         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
21272         LDKCVec_NetAddressZ addresses_arg_constr;
21273         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
21274         if (addresses_arg_constr.datalen > 0)
21275                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21276         else
21277                 addresses_arg_constr.data = NULL;
21278         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
21279         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
21280                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
21281                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
21282                 FREE((void*)addresses_arg_conv_12);
21283                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
21284         }
21285         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
21286         LDKNodeAnnouncement announcement_message_arg_conv;
21287         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
21288         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
21289         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
21290         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
21291         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21292         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21293         long ret_ref = (long)ret_var.inner;
21294         if (ret_var.is_owned) {
21295                 ret_ref |= 1;
21296         }
21297         return ret_ref;
21298 }
21299
21300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21301         LDKNodeAnnouncementInfo orig_conv;
21302         orig_conv.inner = (void*)(orig & (~1));
21303         orig_conv.is_owned = false;
21304         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
21305         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21306         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21307         long ret_ref = (long)ret_var.inner;
21308         if (ret_var.is_owned) {
21309                 ret_ref |= 1;
21310         }
21311         return ret_ref;
21312 }
21313
21314 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
21315         LDKNodeAnnouncementInfo obj_conv;
21316         obj_conv.inner = (void*)(obj & (~1));
21317         obj_conv.is_owned = false;
21318         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
21319         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21320         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21321         CVec_u8Z_free(ret_var);
21322         return ret_arr;
21323 }
21324
21325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21326         LDKu8slice ser_ref;
21327         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21328         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21329         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
21330         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
21331         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21332         return (long)ret_conv;
21333 }
21334
21335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21336         LDKNodeInfo this_obj_conv;
21337         this_obj_conv.inner = (void*)(this_obj & (~1));
21338         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21339         NodeInfo_free(this_obj_conv);
21340 }
21341
21342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
21343         LDKNodeInfo this_ptr_conv;
21344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21345         this_ptr_conv.is_owned = false;
21346         LDKCVec_u64Z val_constr;
21347         val_constr.datalen = (*env)->GetArrayLength(env, val);
21348         if (val_constr.datalen > 0)
21349                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21350         else
21351                 val_constr.data = NULL;
21352         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
21353         for (size_t g = 0; g < val_constr.datalen; g++) {
21354                 int64_t val_conv_6 = val_vals[g];
21355                 val_constr.data[g] = val_conv_6;
21356         }
21357         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
21358         NodeInfo_set_channels(&this_ptr_conv, val_constr);
21359 }
21360
21361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
21362         LDKNodeInfo this_ptr_conv;
21363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21364         this_ptr_conv.is_owned = false;
21365         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
21366         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21367         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21368         long ret_ref = (long)ret_var.inner;
21369         if (ret_var.is_owned) {
21370                 ret_ref |= 1;
21371         }
21372         return ret_ref;
21373 }
21374
21375 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) {
21376         LDKNodeInfo this_ptr_conv;
21377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21378         this_ptr_conv.is_owned = false;
21379         LDKRoutingFees val_conv;
21380         val_conv.inner = (void*)(val & (~1));
21381         val_conv.is_owned = (val & 1) || (val == 0);
21382         val_conv = RoutingFees_clone(&val_conv);
21383         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
21384 }
21385
21386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
21387         LDKNodeInfo this_ptr_conv;
21388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21389         this_ptr_conv.is_owned = false;
21390         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
21391         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21392         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21393         long ret_ref = (long)ret_var.inner;
21394         if (ret_var.is_owned) {
21395                 ret_ref |= 1;
21396         }
21397         return ret_ref;
21398 }
21399
21400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21401         LDKNodeInfo this_ptr_conv;
21402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21403         this_ptr_conv.is_owned = false;
21404         LDKNodeAnnouncementInfo val_conv;
21405         val_conv.inner = (void*)(val & (~1));
21406         val_conv.is_owned = (val & 1) || (val == 0);
21407         val_conv = NodeAnnouncementInfo_clone(&val_conv);
21408         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
21409 }
21410
21411 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) {
21412         LDKCVec_u64Z channels_arg_constr;
21413         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
21414         if (channels_arg_constr.datalen > 0)
21415                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21416         else
21417                 channels_arg_constr.data = NULL;
21418         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
21419         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
21420                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
21421                 channels_arg_constr.data[g] = channels_arg_conv_6;
21422         }
21423         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
21424         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
21425         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
21426         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
21427         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
21428         LDKNodeAnnouncementInfo announcement_info_arg_conv;
21429         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
21430         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
21431         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
21432         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
21433         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21434         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21435         long ret_ref = (long)ret_var.inner;
21436         if (ret_var.is_owned) {
21437                 ret_ref |= 1;
21438         }
21439         return ret_ref;
21440 }
21441
21442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21443         LDKNodeInfo orig_conv;
21444         orig_conv.inner = (void*)(orig & (~1));
21445         orig_conv.is_owned = false;
21446         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
21447         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21448         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21449         long ret_ref = (long)ret_var.inner;
21450         if (ret_var.is_owned) {
21451                 ret_ref |= 1;
21452         }
21453         return ret_ref;
21454 }
21455
21456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
21457         LDKNodeInfo obj_conv;
21458         obj_conv.inner = (void*)(obj & (~1));
21459         obj_conv.is_owned = false;
21460         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
21461         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21462         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21463         CVec_u8Z_free(ret_var);
21464         return ret_arr;
21465 }
21466
21467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21468         LDKu8slice ser_ref;
21469         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21470         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21471         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
21472         *ret_conv = NodeInfo_read(ser_ref);
21473         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21474         return (long)ret_conv;
21475 }
21476
21477 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
21478         LDKNetworkGraph obj_conv;
21479         obj_conv.inner = (void*)(obj & (~1));
21480         obj_conv.is_owned = false;
21481         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
21482         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21483         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21484         CVec_u8Z_free(ret_var);
21485         return ret_arr;
21486 }
21487
21488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21489         LDKu8slice ser_ref;
21490         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21491         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21492         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
21493         *ret_conv = NetworkGraph_read(ser_ref);
21494         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21495         return (long)ret_conv;
21496 }
21497
21498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
21499         LDKThirtyTwoBytes genesis_hash_ref;
21500         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
21501         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
21502         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
21503         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21504         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21505         long ret_ref = (long)ret_var.inner;
21506         if (ret_var.is_owned) {
21507                 ret_ref |= 1;
21508         }
21509         return ret_ref;
21510 }
21511
21512 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) {
21513         LDKNetworkGraph this_arg_conv;
21514         this_arg_conv.inner = (void*)(this_arg & (~1));
21515         this_arg_conv.is_owned = false;
21516         LDKNodeAnnouncement msg_conv;
21517         msg_conv.inner = (void*)(msg & (~1));
21518         msg_conv.is_owned = false;
21519         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21520         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
21521         return (long)ret_conv;
21522 }
21523
21524 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) {
21525         LDKNetworkGraph this_arg_conv;
21526         this_arg_conv.inner = (void*)(this_arg & (~1));
21527         this_arg_conv.is_owned = false;
21528         LDKUnsignedNodeAnnouncement msg_conv;
21529         msg_conv.inner = (void*)(msg & (~1));
21530         msg_conv.is_owned = false;
21531         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21532         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
21533         return (long)ret_conv;
21534 }
21535
21536 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) {
21537         LDKNetworkGraph this_arg_conv;
21538         this_arg_conv.inner = (void*)(this_arg & (~1));
21539         this_arg_conv.is_owned = false;
21540         LDKChannelAnnouncement msg_conv;
21541         msg_conv.inner = (void*)(msg & (~1));
21542         msg_conv.is_owned = false;
21543         LDKAccess *chain_access_conv_ptr = NULL;
21544         if (chain_access != 0) {
21545                 LDKAccess chain_access_conv;
21546                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
21547                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
21548                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21549                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
21550                 }
21551                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
21552                 *chain_access_conv_ptr = chain_access_conv;
21553         }
21554         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21555         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
21556         return (long)ret_conv;
21557 }
21558
21559 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) {
21560         LDKNetworkGraph this_arg_conv;
21561         this_arg_conv.inner = (void*)(this_arg & (~1));
21562         this_arg_conv.is_owned = false;
21563         LDKUnsignedChannelAnnouncement msg_conv;
21564         msg_conv.inner = (void*)(msg & (~1));
21565         msg_conv.is_owned = false;
21566         LDKAccess *chain_access_conv_ptr = NULL;
21567         if (chain_access != 0) {
21568                 LDKAccess chain_access_conv;
21569                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
21570                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
21571                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21572                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
21573                 }
21574                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
21575                 *chain_access_conv_ptr = chain_access_conv;
21576         }
21577         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21578         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
21579         return (long)ret_conv;
21580 }
21581
21582 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) {
21583         LDKNetworkGraph this_arg_conv;
21584         this_arg_conv.inner = (void*)(this_arg & (~1));
21585         this_arg_conv.is_owned = false;
21586         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
21587 }
21588
21589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
21590         LDKNetworkGraph this_arg_conv;
21591         this_arg_conv.inner = (void*)(this_arg & (~1));
21592         this_arg_conv.is_owned = false;
21593         LDKChannelUpdate msg_conv;
21594         msg_conv.inner = (void*)(msg & (~1));
21595         msg_conv.is_owned = false;
21596         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21597         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
21598         return (long)ret_conv;
21599 }
21600
21601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
21602         LDKNetworkGraph this_arg_conv;
21603         this_arg_conv.inner = (void*)(this_arg & (~1));
21604         this_arg_conv.is_owned = false;
21605         LDKUnsignedChannelUpdate msg_conv;
21606         msg_conv.inner = (void*)(msg & (~1));
21607         msg_conv.is_owned = false;
21608         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21609         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
21610         return (long)ret_conv;
21611 }
21612
21613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21614         LDKFilesystemPersister this_obj_conv;
21615         this_obj_conv.inner = (void*)(this_obj & (~1));
21616         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21617         FilesystemPersister_free(this_obj_conv);
21618 }
21619
21620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, int8_tArray path_to_channel_data) {
21621         LDKCVec_u8Z path_to_channel_data_ref;
21622         path_to_channel_data_ref.datalen = (*env)->GetArrayLength(env, path_to_channel_data);
21623         path_to_channel_data_ref.data = MALLOC(path_to_channel_data_ref.datalen, "LDKCVec_u8Z Bytes");
21624         (*env)->GetByteArrayRegion(env, path_to_channel_data, 0, path_to_channel_data_ref.datalen, path_to_channel_data_ref.data);
21625         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_ref);
21626         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21627         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21628         long ret_ref = (long)ret_var.inner;
21629         if (ret_var.is_owned) {
21630                 ret_ref |= 1;
21631         }
21632         return ret_ref;
21633 }
21634
21635 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
21636         LDKFilesystemPersister this_arg_conv;
21637         this_arg_conv.inner = (void*)(this_arg & (~1));
21638         this_arg_conv.is_owned = false;
21639         LDKCVec_u8Z ret_var = FilesystemPersister_get_data_dir(&this_arg_conv);
21640         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21641         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21642         CVec_u8Z_free(ret_var);
21643         return ret_arr;
21644 }
21645
21646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, int8_tArray data_dir, int64_t manager) {
21647         LDKCVec_u8Z data_dir_ref;
21648         data_dir_ref.datalen = (*env)->GetArrayLength(env, data_dir);
21649         data_dir_ref.data = MALLOC(data_dir_ref.datalen, "LDKCVec_u8Z Bytes");
21650         (*env)->GetByteArrayRegion(env, data_dir, 0, data_dir_ref.datalen, data_dir_ref.data);
21651         LDKChannelManager manager_conv;
21652         manager_conv.inner = (void*)(manager & (~1));
21653         manager_conv.is_owned = false;
21654         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
21655         *ret_conv = FilesystemPersister_persist_manager(data_dir_ref, &manager_conv);
21656         return (long)ret_conv;
21657 }
21658
21659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
21660         LDKFilesystemPersister this_arg_conv;
21661         this_arg_conv.inner = (void*)(this_arg & (~1));
21662         this_arg_conv.is_owned = false;
21663         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
21664         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
21665                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21666                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
21667         }
21668         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21669         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
21670         return (long)ret_conv;
21671 }
21672
21673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
21674         LDKFilesystemPersister this_arg_conv;
21675         this_arg_conv.inner = (void*)(this_arg & (~1));
21676         this_arg_conv.is_owned = false;
21677         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
21678         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
21679         return (long)ret;
21680 }
21681